All Courses

Ansible Automation For Beginners to Advance – Step by Step

Ansible Automation For Beginners to Advance – Step by Step

Mastering Ansible, Ansible AWS, Ansible Tower, Automation, Network


Ansible Automation For Beginners to Advance – Step by Step Course For Free

  • Linux or Mac OS X computer
  • You’ll need a terminal and ssh client for running Ansible against target hosts
  • Open Mind to learn New Technologies


Have You interested in automation used Ansible?

What is Ansible?

Ansible is an open-source IT automation platform. It can remove a huge drudgery from your work life. It also improves the scalability, consistency, and reliability of the IT environment. In this course, we’ll start to explore how to automate all the repetitive system administration tasks using Ansible.

What is in this Ansible course?

The Ansible course introduces a beginner to fundamentals of Ansible that you can easily do hands-on exercises right in the browser. The course provides basic use cases of Ansible followed by the introduction of an Ansible inventory, Configuration Management, patterns,

Playbooks, Modules, Conditionals, Loops and Roles, Ansible With Vagrant.

Let’s have a quick look at what you are going to discuss throughout the whole course!

Ansible Inventory: At the same time Ansible works against multiple systems in your infrastructure. It does this by selecting portions of systems listed in Ansible inventory.

Ansible Configuration Management: Ansible is the simplest solution for configuration management.The descriptive data (both human-readable and machine-parsable) ensuring everyone and able to understand the meaning of each Configuration task.configuration management designed for consistent security and highly reliable with the extremely low learning curve for administrators, developers, and IT managers.

Ansible Playbooks: Playbooks are Ansible’s configuration, deployment, and orchestration language. Many of Ansible’s applications which defined previously to enable more flexibility in playbooks.

What is so special in this Ansible course?

The course is very simple, awesome, easy to understand, agentless, parallel execution, automatic reporting easy to use and at the same time it is a time-saver, In a few months you know the course and become more productive in your own goal. This is the one and the only Ansible course that provisions coding exercise where you can practice Ansible Playbook right in your browser.

How does Ansible work?

Ansible connecting your nodes and pushing out small programs. Ansible works the very simple and different ways of setting up the Architecture, SSH keys and their roles and Managing Inventory.

How does Ansible Playbook work?

Ansible playbook works as an Ansible configuration, deployment, and orchestration language. The playbook can finely orchestrate multiple slices of your infrastructure topology with very detail control over how many machines to tackle at the same time.

How does Ansible Tower work?

Ansible tower works as a scale IT automation, manage complex deployments and speed productivity. The Ansible tower allows us to easily streamline the delivery of applications and services to both OpenStack and Amazon clouds in a cost-effective simple and secure manner.

How does Ansible Vault work?

Ansible Vault is a feature of Ansible that keeps sensitive data such as passwords or keys in encrypted files rather than a plaintext in playbook or role. Ansible Vault encrypts anything inside a YAML file, with a password in your own choice. The vault file can distribute or place in source control.

What are the steps to start Ansible?

At first, Ansible installs your local machine. For Ansible to connect your VPS, you need to specify its IP address within the Ansible host file. Test out your configuration by pinging your VPS for


In a previous guide, we discussed how to install the Ansible software and learn basic commands.

We will assume that you have a configured Ansible server and a few clients, just as we left off in the last tutorial. In our guide, the server is a Ubuntu 12.04 machine, and the clients that we are going to be configuring are also Ubuntu 12.04 machines, for ease of explanation.

What are Ansible 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.

Each playbook contains one or more plays, which map hosts to a certain function. Ansible does this through something called tasks, which are module calls.

Exploring a Basic Playbook

Let’s look at a basic playbook:

— – hosts: droplets   tasks:     – name: Installs Nginx web server       apt: pkg=nginx state=installed update_cache=true       notify:         – start Nginx   handlers:     – name: start Nginx       service: name=nginx state=started

The file starts with:

This is a requirement for YAML to interpret the file as a proper document. YAML allows multiple “documents” to exist in one file, each separated by —, but Ansible only wants one per file, so this should only be present at the top of the file.

YAML is very sensitive to white-space and uses that to group different pieces of information together. Items that have the format of key: value operates as hashes or dictionaries. That’s pretty much all there is to basic YAML.

YAML documents define a hierarchical tree structure with the containing elements further to the left.

Next, we have a set of tasks:

— – hosts: droplets   tasks:     – name: Installs Nginx web server       apt: pkg=nginx state=installed update_cache=true       notify:         – start Nginx

At the top level, we have “tasks:” at the same level as “hosts:”. This contains a list (because it starts with a “-“) which contains key-value pairs.

The first one, “name”, is more of a description than a name. You can call this whatever you would like.

The next key is “apt”. This is a reference to an Ansible module, just like when we use the ansible command and type something like:

ansible -m apt -a ‘whatever’ all

This is not an internal Ansible command, it is a reference to a handler, which can perform certain functions when it is called from within a task. We will define the “start Nginx” handler below.

— – hosts: droplets   tasks:     – name: Installs Nginx web server       apt: pkg=nginx state=installed update_cache=true       notify:         – start Nginx   handlers:     – name: start Nginx       service: name=nginx state=started

The “handlers” section exists at the same level as the “hosts” and “tasks”.

We can save this playbook into a file called something like “nginx.yml”.

As you can see, YAML is much more compact and most people would say more readable.

Running an Ansible Playbook

Once you have a playbook built, you can call it easily using this format:

ansible-playbook playbook.yml

For instance, if we wanted to install and start-up Nginx on all of our droplets, we could issue this command:

ansible-playbook nginx.yml

Since the playbook itself specifies the hosts that it should run against (namely, the “droplets” group we created in the last tutorial), we do not have to specify a host to run against.

However, if we would like to filter the host list to only apply to one of those hosts, we can add a flag to specify a subset of the hosts in the file:

ansible-playbook -l host_subset playbook.yml

So if we only wanted to install and run Nginx on our “host3”, we could type this:

ansible-playbook -l host3 nginx.yml

Adding Features to the Ansible Playbook

Right now our playbook looks like this:

— – hosts: droplets   tasks:     – name: Installs Nginx web server       apt: pkg=nginx state=installed update_cache=true       notify:         – start Nginx   handlers:     – name: start Nginx       service: name=nginx state=started

It is simple and it works, but all it is doing is installing a piece of software and starting it. That’s not very beneficial by itself.

We can start to expand the functionality by adding tasks to our playbook.

Add a Default Index File

We can tell it to transfer a file from our Ansible server onto the host by adding some lines like this:

— – hosts: droplets   tasks:     – name: Installs nginx web server       apt: pkg=nginx state=installed update_cache=true       notify:         – start nginx     – name: Upload default index.html for host       copy: src=static_files/index.html dest=/usr/share/nginx/www/ mode=0644   handlers:     – name: start nginx       service: name=nginx state=started

We can then make a directory called static_files in our current directory and place an index.html file inside.

mkdir static_files nano static_files/index.html

Inside of this file, let’s just create a basic html structure:

<html>   <head>     <title>This is a sample page</title>   </head>   <body>     <h1>Here is a heading!</h1>     <p>Here is a regular paragraph.  Wow!</p>   </body> </html>

Save and close the file.

Now, when we re-run the Ansible playbook, Ansible will check each task. It will see the new task section and replace the default index.html file with the one from our server.

Registering Results

For instance, we could tell our Ansible playbook to upload an index.php file if it exists. If that task fails, we could instead try to upload an index.html file.

This new version tries to upload a PHP index file to the host. It registers the success of the operation into a variable called “PHP”.


Now, you should have a good handle on how to automate complex tasks using Ansible. This is a basic example of how you can begin to build your configuration library in Ansible.

Who this course is for:

Ansible Automation For Beginners to Advance – Step by Step