* [Topics](/en/topics "Topics")
* [Automation and management](/en/topics/automation "Automation and management")
* What is an Ansible Playbook?
What is an Ansible Playbook?
============================
Updated  February 10, 2026•*5*-minute read
Copy URL
Jump to section
---------------
OverviewHow does it work?Video overviewExample of Ansible PlaybookHow to use Ansible PlaybooksWhy Red Hat?
Overview
--------
An Ansible® Playbook is a blueprint of automation tasks, which are IT actions executed with limited manual effort across an inventory of IT solutions. Playbooks tell Ansible *what* to do to *which* *devices*.
Instead of manually applying the same action to hundreds or thousands of similar technologies across IT environments, executing a playbook automatically completes the same action for the specified type of inventory—such as a set of routers. Playbooks also serve as frameworks of prewritten code that developers can use ad-hoc or as a starting template.  
Playbooks are regularly used to automate [IT infrastructure](/en/topics/cloud-computing/what-is-it-infrastructure)—such as operating systems and [Kubernetes](/en/topics/containers/what-is-kubernetes) platforms—networks, security systems, and code repositories like GitHub. IT staff can use playbooks to program applications, services, server nodes, and other devices, without the manual overhead of creating everything from scratch.
And playbooks—as well as the conditions, variables, and tasks within them—can be saved, shared, or reused indefinitely. This makes it easier for IT teams to codify operational knowledge and ensure that the same actions are performed consistently.
[Write your first playbook with this free interactive lab](/en/interactive-labs/ansible "interactive lab | write your first Ansible Playbook")
How do Ansible Playbooks work?
------------------------------
Ansible Playbooks are lists of tasks that automatically execute for your specified inventory or groups of hosts. One or more Ansible tasks can be combined to make a *play*—an ordered grouping of tasks mapped to specific hosts—and tasks are executed in the order in which they are written. A playbook can include 1 or more plays as well as [Ansible Roles](/en/topics/automation/what-is-an-ansible-role)—bundles of tasks and associated automation assets that can be run in multiple plays or reused across playbooks.
Tasks are executed by *modules*, each of which performs a specific task in a playbook. A [module](/en/topics/automation/what-is-an-ansible-module) contains metadata that determines when and where a task is executed, as well as which user executes it. There are thousands of Ansible modules that perform all kinds of IT tasks, such as:
### Cloud management
[oci\_vcn](https://docs.ansible.com/ansible/2.8/modules/oci_vcn_module.html#oci-vcn-module) creates, deletes, or updates [virtual](/en/topics/virtualization) [cloud](/en/topics/cloud-computing) networks in Oracle Cloud Infrastructure environments. Similarly, [vmware\_cluster](https://docs.ansible.com/ansible/2.8/modules/vmware_cluster_module.html#vmware-cluster-module) adds, removes, or updates VMware vSphere clusters.
### User management
[selogin](https://docs.ansible.com/ansible/2.8/modules/selogin_module.html#selogin-module) maps [Linux®](/en/topics/linux) operating system (OS) users to [SELinux](/en/topics/linux/what-is-selinux) user, and [gitlab\_user](https://docs.ansible.com/ansible/2.9/modules/gitlab_user_module.html#gitlab-user-module) creates, updates, or deletes GitLab users.
### Networking
Dozens of modules handle application programming interfaces (APIs); Cisco [IOS](https://docs.ansible.com/ansible/2.8/modules/ios_command_module.html#ios-command-module), [NXOS](https://docs.ansible.com/ansible/2.8/modules/nxos_command_module.html#nxos-command-module), and [IOS XR](https://docs.ansible.com/ansible/2.8/modules/iosxr_command_module.html#iosxr-command-module) devices; as well as [F5 BIG-IP](https://docs.ansible.com/ansible/2.8/modules/bigip_command_module.html#bigip-command-module) services and the Arista EOS cloud network operating system.
[See a full list of network modules](https://docs.ansible.com/ansible/2.9/modules/list_of_network_modules.html)
### Security
[Openssh\_cert](https://docs.ansible.com/ansible/2.8/modules/openssh_cert_module.html#openssh-cert-module) generates an OpenSSH host or user certificates, and [ipa\_config](https://docs.ansible.com/ansible/2.8/modules/ipa_config_module.html#ipa-config-module) manages global FreeIPA configuration settings.
### Configuration management
[pip](https://docs.ansible.com/ansible/2.9/modules/pip_module.html#pip-module) manages Python library dependencies while [assemble](https://docs.ansible.com/ansible/2.9/modules/assemble_module.html#assemble-module) consolidates configuration files from fragments.
### Communication
[mail](https://docs.ansible.com/ansible/2.8/modules/mail_module.html#mail-module) can automatically send emails based on certain criteria, and [snow\_record](https://docs.ansible.com/ansible/2.8/modules/snow_record_module.html#snow-record-module) creates, deletes, or updates a single record in ServiceNow.
[Learn the playbook basics with this free learning path](https://developers.redhat.com/learn/ansible/get-started-ansible-playbooks "Developers.redhat.com | Learning path: Get started with Ansible Playbooks")
Recommended for you
Securing and automating the full infrastructure lifecycle
---------------------------------------------------------
[Watch the webinar](https://www.redhat.com/en/events/webinar/securing-and-automating-the-full-infrastructure-lifecycle?percmp=RHCTG0250000455235)
Hear from an expert
-------------------
This video can't play due to privacy settings
To change your settings, select the "Cookie Preferences" link in the footer and opt in to "Advertising Cookies or try disabling adblockers."
A practical example of an Ansible Playbook
------------------------------------------
Ansible is capable of communicating with many different device classifications, from cloud-based [REST APIs](/en/topics/api/what-is-a-rest-api), 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
  become: true
  tasks:
    - name: Ensure apache is at the latest version
      ansible.builtin.yum:
        name: httpd
        state: latest
    - name: Write the apache config file
      ansible.builtin.template:
        src: /srv/httpd.j2
        dest: /etc/httpd.conf
        mode: "0644"
- name: Update db servers
  hosts: databases
  become: true
  tasks:
    - name: Ensure postgresql is at the latest version
      ansible.builtin.yum:
        name: postgresql
        state: latest
    - name: Ensure that postgresql is started
      ansible.builtin.service:
        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.
[Get more details on this playbook](https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html "ansible.com")
How do I use Ansible Playbooks?
-------------------------------
Ansible uses the [YAML syntax](/en/topics/automation/what-is-yaml). 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](/en/technologies/management/ansible) push-button deployments.
Because YAML is a human-readable language, IT professionals with specific domain expertise—like in network, security, or cloud—can create playbooks without having to learn a complicated coding language.
### 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](https://docs.ansible.com/ansible/latest/cli/ansible-playbook.html) 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](https://www.ansible.com/blog/now-available-red-hat-ansible-automation-platform-1.2) 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.
[A quick guide to running your own playbook](https://docs.ansible.com/ansible/latest/user_guide/intro_getting_started.html "ansible.com")
Why Red Hat?
------------
[Red Hat Ansible Automation Platform](/en/technologies/management/ansible) is a unified platform that can automate full processes across your IT domains for a variety of use cases—including infrastructure, hybrid cloud, security, and networks, all the way to edge locations. Ansible Automation Platform includes all the tools needed to implement enterprise-wide automation, including an [event-driven solution](/en/technologies/management/ansible/event-driven-ansible), playbooks, and analytics. And it allows your teams to centralize and control your IT infrastructure with a visual dashboard, role-based access control, and other features that will help reduce operational complexity.  
With a Red Hat subscription, you get [certified, supported content](/en/technologies/management/ansible/content-collections) from Red Hat and our partners, 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.
The introduction of [Red Hat Ansible Lightspeed with IBM watsonx Code Assistant](/en/technologies/management/ansible/ansible-lightspeed) makes Ansible even more accessible to beginners and helps experienced automation teams learn, create, and maintain Ansible Automation Platform content more efficiently. This generative AI service accepts prompts entered by a user and then interacts with [IBM watsonx foundation models](https://www.ibm.com/watsonx) to produce code recommendations built on Ansible best practices—helping you convert subject matter expertise into trusted, reliable Ansible code that scales across teams and domains.
[Learn more about Ansible Automation Platform](/en/technologies/management/ansible)
> The built-in capabilities of Red Hat Ansible Automation Platform provide an accelerator in a box. It’s the de facto standard that many of our vendors and partners also use to write scripts to install, configure, and maintain their technology.
>
> Jesse Amerson
>
> IT director, Ulta Beauty
[Get the full story](/en/success-stories/ulta-beauty "success story | ulta beauty standardizes on red hat for automation transformation")
Recommended for you
E-book
Automate your hybrid cloud at scale
-----------------------------------
Read this e-book to learn about the benefits of automation in hybrid cloud environments.
[Read the e-book](https://www.redhat.com/en/resources/automate-your-hybrid-cloud-ebook?percmp=RHCTG0250000455234)
All Red Hat product trials
--------------------------
Our no-cost product trials help you gain hands-on experience, prepare for a certification, or assess if a product is right for your organization.
[Keep reading](/en/products/trials "All Red Hat product trials")
Keep reading
------------
### 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.
[Read the article](/en/topics/automation/why-choose-red-hat-for-automation "article | Why choose Red Hat for automation")
### Learning Ansible basics
Ansible automates IT processes like provisioning and configuration management. Learn the basics of Ansible with this introduction to key concepts.
[Read the article](/en/topics/automation/learning-ansible-tutorial "article | Learning Ansible basics")
### How to build an IT automation strategy
Isolated automation can only take you so far. To expand automation to all areas of your IT operations, you need an automation strategy that unifies teams, processes, and disconnected workflows.
[Read the article](/en/topics/automation/build-an-automation-strategy "article | How to build an IT automation strategy")
Automation and management resources
-----------------------------------
### Featured product
* #### [Red Hat Ansible Automation Platform](/en/technologies/management/ansible)
  A platform for implementing enterprise-wide automation, no matter where you are in your automation journey.
[See all products](/en/technologies/all-products "See all products")
### Related content
* Blog post
  [AI insights with actionable automation accelerate the journey to autonomous networks](/en/blog/ai-insights-with-actionable-automation-accelerate-the-journey-to-autonomous-networks)
* E-book
  [Automate security to align enterprise IT](/en/resources/automate-security-align-enterprise-ebook)
* E-book
  [Automate security to align enterprise IT](/en/engage/automate-security-align-enterprise-ebook)
* Case study
  [Turkcell, Red Hat ile Esnek Telko Bulut İnşa Ediyor](/en/resources/turkcell-emea-case-study-tr)
### Related articles
* [Why choose Red Hat for automation?](/en/topics/automation/why-choose-red-hat-for-automation)
* [What is SOAR?](/en/topics/security/what-is-soar)
* [Learning Ansible basics](/en/topics/automation/learning-ansible-tutorial)
* [How to build an IT automation strategy](/en/topics/automation/build-an-automation-strategy)
* [Ansible vs. Chef: What you need to know](/en/topics/automation/ansible-vs-chef)
* [Ansible vs. Puppet: What you need to know](/en/topics/automation/ansible-vs-puppet)
* [Ansible vs. Salt: What you need to know](/en/topics/automation/ansible-vs-salt)
* [Ansible vs. Terraform](/en/topics/automation/ansible-vs-terraform)
* [What is IT service management (ITSM)?](/en/topics/automation/what-is-it-service-management-itsm)
* [Automating Microsoft Windows with Red Hat Ansible Automation Platform](/en/technologies/management/ansible/automate-microsoft-windows-with-ansible)
* [What is DevOps automation?](/en/topics/automation/what-is-devops-automation)
* [What is Infrastructure as Code (IaC)?](/en/topics/automation/what-is-infrastructure-as-code-iac)
* [Ansible vs. Kubernetes: how they work together](/en/topics/automation/Ansible-vs-Kubernetes)
* [What is a configuration management database (CMDB)?](/en/topics/automation/what-is-a-configuration-management-database-cmdb)
* [What is cloud migration? And how can automation help?](/en/topics/automation/what-is-cloud-migration)
* [What is a software-defined data center (SDDC)?](/en/topics/automation/what-is-a-sddc)
* [What is IT automation?](/en/topics/automation/what-is-it-automation)
* [Why choose Red Hat Ansible Automation Platform as your AI foundation?](/en/topics/automation/automation-and-ai)
* [What is access control?](/en/topics/security/what-is-access-control)
* [What is virtual infrastructure management? And how can automation help?](/en/topics/automation/virtual-infrastructure-management)
* [What is IT migration?](/en/topics/automation/what-is-it-migration)
* [How to automate migrations with Red Hat Ansible Automation Platform](/en/technologies/management/ansible/automate-migrations-with-red-hat-ansible-automation-platform)
* [Why use Red Hat Ansible Automation Platform with Red Hat OpenShift?](/en/technologies/cloud-computing/openshift/ansible-on-openshift)
* [What is CloudOps?](/en/topics/automation/what-is-cloudops)
* [Red Hat Satellite on Red Hat Enterprise Linux](/en/technologies/management/satellite/satellite-for-rhel)
* [What is role-based access control (RBAC)?](/en/topics/security/what-is-role-based-access-control)
* [Which Red Hat Ansible Automation Platform deployment option is right for you?](/en/technologies/management/ansible/ansible-deployment-options)
* [What is an Ansible module—and how does it work?](/en/topics/automation/what-is-an-ansible-module)
* [How to manage and automate applications at the edge](/en/topics/edge-computing/how-to-manage-automate-applications-edge)
* [How to build an automation Center of Excellence](/en/topics/automation/how-to-build-automation-center-of-excellence)
* [What is orchestration?](/en/topics/automation/what-is-orchestration)
* [How to adopt Automation as Code: Extending Infrastructure as Code into Policy as Code](/en/topics/automation/how-to-adopt-automation-as-code)
* [What is a webhook?](/en/topics/automation/what-is-a-webhook)
* [Red Hat Lightspeed data and application security](/en/topics/management/data-application-security)
* [What is an Ansible Role—and how is it used?](/en/topics/automation/what-is-an-ansible-role)
* [What is data management?](/en/topics/data-services/what-is-data-management)
* [Gain security with Red Hat Ansible Automation Platform](/en/technologies/management/ansible/gain-security-with-red-hat-ansible-automation-platform)
* [What is NetOps?](/en/topics/automation/what-is-netops)
* [What is an Ansible Rulebook?](/en/topics/automation/what-is-an-ansible-rulebook)
* [What is configuration management](/en/topics/automation/what-is-configuration-management)
* [What is event-driven automation?](/en/topics/automation/what-is-event-driven-automation)
* [Zero-Touch Provisioning and telco automation with Red Hat](/en/topics/telecommunications/zero-touch-provisioning-and-telco-automation-at-red-hat)
* [What is infrastructure automation?](/en/topics/automation/what-is-infrastructure-automation)
* [What is YAML?](/en/topics/automation/what-is-yaml)
* [What is provisioning?](/en/topics/automation/what-is-provisioning)
* [What is compliance management?](/en/topics/management/what-is-compliance-management)
* [Understanding Ansible, Terraform, Puppet, Chef, and Salt](/en/topics/automation/understanding-ansible-vs-terraform-puppet-chef-and-salt)
* [What is cloud orchestration?](/en/topics/automation/what-is-cloud-orchestration)
* [What is security automation?](/en/topics/automation/what-is-security-automation)
* [What is a configuration file?](/en/topics/linux/what-configuration-file)
* [Ansible vs. Red Hat Ansible Automation Platform](/en/technologies/management/ansible/ansible-vs-red-hat-ansible-automation-platform)
* [What is cloud automation?](/en/topics/automation/what-is-cloud-automation)
* [What is network automation?](/en/topics/automation/what-is-network-automation)
* [What are managed IT services?](/en/topics/cloud-computing/what-are-managed-it-services)
* [What is business process management?](/en/topics/automation/what-is-business-process-management)
* [What is patch management (and automation)?](/en/topics/management/what-patch-management-and-automation)
* [What is the Red Hat Ansible Automation Platform automation controller?](/en/technologies/management/ansible/automation-controller-product-feature)
* [What is business process automation?](/en/topics/automation/what-is-business-process-automation)
* [What is IT process automation?](/en/topics/automation/what-is-it-process-automation)
* [What is deployment automation?](/en/topics/automation/what-is-deployment-automation)
* [What is business optimization?](/en/topics/automation/business-optimization)
* [What is Kubernetes cluster management?](/en/topics/containers/what-is-kubernetes-cluster-management)
* [What is SRE?](/en/topics/devops/what-is-sre)
* [What is risk management?](/en/topics/management/what-is-risk-management)
* [What is an SOE?](/en/topics/management/what-is-an-soe)
* [What is IT system life-cycle management?](/en/topics/management/it-system-life-cycle-management)
* [What is network management?](/en/topics/management/what-is-network-management)
* [What is robotic process automation (RPA?)](/en/topics/automation/what-is-robotic-process-automation)
* [What is cloud management?](/en/topics/cloud-computing/what-is-cloud-management)
* [What's business automation?](/en/topics/automation/whats-business-automation)
[More about this topic](/en/topics/automation "More about this topic")