Hello all,

I have been working with a few different patterns for launching and 
configuring ec2 hosts, first with add_host, and more recently working with 
refresh_inventory.  The problem I am having is that all ec2_ host variables 
are lost with the introduction of the refresh_inventory task.  Sample 
playbook:

---
- hosts: localhost
  connection: local
  gather_facts: false
  roles:
    - aws_ec2    # standard ec2 deployment based on include vars
  tasks:
    - meta: refresh_inventory

- hosts: tag_Name_somehosts
  tasks:
    - debug: var=hostvars[inventory_hostname]
    - debug: var=ec2_tag_Name

Running the playbook specifies an inventory directory, containing ec2.py, a 
static hosts laying out some groups, group_vars, etc:

ansible-playbook -i inventory ec2.yml

I can see in the debug output that the ec2 host variables are lacking, yet 
all the tag, instance, and sg-based groups exist.  This fact is also proven 
because the host declaration itself for the second play relies on one of 
those groups.  But the second task echoing out the ec2_tag_Name fails:

ok: [10.1.1.1] => {
    "ec2_tag_Name": "VARIABLE IS NOT DEFINED!"
}

Of course if I leave off the refresh, the playbook will succeed and those 
variables exist, except for that very first run where the instances were 
not in inventory and the group does not exist:

PLAY [tag_Name_somehosts] **************************************************
skipping: no hosts matched

As an aside, when I introduced refresh_inventory to the typical add_host 
playbook pattern, that re-init of inventory seemed to eliminate the ad-hoc 
ec2launch group I had created (probably expected).

Ultimately, if any tasks or roles in the second post-ec2-provisioning play 
rely on ec2_* variables, I am afraid refresh_inventory is deleting them.  I 
flipped on and off gather_facts for the second play and it made no 
difference.

Has anyone else run into this or have an idea whether I should be doing 
something differently?  

-Jeff

-- 
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/ebb64ed0-f8b6-4072-b8d5-3ec095620c44%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to