How do you stop Ansible from creating .retry files in the home directory?

You can disable creation of retry file in ansible by modifying ansible configuration file.

[defaults]
...
retry_files_enabled = False

Ansible looks for configuration file as follows

  1. ./ansible.cfg
  2. ~/.ansible.cfg
  3. /etc/ansible/ansible.cfg

Make sure to add your changes to the appropriate config file.


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)

You can also turn the retry files off by setting an environment variable ANSIBLE_RETRY_FILES_ENABLED to 0:

$ ANSIBLE_RETRY_FILES_ENABLED=0 ansible-playbook ...

Tags:

Ansible