Ansible - Retry file

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: []: FAILED! => {"changed": false, "checksum": "34949034fz73467b77cdc923aa747b", "msg": "Destination /var not writable"}

PLAY RECAP   : 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


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


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

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


Web design by yours truely - me, myself, and I   |   |