Is it normal for add_host to not work when using ec2.py? I’m in a playbook that is using ec2.py as the inventory source and I’m trying to create a few groups dynamically using ec2 tag values.
When I run debug on the hostvars afterwards, the new group name isn’t there.
Inventory output:
jenkins@ip-172-31-35-124:~/jobs/JobName/workspace$ bin/devtools/ansible/ec2.py --list --refresh-cache
…“tag_ec2id_test10”: [
“172.31.31.72”,
“172.31.45.13”
“tag_ec2type_mysql”: [
“172.31.25.13”
],
“tag_ec2type_apache”: [
“172.31.31.72”…
Start of the play
name: Gather ec2 facts
ec2_facts:
when: provider == “ec2”name: Add instance to iaas-provider-agnostic type group
add_host: hostname={{ inventory_hostname }} groups=“{{ ec2_tag_ec2type }}”
when: provider == “ec2”
A call to debug on one of these hosts, inserted after the above calls:
"ec2_tag_ec2id": "test10", "ec2_tag_ec2id_and_ec2type": "test10_apache2", "ec2_tag_ec2type": "apache2",
... "group_names": [ "***************************", "***************************", "i-********", "key_*******", "security_group_***************************", "security_group_***************************", "security_group_***************************", "***************************", "***************************", "tag_ec2id_and_ec2type_test10_apache2", "tag_ec2id_test10", "tag_ec2type_apache2", "tag_provisioned_True", "type_m1_medium", "us-west-2", "us-west-2b" ],
TIA for any insights…hopefully I’ve just got an obvious typo.
-Mark