Re: [ansible-project] Re: Limiting hosts when including playbooks

2019-04-17 Thread lander . hernandezmartinez
I TAKE PART IN THIS CONVERSATION. I TAKE ADVANTAGE OF FOR SAY THIS: "the 
suppository is placed on the flat part"

-- 
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/0b8fa66f-321d-41b7-bbf7-63729de27823%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Limiting hosts when including playbooks

2019-04-17 Thread 'Uffi Schnuffi' via Ansible Project
On Tuesday, April 9, 2019 at 4:33:08 PM UTC+2, Brian Coca wrote:

> create the groups the imported playbook uses in a  group_by in a preceding 
> play 
>

This is amazing!!! Thank you! : )


-- 
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/66e66912-b46f-4487-9639-121901471ecd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Limiting hosts when including playbooks

2019-04-09 Thread Brian Coca
create the groups the imported playbook uses in a  group_by in a preceding play


--
Brian Coca

-- 
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/CACVha7f4Mddm3wXEkZQm-F%2B-zYw-Y9PyzYuypycpJpgk07qWMw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Limiting hosts when including playbooks

2019-03-27 Thread Uffi Schnuffi
This is not feasbile when the imported playbook is not in one's own control.
In my use case the imported playbook is a playbook controlled by a third 
party. The issue here is that the host group names used by that playbook do 
not necessarily reflect the host names in our inventory.
It would be neat if it were possible to define something like

```
- import_playbook: playbook
  vars:
 host_groups:
 group1:# this is the host group used in the imported playbook
   - our_inv_groupA
   - our_inv_groupB
```

Such functionality would make importing very powerful. I'm not sure if it's 
doable with the static nature of importing playbooks, though..  I guess it 
depends on when the inventory comes into play during (pre)processing.


My workaround now is to make sure that the host groups used in the imported 
playbook exist in our inventory. Further, it has to be ensured that the 
imported playbook does not use `all` (since the inventory file may contain 
other and shared hosts): Can be tested with `ansible-playbook --list-hosts 
`.




On Tuesday, March 26, 2019 at 1:41:48 PM UTC+1, Sebastian Meyer wrote:
>
> On 26.03.19 13:01, 'Uffi Schnuffi' via Ansible Project wrote: 
> > 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. 
>
> --- 
> - import_playbook: test.yaml 
>   vars: 
> myhosts: plonk 
>
> --- 
> - name: Test playbook 
>   hosts: all:&{{ myhosts }} 
>   tasks: 
>  - name: test var 
>debug: 
>msg: "GOOO" 
>
>
> works for me. 
>
> See: 
>
> https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.7.html#include-tasks-import-tasks-inline-variables
>  
>
> Sebastian 
>
>
> > 
> > 
> > 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 
> >> > 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  >>> > 
>  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, 
> >>

Re: [ansible-project] Re: Limiting hosts when including playbooks

2019-03-26 Thread Sebastian Meyer
On 26.03.19 13:01, 'Uffi Schnuffi' via Ansible Project wrote:
> 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.

---
- import_playbook: test.yaml
  vars:
myhosts: plonk

---
- name: Test playbook
  hosts: all:&{{ myhosts }}
  tasks:
 - name: test var
   debug:
   msg: "GOOO"


works for me.

See:
https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.7.html#include-tasks-import-tasks-inline-variables

Sebastian


> 
> 
> 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 > > 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 >> >
 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 .
> 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 .
 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 .
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>
>> -- 
>> Lorin Hochstein
>> Lead Architect - Cloud Services
>> Nimbis Services, Inc.
>> www.nimbisservices.com
>>
> 

-- 
Sebastian Meyer
Linux Consultant & Trainer
Tel.: +49-172-2057471
Mail: me...@b1-systems.de

B1 Systems GmbH
Os

Re: [ansible-project] Re: Limiting hosts when including playbooks

2019-03-26 Thread 'Uffi Schnuffi' via Ansible Project
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  > 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 > >
>> > 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 .
>> >> 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 .
>> > 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 .
>> 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.