Bootstrap FreeKB - Ansible - Retry file
Ansible - Retry file

Updated:   |  Ansible articles

Let's say you have a playbook named foo.yml and you use the ansible-playbook command to invoke foo.yml.

ansible-playbook foo.yml

 

Let's say some problem occurs when invoking foo.yml.

PLAY [all]

TASKS [mkdir /opt/foo]
fatal: [server1.example.com]: FAILED! => {"changed": false, "checksum": "34949034fz73467b77cdc923aa747b", "msg": "Destination /var not writable"}

PLAY RECAP
server1.example.com   : ok=0  changed=0  unreachable=0  failed=1

 

This will create a .retry file, named foo.retry in this example.

-rw-rw-r--. 1 root root  27 Jul 20 09:38 foo.retry
-rw-rw-r--. 1 root root 515 Jul 20 10:01 foo.yml

 

The .retry file will contain the hostname of the managed hosts (e.g. target system).

cat foo.yml

server1.example.com

 

This occurs because, by default, the /etc/ansible/ansible.cfg has the following.

retry_files_enabled = True

 

Or, on version 2.8 or later of Ansible, the retry files lines in ansible.cfg are commented out.

# retry_files_enabled = False

 

The --limit command line option could then be used to run the playbook against the hosts defined in the .retry file.

ansible-playbook foo.yml --limit @foo.retry

 

Of course, if you don't want Ansible to create the .retry file, you could do the following in ansible.cfg.

retry_files_enabled = False

 

Or, with the following environmental variable.

ANSIBLE_RETRY_FILES_ENABLED=0 ansible-playbook foo.yml

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter acdd50 in the box below so that we can be sure you are a human.