This is no longer working with the new `import_playbook` module.

Is there a recommended way to achieve this (i.e. limiting hosts for an 
imported playbook?). I have not found a way as of yet.


On Friday, February 1, 2013 at 5:06:49 PM UTC+1, Lorin Hochstein wrote:
>
>
> On Fri, Feb 1, 2013 at 11:02 AM, Daniel Hokka Zakrisson <dan...@hozac.com 
> <javascript:>> wrote:
>
>> Lorin Hochstein wrote:
>> > That approach works for limiting hosts when calling from the 
>> command-line,
>> > but I'd like to do it from inside of a playbook. One of the motivations 
>> is
>> > what Michael suggests in that original posting:
>> >
>> > "The same as the above example could be used with --limit stage or 
>> --limit
>> > production to control inventory.   I really don't recommend this though,
>> > because leaving off limit would be pretty dangerous."
>> >
>> > If I want to limit execution of a playbook to staging servers, I worry
>> > about somebody forgetting the "--limit" flag. I'd prefer to do have a
>> > separate playbook, say "update-staging.yaml", that looks like this:
>> >
>> > - include: update.yaml hosts=staging
>> >
>> > Unfortunately, that doesn't work. Right now I'm using a makefile to 
>> invoke
>> > my ansible playbooks to achieve this functionality, but I find that
>> > un-ansible-ish.
>> >
>> > Michael, would you accept merges that implemented this sort of host
>> > filtering on include statements? Would work the same as --limit on the
>> > command-line except it would be an argument to include.
>>
>> hosts: is already templateable with include arguments, so you could do
>> hosts: webservers:&$hosts
>> I think this will also lead to an error if you don't specify hosts, 
>> instead
>> of running against all of it.
>>
>>
> Cool, that works. For anybody who hits this via google, here's a complete 
> example:
>
> ping.yaml:
>
> - hosts: webservers:&$hosts
>   tasks:
>    - name: ping the hosts
>      action: ping
>
> pong.yaml:
>
> # Just ping the staging server
> - include: ping.yaml hosts=staging
>
>
>
> This is a useful pattern, where's a good place to document this? 
>
> Lorin
>
>
>  
>
>> Daniel
>>
>> >  Not sure what to call it (limit, limit-hosts, hosts)?
>> >
>> >
>> > Lorin
>> >
>> >
>> > On Fri, Feb 1, 2013 at 12:55 AM, Yeukhon Wong <gokop...@gmail.com 
>> <javascript:>>
>> > wrote:
>> >
>> >> I think you can try this
>> >>
>> >> 
>> https://groups.google.com/forum/#!msg/ansible-project/qfoeqytbRE4/SI58rlzeEwMJ
>> >>
>> >> If you ever need some exception (all in this group except XX) you can
>> >> use
>> >> hosts: group1:!except_this_group
>> >>
>> >>
>> >> On Thursday, January 31, 2013 11:26:22 PM UTC-5, Lorin Hochstein wrote:
>> >>>
>> >>> When including a playbook in another playbook, is there any way to
>> >>> limit
>> >>> the hosts in the child playbook?
>> >>>
>> >>> For example, if I had an existing playbook (e.g.,
>> >>> "configure-widget.yaml") that had its hosts set to "webservers", and I
>> >>> wanted to write a playbook that only applied to the staging web 
>> server,
>> >>> is
>> >>> there any way to do something like:
>> >>>
>> >>> - include: configure-widget.yaml limit-hosts=staging
>> >>>
>> >>>
>> >>> Lorin
>> >>>
>> >>  --
>> >> 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 ansible-proje...@googlegroups.com <javascript:>.
>> >> For more options, visit https://groups.google.com/groups/opt_out.
>> >>
>> >>
>> >>
>> >
>> >
>> >
>> > --
>> > Lorin Hochstein
>> > Lead Architect - Cloud Services
>> > Nimbis Services, Inc.
>> > www.nimbisservices.com
>> >
>> > --
>> > 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 ansible-proje...@googlegroups.com <javascript:>.
>> > For more options, visit https://groups.google.com/groups/opt_out.
>> >
>> >
>> >
>>
>> --
>> 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 ansible-proje...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
> -- 
> Lorin Hochstein
> Lead Architect - Cloud Services
> Nimbis Services, Inc.
> www.nimbisservices.com
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fc0140fb-bbf6-4515-b23f-53645e494bda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to