Highlighted
Mission Specialist
Mission Specialist
  • 1,197 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
Highlighted
Flight Engineer Flight Engineer
Flight Engineer
  • 1,189 Views

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

Jump to solution

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

Reply
Loading...
5 Replies
Highlighted
Flight Engineer Flight Engineer
Flight Engineer
  • 1,190 Views

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

Jump to solution

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

Reply
Loading...
Highlighted
Mission Specialist
Mission Specialist
  • 1,186 Views

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

Jump to solution

Thank you for the quick response! cleared everything up.

0 Kudos
Reply
Loading...
Highlighted
Flight Engineer Flight Engineer
Flight Engineer
  • 1,176 Views

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

Jump to solution

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!'
Reply
Loading...
Highlighted
Flight Engineer Flight Engineer
Flight Engineer
  • 1,162 Views

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

Jump to solution

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.

Reply
Loading...
Highlighted
Flight Engineer Flight Engineer
Flight Engineer
  • 1,139 Views

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

Jump to solution

Good point about the hosts directive @littlebigfab 

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