cancel
Showing results for 
Search instead for 
Did you mean: 
dennishart
Mission Specialist
Mission Specialist
  • 3,668 Views

plays vs playbooks I'm a little confused on what is consider what

Jump to solution

Could anyone explain the difference?

Labels (1)
0 Kudos
1 Solution

Accepted Solutions
andkra
Flight Engineer Flight Engineer
Flight Engineer
  • 3,660 Views

Hello,

the term playbook stands for the yaml file itself.

One playbook (file) have one or more plays. Identified by name: and/or hosts:

Greetings
Andreas

View solution in original post

5 Replies
andkra
Flight Engineer Flight Engineer
Flight Engineer
  • 3,661 Views

Hello,

the term playbook stands for the yaml file itself.

One playbook (file) have one or more plays. Identified by name: and/or hosts:

Greetings
Andreas

dennishart
Mission Specialist
Mission Specialist
  • 3,657 Views

Thank you for the quick response! cleared everything up.

0 Kudos
Razique
Flight Engineer Flight Engineer
Flight Engineer
  • 3,647 Views

Consider the following example:

# This is the run-me.yml playbook

- name: This is the first play
  hosts: hostsA
  tasks:
    - name: Hello world
      debug:
        msg: 'Hello World'

- name: This is the second play
  hosts: hostsB
  tasks:
    - name: Bye bye word
      debug:
        msg: 'Bye bye world!'
littlebigfab
Starfighter Starfighter
Starfighter
  • 3,633 Views

Hi @dennishart,

My mnemonic is that a playbook is a list of plays.

Once you get that, you realize why a playbook yaml file always has to start by a hyphen, introducing the first item of that list.

Most playbooks only have one play, which probably fuels your confusion. Yet, they are still a list (of 1 item) and they still require that initial hyphen though.

The reason why you would need several plays in one playbook is when you have to execute different tasks or roles to different sets of target systems. Indeed the key directive of a play is  the hosts directive which sets the target systems for that play.

Razique
Flight Engineer Flight Engineer
Flight Engineer
  • 3,610 Views

Good point about the hosts directive @littlebigfab 

0 Kudos
Join the discussion
You must log in to join this conversation.