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
deprecation_warnings = False
- Create an inventory file with an extension you prefer, for example
[arch] example.com ansible_user=sudouser [arch:vars] ansible_python_interpreter=/usr/bin/python3
Specifying the Python interpreter in Arch based distributions reduces warnings.
- Create a playbook, the convention is to name it
--- - hosts: arch tasks: - name: Install a package community.general.pacman: name: neofetch state: present
- Run, provide sudo password for the
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
Look at more examples in the official docs.
This is a 33th post of #100daystooffload.