To use ansible on the Arch based system, either for a local provision or on the VPS such as Linode or Contabo to name the ones that I have tested, these steps are required:

  • Install Community General Collection:
ansible-galaxy collection install community.general

Optionally check the community.general.pacman plugin is available:

ansible-doc -l | grep pacman

To clean above output, consider disabling deprecation warnings in your ansible.cfg:

deprecation_warnings = False
  • Create an inventory file with an extension you prefer, for example inventory.cfg:
[arch]			ansible_user=sudouser


Specifying the Python interpreter in Arch based distributions reduces warnings.

  • Create a playbook, the convention is to name it main.yml:
- hosts: arch
  - name: Install a package
      name: neofetch
      state: present
  • Run, provide sudo password for the sudouser, installing neofetch:
ansible-playbook -i inventory.cfg main.yml --become --ask-become-pass

The playbook is equivalent of running the following on the system:

sudo pacman -S --needed neofetch

Note that since --needed argument is passed in, the packages would not be re-installed. I could not find this in documentation, but it is quite clear from the source comments.

Look at more examples in the official docs.

This is a 33th post of #100daystooffload.