Re: [ansible-project] Ansible dynamic looping

2018-02-01 Thread Pshem Kowalczyk
Hi,

If you use the dynamic inventory script (ec2.py) you can use tags to
dynamically create groups. Have a look here:
https://aws.amazon.com/blogs/apn/getting-started-with-ansible-and-dynamic-amazon-ec2-inventory-management/


kind regards
Pshem


On Fri, 2 Feb 2018 at 18:39 Andrew Morgan  wrote:

> Thanks for your reply, but the issue with that is , the servers in aws get
> removed and created again each build( every 1hr) , so I would need a way to
> get the servers dynamically.Is there anyway to do that? i want to
> dynamically have a list, not create a list of servers in inventory.
>
>
> On Thursday, 1 February 2018 21:08:51 UTC-5, Pshem Kowalczyk wrote:
>
>> with_items requires a list to iterate over. I think one way of achieving
>> your outcome is to create a group in the inventory and populate it with the
>> hosts and run the playbook against that group.
>>
>> kind regards
>> Pshem
>>
> On Fri, 2 Feb 2018 at 13:02 Andrew Morgan 
>> wrote:
>>
> Hello all,
>>>
>>> I have a play I want to run wich deletes all hosts matching a certain
>>> criteria:
>>>
>>> tasks:
>>>   - name: Delete unavailable nodes
>>> zabbix_host:
>>>  server_url: http://zabbix.aa.net/zabbix
>>>  login_user: Admin
>>>  login_password: aq!
>>>  host_groups: Discovered hosts
>>>  status: disabled
>>>  state: absent
>>>  host_name: "{{ item }}"
>>> with_items:
>>>  - ip-10-1-*-*.us-west-2.compute.internal
>>>
>>>
>>>
>>> The above doesnt work, but if I list out the items
>>> with_items:
>>>  - ip-10-1-65-27.us-west-2.compute.internal
>>>  - ip-10-1-65-28.us-west-2.compute.internal
>>>  - ip-10-1-65-37.us-west-2.compute.internal
>>>
>>> then it works, but I want it to be dynamic and find all ips matching
>>>- ip-10-1-*-*.us-west-2.compute.internal
>>>
>>> any help please?
>>>
>>> --
>>> 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.
>>> To post to this group, send email to ansible...@googlegroups.com.
>>
>>
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/dcd118b2-775b-44d3-baf5-713b9b0918be%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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/698ae457-a362-4f57-a384-13f932a6f654%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAEaZiRXs6e3qLAZ0TyNO2YHr27OwPEu5pqMW4L9PW_Xgve8MOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible dynamic looping

2018-02-01 Thread Andrew Morgan
Thanks for your reply, but the issue with that is , the servers in aws get 
removed and created again each build( every 1hr) , so I would need a way to 
get the servers dynamically.Is there anyway to do that? i want to 
dynamically have a list, not create a list of servers in inventory.

On Thursday, 1 February 2018 21:08:51 UTC-5, Pshem Kowalczyk wrote:
>
> with_items requires a list to iterate over. I think one way of achieving 
> your outcome is to create a group in the inventory and populate it with the 
> hosts and run the playbook against that group.
>
> kind regards
> Pshem
>
>
> On Fri, 2 Feb 2018 at 13:02 Andrew Morgan  
> wrote:
>
>> Hello all,
>>
>> I have a play I want to run wich deletes all hosts matching a certain 
>> criteria:
>>
>> tasks:
>>   - name: Delete unavailable nodes
>> zabbix_host:
>>  server_url: http://zabbix.aa.net/zabbix
>>  login_user: Admin
>>  login_password: aq!
>>  host_groups: Discovered hosts
>>  status: disabled
>>  state: absent
>>  host_name: "{{ item }}"
>> with_items:
>>  - ip-10-1-*-*.us-west-2.compute.internal
>> 
>>
>>
>> The above doesnt work, but if I list out the items
>> with_items:
>>  - ip-10-1-65-27.us-west-2.compute.internal
>>  - ip-10-1-65-28.us-west-2.compute.internal
>>  - ip-10-1-65-37.us-west-2.compute.internal
>>
>> then it works, but I want it to be dynamic and find all ips matching   
>>- ip-10-1-*-*.us-west-2.compute.internal
>>
>> any help please?
>>
>> -- 
>> 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 .
>> To post to this group, send email to ansible...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/dcd118b2-775b-44d3-baf5-713b9b0918be%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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/698ae457-a362-4f57-a384-13f932a6f654%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible dynamic looping

2018-02-01 Thread Pshem Kowalczyk
with_items requires a list to iterate over. I think one way of achieving
your outcome is to create a group in the inventory and populate it with the
hosts and run the playbook against that group.

kind regards
Pshem


On Fri, 2 Feb 2018 at 13:02 Andrew Morgan  wrote:

> Hello all,
>
> I have a play I want to run wich deletes all hosts matching a certain
> criteria:
>
> tasks:
>   - name: Delete unavailable nodes
> zabbix_host:
>  server_url: http://zabbix.aa.net/zabbix
>  login_user: Admin
>  login_password: aq!
>  host_groups: Discovered hosts
>  status: disabled
>  state: absent
>  host_name: "{{ item }}"
> with_items:
>  - ip-10-1-*-*.us-west-2.compute.internal
>
>
>
> The above doesnt work, but if I list out the items
> with_items:
>  - ip-10-1-65-27.us-west-2.compute.internal
>  - ip-10-1-65-28.us-west-2.compute.internal
>  - ip-10-1-65-37.us-west-2.compute.internal
>
> then it works, but I want it to be dynamic and find all ips matching
> - ip-10-1-*-*.us-west-2.compute.internal
>
> any help please?
>
> --
> 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/dcd118b2-775b-44d3-baf5-713b9b0918be%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAEaZiRUGYVzhBwe2bPDiZNmjOpka%3DhKon-agR5YMYC4zbiFX-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Ansible dynamic looping

2018-02-01 Thread Andrew Morgan
Hello all,

I have a play I want to run wich deletes all hosts matching a certain 
criteria:

tasks:
  - name: Delete unavailable nodes
zabbix_host:
 server_url: http://zabbix.aa.net/zabbix
 login_user: Admin
 login_password: aq!
 host_groups: Discovered hosts
 status: disabled
 state: absent
 host_name: "{{ item }}"
with_items:
 - ip-10-1-*-*.us-west-2.compute.internal



The above doesnt work, but if I list out the items
with_items:
 - ip-10-1-65-27.us-west-2.compute.internal
 - ip-10-1-65-28.us-west-2.compute.internal
 - ip-10-1-65-37.us-west-2.compute.internal

then it works, but I want it to be dynamic and find all ips matching  - 
ip-10-1-*-*.us-west-2.compute.internal

any help please?

-- 
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/dcd118b2-775b-44d3-baf5-713b9b0918be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.