我不明白你聲稱「第一個命令執行失敗整個遊戲」。如果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