System specific variables in ansible

I opted to use Ansible's ability to source inventory from a directory. In this manner I could define the ansible_python_interpreter for localhost only for the local machine

inventory_dir/local

[local]
localhost ansible_python_interpreter="/path/to/alternate/bin/python"

And then just use the directory as you would an inventory file.

ansible-playbook -i inventory_dir playbook.yml


Well you can set in three ways

  1. http://docs.ansible.com/intro_inventory.html#list-of-behavioral-inventory-parameters ansible_python_interpreter=/usr/bin/python2 this will set it per host
  2. Set it host_vars/ ansible_python_interpreter: "/usr/bin/python2" this will set it per host
  3. set it for all nodes in the file group_vars/all (you may need to create the directory group_vars and the file all) as ansible_python_interpreter: "/usr/bin/python2"

Hope that helps

Tags:

Ansible