Ansible Configuration
Document Control
TODO:
- Overall structure.
- Initial draft complete
- Testing
- Ready
Ansible will search for a configuration, in order at:
ANSIBLE_CONFIG
environment variable./ansible.cfg
in the current directory~/.ansible.cfg
in the home directory/etc/ansible/ansible.cfg
Placing a ansible.cfg in your project directory makes it easy to include in your version control system.
Generally, it's best to avoid using /etc/ansible/ansible.cfg or any files owned by root.
Example ansible.cfg
See Configuring Ansible for more information.
ansible.cfg
Plase a file called ansible.cfg in your playbook directory. Example:
[defaults] strategy = free roles_path = ~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:./roles.wip internal_poll_interval = 0.001 # Facts gathering and caching gathering = smart gather_subset = all gather_timeout = 10 fact_caching_timeout = 86400 fact_caching = jsonfile fact_caching_connection = /tmp/ansible_facts_cache.json # Callback and logging stdout_callback = debug nocows = 1 log_path = /tmp/ansible.log display_skipped_hosts = no display_args_to_stdout = False deprecation_warnings = True callback_whitelist = profile_tasks,profile_roles,yaml,debug # Inventory and connectivity inventory = ./inventory inventory_ignore_extensions = ~, .orig, .bak, .ini, .cfg, .retry, .pyc, .pyo forks = 20 ansible_python_interpreter = /usr/bin/python3 remote_user = devops # Inventory plugins [inventory] enable_plugins = host_list, script, auto, yaml, ini, toml # Sudo [privilege_escalation] become = false become_method = sudo become_user = root become_ask_pass = false # SSH Connection [ssh_connection] pipelining = true ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o PreferredAuthentications=publickey #ssh_args = -o PreferredAuthentications=publickey [diff] always = yes context = 3
Environmental configuration
Ansible can also be configured using environment variables. These can be handy when dealing with CI/CD systems.
See Ansible Configuration Settings for a list of variables.
You cause the ansible-config
utility to inspect your configuration.
Last update: 2020-01-19