I have an 'all-hosts' playbook which contains logic common to all hosts.
This playbook is nested as an include in several top-level playbooks (for
example deploy-application-x and deploy-application-y). When I run each of
these top level playbooks I want to limit the hosts on which all-hosts runs
to just the hosts defined in the top level playbook.
Here's a slightly contrived example in code:
#deploy-app-x.yml
---
# First do the stuff which is common to all hosts, but just run it on the
app-x-hosts this time
- include: all-hosts.yml hosts=app-x-hosts
# Then deploy app-x
- hosts: app-x-hosts
roles:
- { role: deploy-app-x, tags: ['app-x']}
#deploy-app-y.yml
---
# First do the stuff which is common to all hosts, but just run it on the
app-y-hosts this time
- include: all-hosts.yml hosts=app-y-hosts
# Then deploy app-y
- hosts: app-y-hosts
roles:
- { role: deploy-app-y, tags: ['app-y']}
#all-hosts.yml
---
- hosts: &$hosts #This convention is defined in 'Patterns'
http://docs.ansible.com/ansible/intro_patterns.html but doesn't seem to
work at all here.
roles:
- { role: group-management, groups_to_manage: [{ name: 'dev' }, { name:
'247ops' }], tags: ['groups', 'users'] }
- { role: user-management, users: "{{ devteam_users }}", tags:
['users'] }
- { role: user-management, users: "{{ twenty_four_seven_ops_users }}",
tags: ['users'] }
When I try to execute either of the top level playbooks the invocation of
the all-hosts playbook simply gets skipped:
PLAY
***************************************************************************
skipping: no hosts matched
Is this something Ansible supports or have I gone a bit off piste here? If
the latter are there any common Ansible idioms for nesting and re-using
plays across different sets of machines?
Many thanks,
Edd
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/07165114-5f7e-4fdd-af77-7286efbebc63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.