• Home
  • Recent Q&A
  • Java
  • Cloud
  • JavaScript
  • Python
  • SQL
  • PHP
  • HTML
  • C++
  • Data Science
  • DBMS
  • Devops
  • Hadoop
  • Machine Learning
in Ansible by
Q:
Difference between play and playbook.

1 Answer

0 votes
by
An Ansible play is a set of tasks that are run on one or more managed hosts. A play may include one or more tasks, and the most common way to execute play is to use a playbook. An Ansible playbook is composed of one or more plays and offer more advanced functionality for sending tasks to managed host compared to running many ad-hoc commands.  

               

Example of play is:

                       - hosts: webservers

                         tasks:

                           - name: ensure apache is at the latest version

                              yum:

                                   name: httpd

                                   state: latest

 Example of playbook with 2 plays is:

                        ---

                        - hosts: webservers

                          tasks:

                             - name: ensure apache is at the latest version

                                   yum:

                                       name: httpd

                                       state: latest

                        - hosts: databases

                          tasks:

                             - name: ensure postgresql is at the latest version

                                   yum:

                                       name: postgresql

                                       state: latest

Related questions

0 votes
asked Aug 24, 2019 in Ansible by rahulsharma
0 votes
asked Aug 24, 2019 in Ansible by rahulsharma
...