Proper way to define default variables for all hosts in Ansible

Akif picture Akif · Sep 13, 2017 · Viewed 8.7k times · Source

There is a definition of [all:vars] in my ansible inventory file as follows:

[all:vars]
ansible_shell_type=bash
ansible_user=certain_user
ansible_ssh_common_args="-o ConnectionAttempts=10"

I plan to move such variables into ansible.cfg to set defaults for all hosts. Would it simply work in a similar way or is there any circumstances to consider? What else alternatives available to remove [all:vars] from the inventory file?

Answer

LuckyAshnar picture LuckyAshnar · Sep 13, 2017

Consider moving the variables to /group_vars/all to achieve the same in a supported way.