System Configuration with Ansible

System Configuration

DevShop is now installed using Ansible roles. This means that most system-level configuration is now managed with Ansible variables. & Ansible

When you run, it collects information about your system and passes that to the ansible-playbook command. The script is idempotent, meaning you can run it many times and get the same result.

These variables are things like system_hostname, mysql_root_password, or php_memory_limit.

When runs, it creates a simple Ansible inventory file in the same folder that resides. This file contains a single entry using just the hostname by default.

If the file already exists, the script will tell ansible-playbook to use that file.

This inventory file is the key to customizing the configuration of your server.

Default Ansible inventory vs DevShop inventory

DevShop's script uses a separate inventory file than the default Ansible inventory (at /etc/ansible/hosts). This is to remain unobtrusive to the system. In the future, we will likely start using the default inventory system.

Create a file called inventory in the same directory as You can place custom variables in there in the form of an "Ansible Inventory".

Ansible Inventory Format

For your devshop server's inventory file you do not need to worry about groups. By default, it just includes the hostname.

If you want to add variables you can do so with this format: php_memory_limit=256M

Explanation of the hostname vs server_hostname:

The first hostname mentioned in the file above, "", is what ansible will use to find the server, using a DNS lookup.

The second, is the variable that Ansible will use to try and set the system hostname of this machine.

Ansible Variables & Templates

This list of available Ansible variables depends on the roles being used. DevShop uses Jeff Geerling's roles which are very well written, so there are many variables to use.

The easiest way to review all of the roles, variables, and templates that DevShop uses in one place is to use the ansible-galaxy command and DevShop's requirements.yml file:

Get that file and run ansible-galaxy install:

   ansible-galaxy install -r requirements.yml

In each Ansible Role repository, look for the defaults/main.yml file. In this file are all the available variable names you can use, along with their default values.

Also look for the templates folder. Most configuration files on the system come from these templates.

For example, php_memory_limit is in the defaults/main.yml file located at and is written to the templates/php.ini.j2 file at

Configuring your System

You can edit your inventory file, then run again to reconfigure your system. The Ansible playbooks are smart enough to restart services if a configuration file changes.

More Ansible with Aegir

We have developed a module that allows Aegir to become your Ansible Inventory. It is possible to setup your DevMaster front-end to manage the server's inventory and variables.

Enable Aegir Ansible Inventory & Variables module, and read up on the documentation.

Last updated