Issue with registered variables

50 views
Skip to first unread message

Cann

unread,
Dec 8, 2016, 8:08:25 PM12/8/16
to Ansible Project
Hi guys , I am having a really hard time with registered variables. I banged my head around all day.... but could not figure this out. :(

I simply want to register my task result as a variable and access it later on.

This is my debug: var= result: https://pastebin.mozilla.org/8950629
and I simply want to get dns_name

I call it like this:


- name: Wait for servers to boot up
  wait_for:
    host: "{{ item.dns_name }}"
    port: 22
    delay: 30
    timeout: 300
    state: started
  with_items: ec2_result.instances 


But I am getting error saying that 


fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'unicode object' has no attribute 'dns_name'\n\n


Can you guys please point me to right direction?
Thank you.
 

Matt Martz

unread,
Dec 8, 2016, 9:08:54 PM12/8/16
to ansible...@googlegroups.com
As of Ansible 2.2 with_items does not support bare variables.

As such you need to use:

with_items: "{{ ec2_result.instances }}"

Otherwise it will treat ec2_result.instances as a string.


--


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 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/cff7dbba-13f5-449f-afb8-87c29d9e0636%40googlegroups.com.


For more options, visit https://groups.google.com/d/optout.


Cann

unread,
Dec 8, 2016, 11:08:45 PM12/8/16
to Ansible Project
Thank you so much Matt Martz! You're awesome! 
Reply all
Reply to author
Forward
0 new messages