Ansible

Ansible is Article description::an agentless automation system written in [[Python.]] It can be used for automating machine deployments, configuration management, or orchestrating continuous delivery.

The automation jobs are written in YAML as a series of interactions with the target hosts performed via SSH by default. Ansible requires no databases nor central runtime servers.

Emerge
Install :

Configuration
The ansible ebuild has a example configuration generate the basic configuration. Change to home directory:

Extract the example configuration to the home directory:

To show current ansible configuration, issue:

Additionally a example configuration file is available on the official site of the project.

With  and   remote users and ssh ports can be specified per hosts. From 2.0 version they are deprecated, use  and   instead.

The first two lines are crucial to explicitly set Ansible's python interpreter for all hosts, Ansible only works with python 2.7, and even is the  flag is set, it will use the system's python by default. It is unnecessary if the system python is version 2.7, but still recommended to avoid unexpected failure if you change it.

Inventory
The default inventory file is named. It should be created in the directory:

This file contains the managed nodes organized in groups.

Authentication
The credentials username and password should be handled by ansible-vault change to the ansible directory in the home path:

Create a ansible vault for the credentials. The ansible-vault asks for a passphrase. This passphrase is used to encrypt and decrypt the vault.yml file:

New Vault password:

The vault file contains the credentials used to authenticate to remote nodes:

Content of the encrypted vault.yml file:

Roles for Gentoo
Over 40 roles specifically for Gentoo can be found in the https://github.com/gentoo-ansible project.

Usage
Check if ansible can manage remote machine with given user:

Get info from remote machine, what can be used later in playbooks:

Run on evapc under myuser via :

The command can be used to read module documentation. For example, to list available modules:

To print out info about the ping module:

Ad-hoc commands
Add simple examples.

External resources

 * Porting guides
 * Example ansible configuration file
 * Example hosts file