Playbook: An Ansible playbook is a file that contains an ordered set of
tasks that will be run in the order in which they are defined and as
many times as needed. Playbooks are written in YAML, which makes
them easy to read, write, and share. It is common (but not mandatory)
to name the main playbook site.yml.
Inventory file: The inventory file is a list of all the managed nodes.
Also called the hostfile, it contains a list of IP addresses or hostnames
for all the managed nodes as well as credentials and variables that can
be referenced in playbooks. Managed devices can be grouped together
by function or location or based on some other feature. As the hostfile
grows larger in a bigger environment, it is a best practice to move the
variables to dedicated files in group_vars/ and host_vars/ folders.
The group_vars folder would contain files with definitions for variables
related to groups of devices, and the host_vars folder would contain
files with definitions of variables related to individual hosts. Variables
can define anything of interest for the specific environment: TCP/UDP
port numbers, custom proxy configurations, timer values, and so on.
Inventory files are created in either INI or YAML format. INI is a file
format commonly used for configuration files of software platforms. It
was extensively used in older versions of Microsoft Windows to
configure the operating system. INI files are simple text files composed
of basic structures such as sections, properties, and values.
Module: Ansible modules are units of parameterized Python code that
get executed by Ansible. Every module in Ansible has a specific use.
There are modules, for example, for installing server packages, for
managing users, for configuring NTP servers on Cisco NX-OS switches,
and for performing show commands on Cisco IOS devices. An
individual module is invoked through an Ansible task, or multiple
modules can be invoked through an Ansible playbook.
Ansible can be installed in several different ways:
Using the operating system package manager:. For example, on
RedHat and CentOS Linux, it can be installed with the following
command:
sudo yum install ansible
Using the Python package manager: The command for installing
using the Python package manager is pip install ansible. As always,
it is recommended to use a virtual environment when working with
Python. Some dependencies might need to be installed before you can
install Ansible. Always check the latest release notes at
https://docs.ansible.com.
Using the development version: You can clone the developer
repository and issue the source command from a bash terminal.
When automating server configurations, Ansible uses
SSH to log in to the server, copies the Python code, and
runs that code on the server. There is no need to have