Ansible is a configuration management system written in Python. It can be used for automating machine deployments.
USE flags for app-admin/ansible Model-driven deployment, config management, and command execution framework
emerge --ask app-admin/ansible
The app-admin/ansible-1.9.6 ebuild will not generate the basic configuration. Ansible upstream provides an example configuration file that includes all options for convenience.
The default inventory file is named hosts. It should be created in the /etc/ansible directory:
This file contains the managed computers organized in groups.
[all:vars] # IMPORTANT ansible_python_interpreter=/usr/bin/python2.7 [servers] myserver01 myserver02 myserver03 [workstations] evapc ansible_ssh_user=myuser ansible_ssh_port=9000 joepc ansible_ssh_user=myuser mypc ansible_ssh_user=myuser ansible_connection=local
ansible_ssh_port= remote users and ssh ports can be specified per hosts. From 2.0 version they are deprecated, use
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
python_targets_python2_7 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.
[defaults] # Default remote user remote_user = root # SSH timeout in seconds timeout = 10
To show current ansible configuration, issue:
Roles for Gentoo
Over 40 roles specifically for Gentoo can be found in the https://github.com/gentoo-ansible project.
Check if ansible can manage remote machine with given user:
ansible evapc -u myuser -m ping
Get info from remote machine, what can be used later in playbooks:
ansible evapc -u myuser -m setup
Run emerge --sync on evapc under myuser via sudo:
ansible evapc -s -u myuser -m command -a "emerge --sync"
||Specifies the user, if absent ansible will search in your inventory file for default user associated to the given host, if not any it will use the default specified in the /etc/ansible/ansible.cfg file, if there is no such an entry it will use the current username.|
||Specifies the module to be invoked.|
||Specifies the arguments to passed to the module.|
The ansible-doc command can be used to read module documentation. For example, to list available modules:
To print out info about the ping module: