We will start this module discussing the inventory and how it can be extended
to include specific information about hosts and groups,
along with variables.
Variables can be defined in inventory, separate files, and directories.
The method you choose really depends on the scalability you were looking for.
We will then go into variables in general and how and where they can be defined.
The inventory is just one place.
We will then discuss conditional task execution with the
when clause and the use of handlers.
Finally, we will have a look about how Ansible deals with failures.
There will also be three demos in this module.
The default way to describe your hosts in Ansible is to list them in text files.
From module two, we know this to be inventory host files.
The simplest form is just a list of hostnames in a file named hosts.
This will then allow users to interact with multiple hosts.
When you manage hosts, need to be managed in Ansible.
The inventory file needs to be updated manually,
unlike a dynamic inventory that takes advantage of
scripting to populate the inventory content.
So the Ansible inventory is a flexible object.
So it could be a file in several formats.
It can be a directory or executable, or some executables are bundled as plugins.
Inventory plugins allow you to point at data sources other than the local file,
such as your cloud provider,
and the cloud provider will then be used to compile the
inventory instead of using a local file.
In these use cases, an inventory can be stored separately from your playbooks,
and Ansible has several executables that can connect to various
cloud systems provided you install the necessary requirements and
set up the correct authentication.
So dynamic inventories are used to keep inventories
in different software systems.
If the inventory is executable, it is a dynamic inventory.
So we can use a dynamic inventory, which is an executable inventory.
That provides dynamic output according to the contents of the script.
This is useful when you want the system external to Ansible.
That keeps track of your hosts instead of editing a local file all the time.
Let's say you're using AWS EC2,
and maintaining an inventory file might not be the best
approach because hosts may come and go over time,
and they may be managed by external applications or
even be affected by AWS Auto Scaling.
For this reason, you can use an EC2 external inventory script.
So if your hosts run on Amazon EC2,
then EC2 tracks information about your host for you.
So the Ansible inventory is a very flexible object,
and you can use multiple inventory sources simultaneously.
So when doing so,
it is possible to mix dynamic and statically managed
inventory sources in the same Ansible run.
Many are referring this to as an instant hybrid cloud.