Limit hosts for nested playbook

56 views
Skip to first unread message

Andrew

unread,
Sep 21, 2016, 9:33:51 PM9/21/16
to Ansible Project
Is it possible to limit the hosts that run against a nested playbook? For example, I have a site.yml file that includes other playbooks like so:

---
- hosts: all
  roles:
    - foo

- include: foo.yml

For the foo playbook I'd only want a subset of hosts to get evaluated. Some googling pointed me at trying the following syntax but it doesn't seem to work:

---
- hosts: all
  roles:
    - foo

- include: foo.yml hosts=bar

This results in syntax errors. Is this possible?

Brian Coca

unread,
Sep 22, 2016, 11:44:58 AM9/22/16
to ansible...@googlegroups.com
no


----------
Brian Coca

J Hawkesworth

unread,
Sep 22, 2016, 12:19:54 PM9/22/16
to Ansible Project
I suggest you create some groups in your inventory, so instead of
- hosts: all

you run against
- hosts: webservers

(obviously webservers is just an example of a group).

This is nice when reading playbooks as you instantly get a notion of what roles are needed on the different types of server you are managing.

Hope this helps,

Jon
Reply all
Reply to author
Forward
0 new messages