Hello Team,
I am using the EC2 Inventory plugin to build a dynamic inventory for
ansible to run. The inventory is built based on certain ec2 instance tags
mentioned in the filters section of the plugin config so that I can run
ansible targetting specific instances based on their tags. Everything works
as expected when I hard code the value of the tags in the plugin config
directly. Unfortunately, when I try specifying a variable instead of the
actual value, it doesn't work. It just returns "[WARNING]: Could not match
supplied host pattern, ignoring: role_server".
>From the below config, I am passing a variable 'var1' as value for the tag
'cluster_name'. The value for this variable is mentioned in group_vars/all.
After some research, I found that group_vars or host_vars are acknowledged
only on the task level and not on the inventory level. Do we have any
workaround to make this work?
plugin: aws_ec2
regions:
- xxxxxxx
keyed_groups:
- key: tags.role
prefix: role_
separator: ""
groups:
role_all: "'role' in (tags|list)"
compose:
# set the ansible_host variable to connect with the private IP address
without changing the hostname
ansible_host: private_ip_address
filters:
tag:role:
- server
- worker
tag:cluster_name:
- "{{ var1 }}"
Thanks,
Prasanth
--
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/7c6726b5-7638-4316-b6e9-5113dc9f42d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.