Thank you! Those work, indeed they do. What does that "~" syntax mean?

The reason I said your earlier solution did not work one is that you did
not in your first answer include the secret sauce of prefixing "tag": to
the tag name in the tag_name variable itself. When I do that, the first
variant works. I should have tried that, it seems obvious in hindsight :-)

The second variant is nicer IMHO because it keeps the specifics of the
filter syntax in the filter clause itself, and the actual tag name can be
passed in.

Thank you so much for your assistance. The solution using
ec2_instance_facts is way simpler than the solution I had working with
ec2.py.

Regards, K.


On Sun, May 6, 2018 at 10:10 AM, flowerysong <[email protected]> wrote:

> On Saturday, May 5, 2018 at 7:54:27 PM UTC-4, Karl Auer wrote:
>>
>>
>> Did you actually try that?
>>
>> When I use that, I get the same error as before: An error occurred
>> (InvalidParameterValue) when calling the DescribeInstances operation: The
>> filter 'GroupName' is invalid
>>
>> ("GroupName" is the value in my variable tag_name)
>>
>
> Yes, it works. You have to construct a valid filter, and GroupName isn't a
> valid filter.
>
> - hosts: localhost
>   become: false
>   tasks:
>     - ec2_instance_facts:
>         filters: "{{ { tag_name: tag_value } }}"
>       vars:
>         tag_name: "tag:Name"
>         tag_value: "*"
>     - ec2_instance_facts:
>         filters: "{{ { 'tag:' ~ tag_name: tag_value } }}"
>       vars:
>         tag_name: Name
>         tag_value: "*"
>
>
> PLAY [localhost] ******************************
> *********************************
>
> TASK [Gathering Facts] ******************************
> ***************************
> ok: [localhost]
>
> TASK [ec2_instance_facts] ******************************
> ************************
> ok: [localhost]
>
> TASK [ec2_instance_facts] ******************************
> ************************
> ok: [localhost]
>
> PLAY RECAP ************************************************************
> *********
> localhost                  : ok=3    changed=0    unreachable=0    failed=0
>
> --
> 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/3d8bda0d-0417-40df-9608-6e5a047117ba%40googlegroups.
> com
> <https://groups.google.com/d/msgid/ansible-project/3d8bda0d-0417-40df-9608-6e5a047117ba%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Karl Auer

Email  : [email protected]
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
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/CA%2B%2BT08RAtvtyGruQB7%2BrdPaukTpPYFoM_ujn-7Tfu69wPA4p4g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to