Limiting hosts when including a playbook

Posted on

You can define a playbook that calls another and limits the host. Here’s a child playbook,that’s meant to be invoked by the parent. Note how hosts is defined:

# ping.yaml
- name: ping
  hosts: webservers:&$hosts
   - name: ping
     action: ping

Here’s how you would define another playbook that invokes ping.yaml but only for the staging server:

# pong.yaml
- include: ping.yaml hosts=staging

Leave a Reply

Your email address will not be published.