我想根据条件摆脱with_items循环。出于参数考虑,该条件是命令的标准输出等于特定字符串。
显然下面的示例不起作用,但这是我想做的事情。
例如:
- 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 command matches the string "two". So it will run twice and break on the second.