Difference between revisions of "Ansible"

From ArchWiki
Jump to navigation Jump to search
(Add example inventory for ansible_python_interpreter)
(→‎Installation: extend the structure for further editing)
Line 7: Line 7:
 
== Installation ==
 
== Installation ==
  
[[Install]] the {{Pkg|ansible}} package. The remote machine where you want to automate deployment or configuration tasks only requires a Python interpreter and an [[openssh|OpenSSH server]].
+
On the control machine (server, master), [[Install]] the {{Pkg|ansible}} package.  
  
 +
On the managed machines (clients, slaves), where you want to automate deployment or configuration tasks, install {{Pkg|python2}} (or the experimental alternative {{Pkg|python}}) and {{Pkg|openssh}}. 
 +
Note that [[SSH_keys#Copying_the_public_key_to_the_remote_server|some ssh key settings]] are needed for the ssh connections to function properly.
 +
 +
== Tips and tricks ==
 
=== Telling Ansible where Python is located ===
 
=== Telling Ansible where Python is located ===
  
Line 28: Line 32:
  
 
More information this is available in [https://docs.ansible.com/ansible/python_3_support.html], [http://docs.ansible.com/faq.html#how-do-i-handle-python-pathing-not-having-a-python-2-x-in-usr-bin-python-on-a-remote-machine] and [http://docs.ansible.com/intro_inventory.html#list-of-behavioral-inventory-parameters].
 
More information this is available in [https://docs.ansible.com/ansible/python_3_support.html], [http://docs.ansible.com/faq.html#how-do-i-handle-python-pathing-not-having-a-python-2-x-in-usr-bin-python-on-a-remote-machine] and [http://docs.ansible.com/intro_inventory.html#list-of-behavioral-inventory-parameters].
 +
 +
== See also ==

Revision as of 14:35, 2 August 2017

From docs.ansible.com:

Ansible is an IT automation tool. It can configure systems, deploy software, and orchestrate more advanced IT tasks such as continuous deployments or zero downtime rolling updates.

Installation

On the control machine (server, master), Install the ansible package.

On the managed machines (clients, slaves), where you want to automate deployment or configuration tasks, install python2 (or the experimental alternative python) and openssh. Note that some ssh key settings are needed for the ssh connections to function properly.

Tips and tricks

Telling Ansible where Python is located

Ansible requires Python on the target machine, Python 3 is supported as a preview [1] but might not work for all modules. By default Ansible assumes it can find a /usr/bin/python on your remote system that is a 2.X or 3.X version of Python, specifically 2.4 or higher.

If some of your modules requires Python 2 you need to tell Ansible where to find Python 2 by setting the ansible_python_interpreter variable in your Ansible inventory file. This can be done succinctly by using host groups in the inventory:

Inventory file
[archlinux]
server1
server2

[debian]
server3

[archlinux:vars]
ansible_python_interpreter=/usr/bin/python2

More information this is available in [2], [3] and [4].

See also