HomeAutomation Tools

Ansible : Getting Started with Ansible Playbook

Ansible : Getting Started with Ansible Playbook
Like Tweet Pin it Share Share Email
Personal Development Category (English)728x90

Ansible playbooks are a way to send commands to remote computers in a scripted way. At a basic level, Ansible Playbook can be used to manage configurations of and deployments to remote machines. At a more advanced level, they can sequence multi-tier rollouts involving rolling updates and can delegate actions to other hosts, interacting with monitoring servers and load balancers along the way.

Playbooks are designed to be human-readable and are developed in a basic text language, are written in the YAML data serialization format.

Ansible Playbook

Suggestable Read:

1. Introduction and Installation & Configuration of Ansible 2.3 on CentOS/Redhat Linux 7

2. Configuring Ansible Dynamic Inventory for AWS EC2

3. Creating an Ansible static inventory with variables

4. Part #1: Getting Started with Ansible Ad-Hoc Commands

5. Part #2: Getting Started with Ansible Ad-Hoc Commands

Click here to get started with YAML Syntax: http://www.yaml.org/start.html

Let’s start understanding the Ansible Playbook format.

YAML format: YAML language always starts with 3 (– – –) hyphens. It is an identification for YAML format and that indicates the yaml program starts from there.

Now let’s start writing a basic Ansible Playbook. Here I have a directory called “playbooks” to maintain all the playbooks at one place.

The below playbook will create a group called “demogrp”, then the next task will create multiple users with the below-specified requirements.

Playbook name: For YAML program, you have to always maintain like this “your-playbook-name.yaml” or “your-playbook-name.yml“.  check my sample playbook name here – basic_playbook.yaml

Screenshot:  If you’re using Notepad ++, then it easy to write YAML syntax.

Ansible Playbook


Before running a playbook on target servers, you should verify the playbook syntax and try to execute the “dry-run”

The below command will check the syntax-check.


The below command will do run in Check mode “Dry run” without executing on remote servers.

Ansible Playbook


As a beginner, you will see a lot of syntax error when you writing a playbook. So you can always verify the syntax check using http://www.yamllint.com/.

Ansible Playbook

Let’s run your first ansible Playbook using “ansible-playbook” command.

Succesful execution: 

Ansible Playbook


Conclusion:  That’s all about executing your first Ansible Playbooks. I will come up with more useful and interesting articles related to Ansible. Leave a comment on below if it helps you to get the knowledge on playing with Ansible.

Follow our Youtube Channel for more about Ansible Tutorials :

Check out the below Video for More about Ansible Playbook.

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.