Contact us
Account Log in
Jump to section

What is an Ansible Playbook?

Copy URL

An Ansible® Playbook is a blueprint of automation tasks—which are complex IT actions executed with limited or no human involvement. Ansible Playbooks are executed on a set, group, or classification of hosts, which together make up an Ansible inventory.

Ansible Playbooks are essentially frameworks, which are prewritten code developers can use ad-hoc or as starting template. Ansible Playbooks are regularly used to automate IT infrastructure (such as operating systems and Kubernetes platforms), networks, security systems, and developer personas (such as Git).

Ansible Playbooks help IT staff program applications, services, server nodes, or other devices without the manual overhead of creating everything from scratch. And Ansible Playbooks—as well as the conditions, variables, and tasks within them—can be saved, shared, or reused indefinitely.

Ansible modules execute tasks. One or more Ansible tasks can be combined to make a play. Two or more plays can be combined to create an Ansible Playbook. Ansible Playbooks are lists of tasks that automatically execute against hosts. Groups of hosts form your Ansible inventory.

Each module within an Ansible Playbook performs a specific task. Each module contains metadata that determines when and where a task is executed, as well as which user executes it. There are thousands of other Ansible modules that perform all kinds of IT tasks, such as:

Cloud management

oci_vcn creates, deletes, or updates virtual cloud networks in Oracle Cloud Infrastructure environments. Similarly, vmware_cluster adds, removes, or updates VMware vSphere clusters.

User management

selogin maps Linux® operating system (OS) users to SELinux user, and gitlab_user creates, updates, or deletes GitLab users.


Dozens of modules handle application programming interfaces (APIs); Cisco IOS, NXOS, and IOS XR devices; as well as F5 BIG-IP services.


Openssh_cert generates an OpenSSH host or user certificates, and ipa_config manages global FreeIPA configuration settings.

Configuration management

pip manages Python library dependencies while assemble consolidates configuration files from fragments.


mail can automatically send emails based on certain criteria, and snow_record creates, deletes, or updates a single record in ServiceNow.

Watch sessions from AnsibleFest 2022

AnsibleFest 2022 may be over, but you can keep building your automation knowledge. Explore our on-demand content hub, with more than 50 AnsibleFest sessions on automation use cases, processes, and more. Sign up for free to view all content until April 2023.

Ansible is capable of communicating with many different device classifications, from cloud-based REST APIs, to Linux and Windows systems, networking hardware, and much more. This is a sample of 2 Ansible modules automatically updating 2 types of servers:

--- name: update web servers
  hosts: webservers
  remote_user: root

  - name: ensure apache is at the latest version
      name: httpd
      state: latest
  - name: write the apache config file
      src: /srv/httpd.j2
      dest: /etc/httpd.conf

- name: update db servers
  hosts: databases
  remote_user: root

  - name: ensure postgresql is at the latest version
      name: postgresql
      state: latest
  - name: ensure that postgresql is started
      name: postgresql
      state: started

The playbook contains 2 plays: 

  • The first checks whether or not web server software is up to date and runs the update if necessary
  • The second checks whether or not database server software is up to date and runs the update if necessary

Ansible uses the YAML syntax. Depending on whom you ask, YAML stands for yet another markup language or YAML ain’t markup language (a recursive acronym). There are also 2 different, but perfectly acceptable, YAML file extensions: .yaml or .yml.

There are 2 ways of using Ansible Playbooks: From the command line interface (CLI) or using the Red Hat Ansible Automation Platform’s push-button deployments.

From the CLI

After installing the open source Ansible project or Red Hat Ansible Automation Platform (which is as straightforward as typing sudo yum install ansible in the Red Hat Enterprise Linux CLI), all you need to do is use the ansible-playbook command to run Ansible Playbooks.

From within the platform

The Red Hat Ansible Automation Platform web-based user interface includes push-button Ansible Playbook deployments that are used as part of larger jobs (or job templates). These deployments come with additional safeguards that are particularly helpful to users who are newer to IT automation—or those without as much experience working in the CLI.

There’s a lot more to do with automation.

Red Hat® Ansible Automation Platform uses human-readable YAML language so users can  share, vet, and manage automation content. It includes all the tools needed to implement enterprise-wide automation, including playbooks and analytics. And it allows your teams to centralize and control your IT infrastructure with a visual dashboard, role-based access control, and more to reduce operational complexity.

With a Red Hat subscription, you get certified content from our robust partner ecosystem, access to hosted management services, and life cycle technical support to scale automation across your organization. And you’ll get expert knowledge gained from our success with thousands of customers.


Keep reading


Learning Ansible basics

Ansible automates IT processes like provisioning and configuration management. Learn the basics of Ansible with this introduction to key concepts.


What is business process management?

Business process management (BPM) is the practice of modeling, analyzing, and optimizing end-to-end business processes to meet your strategic business goals.


Why choose Red Hat for automation?

Red Hat Ansible Automation Platform includes all the tools needed to share automation across teams and implement enterprise-wide automation.

More about automation


Engagements with our strategic advisers who take a big-picture view of your organization, analyze your challenges, and help you overcome them with comprehensive, cost-effective solutions.

A platform for implementing enterprise-wide automation, no matter where you are in your automation journey

A platform for developing cloud-native applications that automate business decisions and processes.



Free training course

Ansible Essentials: Simplicity in Automation Technical Overview

Free training course

Red Hat Ansible Automation for SAP