From Alpine Linux
This material needs expanding ...

Please feel free to help us complete it.

Ansible is a simple configuration management, deployment, task-execution, and multinode orchestration framework.

It uses SSH for the communication between the involved systems, no server or client daemons are needed, and no additional software beside Python on managed nodes is required.


On the control node (master host), you can install the ansible-core package and/or the ansible package, which is a "batteries included" package that brings in ansible-core along with a set of curated collections. Both are available from the community repository:

Tip: If you don't know you need ansible-core, I would recommend installing ansible.

# apk add ansible

Create a SSH key

Generate a SSH key for the managed node. It's recommended to use a key which is protected with a password.

$ ssh-keygen -t ed25519

Managed nodes

There are only minimal requirements for the clients. For every system you want to manage, you need to have the client's SSH key in the authorized_keys file of the management system and Python.

Install the Python package:

# apk add python3

Transfer the SSH key

There are two ways to do it. From a default Alpine installation you can use ssh and cat to do it.

ssh root@[IP of the management system] 'cat ~/.ssh/' | cat - >> ~/.ssh/authorized_keys

If you are planning to use additional features of SSH. ssh-copy-id, which is provided by the openssh-client package, can help you with the key setup.

ssh-copy-id -i ~/.ssh/ root@[IP of the management system]




The inventory is the list of managed nodes or "hosts". The default location is /etc/ansible/hosts. You can specify a different inventory file using -i PATH on the command line. See How to build your inventory for more information.

Contents of /etc/ansible/hosts

[control] [managed]


Check that you can reach all nodes:

$ ansible all -m ping


When writing playbooks for Alpine Linux there are some things to keep in mind:

  1. There is support for OpenRC, the Init System, in the service module.
    - name: Make "lighttpd" start on boot and start now, if not started.
        name: lighttpd
        enabled: true
        state: started
  2. There is support for APK as of Ansible 2.0, in the apk module.
    - name: Ensure lighttpd is installed, update cache and install if not.
        name: lighttpd
        state: present
        update_cache: yes
  3. There is support for the Awall firewall as of Ansible 2.4, in the awall module.
    - name: Enable "foobar" policy
        name: foobar
        state: enabled
        activate: true
  4. If you are going to re-use playbooks from other Linux distributions, please keep in mind that Alpine Linux uses different paths for the binaries. For example rm is /bin/rm.



You can check if you're using "proven practices", by installing the ansible-lint package and running:

$ ansible-lint -s ./PATH

See Also