我不明白你声称“第一个命令执行失败整个游戏”。如果Ansible以这种方式表现出来,这是没有道理的。
以下任务:
- command: /usr/bin/false
retries: 3
delay: 3
register: result
until: result.rc == 0
生产:
TASK [command] ******************************************************************************************
FAILED - RETRYING: command (3 retries left).
FAILED - RETRYING: command (2 retries left).
FAILED - RETRYING: command (1 retries left).
fatal: [localhost]: FAILED! => {"attempts": 3, "changed": true, "cmd": ["/usr/bin/false"], "delta": "0:00:00.003883", "end": "2017-05-23 21:39:51.669623", "failed": true, "rc": 1, "start": "2017-05-23 21:39:51.665740", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
这似乎正是你想要的。
请发布整个任务。我不明白你的担心 - 如果你写得正确,首先执行不应该失败。 – techraf