How can I break the with_items loop based on a condition
问题 I want to break out of the with_items loop based on a condition. That condition for arguments sake is if the stdout of a command is equal to a particular string. Obviously the example below does not work but this is an idea of what I want to do. For example: - name: testing loop shell: "echo {{ item }}" with_items: - "one" - "two" - "three" register: shell_command # registering the shell command and it's attributes when: shell_command.stdout == "two" # break once the stdout of the run shell