Ansible Architecture

Modules

small programs that do some work on the server, so for example instead of running this command

sudo apt-get install htop

we can use apt module and install htop

- name: Install htop

apt: name=htop

Using module give you the ability to know if it’s installed or not.

Plugins

Plugins are pieces of code that augment Ansible’s core functionality. Ansible ships with a number of handy plugins, and you can easily write your own.

Host inventories

To provide a list of hosts, we need to provide an inventory list. This is in the form of a hosts file.

In its simplest form, our hosts file could contain a single line:

35.178.45.231 ansible_ssh_user=ubuntu

Playbooks

Ansible playbooks are a way to send commands to remote computers in a scripted way. Instead of using Ansible commands individually to remotely configure computers from the command line, you can configure entire complex environments by passing a script to one or more systems.

group_vars

file contains set of variables for example db username and password.

roles

Roles are a way to group multiple tasks together into one container to do the automation in very effective manner with clean directory structures

handlers

Handlers are lists of tasks, not really any different from regular tasks, that are referenced by a globally unique name, and are notified by notifiers. If nothing notifies a handler, it will not run. Regardless of how many tasks notify a handler, it will run only once, after all of the tasks complete in a particular play.

Tags

If you have a large playbook it may become useful to be able to run a specific part of the configuration without running the whole playbook.