It will also fail if you don't quote the variable.
Use this:
- debug:
msg: "{{ my_droplet.droplet.ip_address }}"
Or this:
- debug: msg={{ my_droplet.droplet.ip_address }}
Simon
On Thursday, January 5, 2017 at 5:07:51 PM UTC+1, Jerry Steele wrote:
>
> Hi All,
>
> It looks like I've stumbled across a bug with the digital_ocean module.
>
> I've been following the digital ocean tutorial here
> <https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-api-v2-with-ansible-2-0-on-ubuntu-14-04>,
>
> but I want to parameterise as much as possible. I'm building a role, and
> this is the main tasks.yml:
>
> - hosts: digitalocean
> vars:
> - zonomi_api_key: <my zonomi api key>
> - zonomi_url: http://zonomi.com/app/dns/dyndns.jsp
> - do_url: <URL of do_droplet>
> - do_domain: <my domain>
> tasks:
>
> - name: Add droplet
> digital_ocean: >
> state=present
> command=droplet
> name={{ item.key }}
> size_id=512mb
> region_id=ams2
> image_id={{ item.value.image_id }}
> ssh_key_ids={{ my_ssh_key.ssh_key.id }}
> unique_name=yes
> with_dict: "{{ droplets_up }}"
> register: my_droplet
>
>
> - debug:
> msg: {{ my_droplet.droplet.ip_address }
>
> The host_vars are elsewhere, but I don't believe they're important in
> this context - the droplet gets created as expected.
>
> However, I get the following error about the "ip_address" var:
>
> 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: 'dict object' has no attribute 'id'\n\nThe error
> appears to have been in '/my/path/digitalocean.yml': line 33, column 7, but
> may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe
> offending line appears to be:\n\n msg: Droplet details are {{
> my_droplet }}\n - debug:\n ^ here\n"}
>
> The official docs
> <http://docs.ansible.com/ansible/digital_ocean_module.html> appear to
> suggest that this should work, and if I print debug output of "my_droplet"
> on its own, I get a dump of the variable with all its data (I won't reprint
> it unless it's required as it would take a while to go through and
> obfuscate any sensitive data). I would like the ability to pick out certain
> parts of the var (in this instance, I need the IP in order to publish it to
> my DNS server..
>
> Thanks
>
> Jerry
>
>
>
--
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/8274d56a-cc7e-4a7e-9c8a-03d8f98f1f79%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.