The magic line seems to be
hosts: "jenkinsslaves:&{{ hosts|default('all') }}"
I was missing that the ouput of the {{ }} expression needs to be a string
('all'), not a variable (e.g. all).
This seems like a pretty easy solution, unless there is a better way?
Thanks,
Alan
On Friday, March 20, 2015 at 8:07:51 PM UTC-4, Alan Ray wrote:
>
> I'm trying to figure out how to make includable playbooks that
> 1) Work like normal playbooks when run via ansible, running an a group of
> hosts
> 2) Only run on the group of hosts from (1) that intersects with the hosts
> of the includer.
>
> (Use case: I have a playbook for initializing our Jenkins slaves.
> Sometimes I need to run it directly to update all of the slaves to a new
> configuration. But sometimes I'm setting up a type of server that includes
> being a slave and I just need to include the role so that all servers of
> that type are setup correctly.)
>
> This seems like a common use case, but I can't find it in the
> documentation which makes me wonder if I have the wrong approach. Here's
> what I have so far:
>
> *JenkinsSlave.yml*
> - name: JenkinsSlave creation
> hosts: jenkinslaves:&{{hosts}}
> ...
>
> *BuildServer.yml*
> - include: JenkinsSlave.yml hosts=BuildServers
> ...
>
> The above works for inclusion, but doesn't work when I run
> JenkinsSlaves.yml because hosts is empty and so the intersection of
> JenkinsSlave and hosts is none. I'd like something like
> :&{{hosts|default(all)}} but that doesn't seem to work the way I expect.
>
> Thanks for all feedback,
> Alan
>
--
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/6df64175-81ac-466b-8ee6-e8a66b99fc22%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.