Thank you so much! The below syntax worked for me as well.
filters: "{{ { 'tag:' ~ tag_name: tag_value } }}"
I had a follow up question related to this. How can I add multiple filters
with one filter being "{{ { 'tag:' ~ tag_name: tag_value } }}"?
I am trying to add it like we do in all other cases(shown below) but it
gives an error.
filters:
instance-state-name: ["running"]
"{{ { 'tag:' ~ tag_name: tag_value } }}"
However, I get a syntax error.
Can you please suggest what am I doing wrong?
Thanks in advance!!
On Saturday, 5 May 2018 20:10:05 UTC-4, flowerysong 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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/eeb7c377-7f3d-44bf-b627-cebcb6d9b552%40googlegroups.com.