Upgrading to Ansible 2 break EC2 inventory groups augmentation

57 views
Skip to first unread message

Tzach Livyatan

unread,
Apr 21, 2016, 3:27:54 AM4/21/16
to Ansible Project
Hi
I have a working play book in Ansible 1.9
As part of it, I'm defining extra groups in file inventories/ec2/hosts, for example:
[us-west-2]
[us_west_2:children]
us-west-2

In Ansible 1.9, I used this group as follow:
1. run the playbook with -i inventories/ec2/ prefix
2. use the group as follow:
  - debug: msg="{{ hostvars[item].ec2_private_ip_address }}"
    with_items: groups.us_west_2

ec2.py did not change, and still return
...
  "us-west-2": [
    "54.213.157.131", 
    "54.191.215.128", 
    "54.186.93.200", 
    "54.186.40.39"
  ], 
...

Look like Ansible 2 does not use the groups defined in inventories/ec2/hosts.
Is it bug or a feature?
any idea how to bypass this issue?

Thanks
Tzach

Tzach Livyatan

unread,
May 25, 2016, 8:12:04 AM5/25/16
to Ansible Project
Still struggling with this issue
Any lead will be appreciated

Thanks

Johannes Kastl

unread,
May 25, 2016, 9:39:10 AM5/25/16
to ansible...@googlegroups.com
> On Thursday, April 21, 2016 at 10:27:54 AM UTC+3, Tzach Livyatan wrote:

>> As part of it, I'm defining extra groups in file inventories/ec2/hosts,
>> for example:
>> [us-west-2]
>> [us_west_2:children]
>> us-west-2

Is there a typo? Or are you using the group name as child element for
another group? us-west-2 vs. us_west_2

>> Look like Ansible 2 does not use the groups defined in
>> inventories/ec2/hosts.

What are the exact error messages? Maybe include some more debug tasks
to output the values.

You had a debug task in your mail, what was the output and was did you
expect to get?

Johannes


signature.asc

Tzach Livyatan

unread,
May 26, 2016, 12:10:19 PM5/26/16
to ansible...@googlegroups.com
Hi Johannes
Thanks for the response

On Wed, May 25, 2016 at 4:38 PM, Johannes Kastl <ma...@ojkastl.de> wrote:
> On Thursday, April 21, 2016 at 10:27:54 AM UTC+3, Tzach Livyatan wrote:

>> As part of it, I'm defining extra groups in file inventories/ec2/hosts,
>> for example:
>> [us-west-2]
>> [us_west_2:children]
>> us-west-2

Is there a typo? Or are you using the group name as child element for
another group? us-west-2 vs. us_west_2

It is an ugly hack indeed.  I did it to bypass the fact Ansible does no allow a variable with '-', while ec2.py groups are with '-'.
I will be happy to get rid of it, but as far as I can tell not the issue. 


>> Look like Ansible 2 does not use the groups defined in
>> inventories/ec2/hosts.

What are the exact error messages? Maybe include some more debug tasks
to output the values.

You had a debug task in your mail, what was the output and was did you
expect to get?

As far as I can tell the difference between Ansible 1.9 and 2.0 is the following:

    - debug: msg="{{ hostvars[item].ec2_private_ip_address }}"
      with_items: groups.us_west_2

    - debug: msg="{{ hostvars[item].ec2_private_ip_address }}"
      with_items: groups.{{region_group}}

The first debug works with both Ansible versions, the second failed only on Ansible 2, with the following error:

TASK [debug] *******************************************************************
task path: /home/fedora/cassandra-test-and-deploy/stress.yaml:27
fatal: [54.218.71.135]: FAILED! => {"failed": true, "msg": "'ansible.vars.hostvars.HostVars object' has no attribute u'groups.us_west_2'"}

Although the value of {{region_group}} was us_west_2, using a variable as an attribute of groups stopped working on Ansible 2
Does this issue ring any bells?

Thanks
Tzach

 

Johannes


--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/qTKRXIWQRow/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5745AAF1.9090801%40ojkastl.de.
For more options, visit https://groups.google.com/d/optout.

Johannes Kastl

unread,
May 26, 2016, 2:32:15 PM5/26/16
to ansible...@googlegroups.com
On 26.05.16 18:10 Tzach Livyatan wrote:

> As far as I can tell the difference between Ansible 1.9 and 2.0 is the
> following*:*

[...]

> Although the value of {{region_group}} was us_west_2, using a variable as
> an attribute of groups stopped working on Ansible 2
> Does this issue ring any bells?

If this worked in 1.9 and does no longer in 2.0, I would say try to
test it in 2.1, as there have been lots of fixes for regressions
AFAIK. If it still does not work, create a bug report aka issue on github.

Johannes

signature.asc
Reply all
Reply to author
Forward
0 new messages