Install Ansible on Arch Linux

Installation is pretty simple….

$ sudo pacman -Sy ansible

Create an inventory hosts file:

$ sudo vim /etc/ansible/hosts

My one currently has just localhost as the control machine:


Test it works by using the ansible ping module:

[andy@home-pc ~]$ ansible control -m ping -u andy --ask-pass
SSH password: | SUCCESS => {
    "changed": false, 
    "ping": "pong"

To use the –ask-pass switch, you need to first install sshpass:

$ sudo pacman -Sy sshpass

Other useful dependencies are:

Optional dependencies for ansible
    sshpass: for ssh connections with password
    python2-passlib: crypt values for vars_prompt
    python2-netaddr: for the ipaddr filter
    python2-systemd: log to journal
    python2-pywinrm: connect to Windows machines
    python2-dnspython: for dig lookup
    python2-ovirt-engine-sdk: ovirt support
    python2-boto: aws_s3 module
    python2-jmespath: json_query support

Its probably best to enable these as and when they’re needed. One of my next aims to is connect to a Windows device to run a few tasks so I know I’m going to need the winrm module. The below playbook refreshes the pacman cache and then updates the system. It then installs the python2-pywinrm package.

$ vim ~/ansible
$ cd ~/ansible
$ vim winrm.yml


- name: All hosts up-to-date
  hosts: control
  remote_user: root
  become: yes
    - name: full system upgrade
        update_cache: yes
        upgrade: yes
    - name: ansible winrm module
        name: python2-pywinrm
        state: latest

Then run it with:

$ ansible-playbook --ask-pass winrm.yml

Enter the root password.

Leave a Reply