I have a task where I am updating a line in a file with a comma separated
list of inventory hosts, this works for the hard coded case:
- name: Set host list
lineinfile: dest=/home/project/pom.xml
regexp='<targetHosts>.*</targetHosts>' line='<targetHosts>{{
groups.tag_Type_targettype | intersect('groups.key_mykey) | join(', ')
}}</targetHosts>'
key_mykey is a group generated from ec2 properties in a dynamic inventory
using:
- name: Create groups based on ec2 access key
group_by: key=key_{{ ec2_key_name }}
The issue I'm facing is that I need to be able to generate the intersection
'key_<MYKEY>' from a variable so that I can generate different
intersections at playbook runtime.
I have tried different ways to use a variable for <MYKEY>, most give a
runtime error, the following does not, but it also generates an empty hosts
list.
vars:
ec2keyname: mykey
intersect('groups.key_' + ec2keyname)
Is there a way to use a variable in the intersection groups name?
Andy
--
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/23c9fd37-c143-40bb-805b-97338a0ea34a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.