Question:
When writing and debugging Ansible playbooks, typical workflow is as follows:
ansible-playbook ./main.yaml
- Playbook fails on some task
- Fix this task and repeat line 1, waiting for all previous tasks to execute again. Which takes a lot of time
Ideally, i’d like to resume execution on failed task, having inventory and all facts collected by previous tasks. Is it even possible? How to make playbook writing/debugging faster?
Answer:
Take a look at Executing playbooks for troubleshooting.
If you want to start executing your playbook at a particular task, you can do so with the --start-at-task
option:
1 2 |
ansible-playbook playbook.yml --start-at-task="install packages" |
The above will start executing your playbook at a task named “install packages”.
When a play fails, it usually gives you something along the lines of:
1 2 3 |
PLAY RECAP ******************************************************************** to retry, use: --limit @/home/user/site.retry |
Use that --limit
command and it should retry from the failed task.