From ArchWiki
Jump to: navigation, search


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.


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 and openssh. (Or you can use python instead of python2, but Python 3 support in Ansible is currently experimental.)

Note that a functioning SSH key setup makes the use of Ansible much more frictionless (but this is not required).

Basic usage


According to the default settings in /etc/ansible/ansible.cfg, one can define its infrastructure in /etc/ansible/hosts. For instance, the following inventory defines a tiny cluster with three nodes:



One can assign specific attributes to every node in the file. Check the official document for details.


You may check if all the nodes listed in the inventory are alive by

$ ansible all -m ping


Playbooks are the main organizational unit to configure and deploy the whole infrastructure. Check the official document for more details. Here is an extremely simple demonstration, where the administrator of the above inventory wants to perform a full system upgrade on a set of Arch Linux hosts. First, create a playbook file, with YAML formatting (always 2 spaces indentation):

- name: All hosts up-to-date
  hosts: control managed
  become: yes
    - name: full system upgrade
        update_cache: yes
        upgrade: yes

Then, run the playbook script:

# ansible-playbook --ask-become-pass syu.yml

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 require 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



More information about Python versions is available in [2], [3] and [4].

See also