When Ansible has problems running plays against a host, it will output the name of the host into a file in the user's home directory ending in '.retry'. These are often not used and just cause clutter, is there a way to turn them off or put them in a different directory?
160
votes
5 Answers
199
votes
There are two options that you can add to the [defaults] section of the ansible.cfg file that will control whether or not .retry files are created and where they are created.
[defaults]
...
retry_files_enabled = True # Create them - the default
retry_files_enabled = False # Do not create them
retry_files_save_path = "~/" # The directory they will go into
# (home directory by default)
66
votes
10
votes
0
votes
Funny enough, I had a similar issue with the retry file, but as I am working with a whole team, I'd rather not touch the config.
What I decided to do instead was to remove the retry file(s) as part of the run from within the playbook:
#Clean up the admin node - basic housekeeping
- hosts:
- admin
gather_facts: no
tasks:
- name: remove retry file
file:
path: "{{ item }}"
state: absent
with_fileglob:
- "{{playbook_dir}}/*.retry"