I've tried a LOT of things now, and have come to the conclusion that ec2_instance_facts requires a literal filter name, at least in the case of "tags:Name".
This makes that filter essentially useless :-(
Please, can someone tell me I'm wrong, and how me how to filter on a tag:value pair passed in as a variable?
- ec2_instance_facts: filters: "{{ { tag_name: tag_value } }}"
--
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+unsubscribe@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/38b14171-3086-4c2d-868f-de3882384090%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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)
- 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 ansible-project+unsubscribe@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/3d8bda0d-0417-40df-9608-6e5a047117ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Kai Stian Olstad
--
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+unsubscribe@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/de2d6b8e5b066b65209bc44007105480%40olstad.com.
For more options, visit https://groups.google.com/d/optout.
How does "~" differ from "+"?"{{ 'hello' ~ name ~ 'there!' }}"vs
"{{ 'hello' + name + 'there!' }}"
?
While they’re often
interchangeable, developing a habit of using the concatenation operator
means that you don’t have to worry about or code around the situations
where they’re not.
TASK [Addition isn't concatenation] ********************************************
ok: [localhost] => {
"13 + 37": "50"
}
TASK [Concatenation is concatenation] ******************************************
ok: [localhost] => {
"13 ~ 37": "1337"
}
TASK [Concatenation handles mixed types] ***************************************
ok: [localhost] => {
"13 ~ '37'": "1337"
}
TASK [It's possible to do the coercion manually, but who wants to do that?] ****
ok: [localhost] => {
"13 | string + '37'": "1337"
}
TASK [Addition doesn't like mixed types] ***************************************
fatal: [localhost]: FAILED! => {"msg": "Unexpected templating type error occurred on ({{13 + '37'}}): unsupported operand type(s) for +: 'int' and 'str'"}