Ansible basics

Ansible technical terms – Cheat sheet

Ansible has lot of technical terms with service , function, modules etc . Below are the major technical terms used widely .

Control Node:

Any machine that has ansible and python installed can act ass Control node . You can run commands and playbooks, invoking /usr/bin/ansible or /usr/bin/ansible-playbook, from any control node .Windows server can not be run as control node.

Managed Node:

The network devices, servers you manage with Ansible. Managed nodes are also sometimes called “hosts”. Ansible is not installed on managed nodes.


A list of managed nodes. An inventory file is also sometimes called a “hostfile”. Your inventory can specify information like IP address for each managed node. An inventory can also organize managed nodes, creating and nesting groups for easier scaling .


Unit of codes that ansible executes. Each module has a particular use . Ex to install httpd package on centos you can use yum module . To manage the file content you can use file module.


A playbooks is a file that defines the desired state of your system . Playbook contains plays.Playbooks can include variables as well as tasks. Playbooks are written in YAML and are easy to read, write, share and understand.


A play contain different tasks . There can be one or many play in the playbook. A play is minimally a mapping between a set of hosts and the tasks which run on those hosts .


A command that Ansible runs via its modules, like a task for installing a package via apt-get or yum.


Roles provide a framework for fully independent collections of variables, tasks, files, templates, and modules . It provides all the required directory , and files in a structured way. Role breaking a playbook into multiple files it simplifies writing complex playbooks.

Roles are not playbooks. Roles are small functionality which can be independently used but have to be used within playbooks. There is no way to directly execute a role .


Handlers are just like regular tasks in an ansible playbook . It will run only if task contains “notify” directive  . For example apche config file managed by “file.managed” task it can trigger other apache service restart task.


Facts are simply things that are discovered about remote nodes . Ansible facts are a way of getting data about remote systems for use in playbook variables. Usually these are discovered automatically by the setup module in Ansible. Users can also write custom facts modules . Example knowing about OS kernel version is fact information.

Group Vars:

Assigning a variable to many machines. Keep the variables for group of nodes in group_vars/ directory . This is a convenient place to put variables that are provided to a given group, especially complex data structures, so that these variables do not have to be embedded in the inventory file or playbook.

In INI way





Host Vars:

Assigning variable to one or specific machine . host_vars/ hold the informaiton.

    http_port: 80
    maxRequestsPerChild: 808
    http_port: 303
    maxRequestsPerChild: 909


Ansible allows tagging resources in a playbook with arbitrary keywords, and then running only the parts of the playbook that correspond to those keywords


Ansible can easily transfer files to remote systems but often it is desirable to substitute variables in other files. Variables may come from the inventory file, Host Vars, Group Vars, or Facts. Templates use the Jinja2 template engine and can also include logical constructs like loops and if statements.


An optional conditional statement attached to a task that is used to determine if the task should run or not. If the expression following the when: keyword evaluates to false, the task will be ignored.


Leave a Reply