# digital\_ocean module and host\_vars

**URL:** <https://forum.ansible.com/t/digital-ocean-module-and-host-vars/23389>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [January 5, 2017, 4:07pm UTC](https://forum.ansible.com/t/digital-ocean-module-and-host-vars/23389 "2017-01-05T16:07:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ticktockhouse](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ticktockhouse/32/8278_2.png) [@ticktockhouse](https://forum.ansible.com/u/ticktockhouse)\
**Post date:** [January 5, 2017, 4:07pm UTC](https://forum.ansible.com/t/digital-ocean-module-and-host-vars/23389/1 "2017-01-05T16:07:51Z")

</div>

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: 

- zonomi\_url: [http://zonomi.com/app/dns/dyndns.jsp](http://zonomi.com/app/dns/dyndns.jsp)

- do\_url: 

- do\_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

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [January 6, 2017, 8:41pm UTC](https://forum.ansible.com/t/digital-ocean-module-and-host-vars/23389/2 "2017-01-06T20:41:58Z")

</div>

1. You are missing the second closing curly bracket.

2. Does using this help?  
- debug: var=my\_droplet  
- debug: var=my\_droplet.droplet  
- debug: var=my\_droplet.droplet.ip\_address

3. Sure you have not mixed up ip and id somewhere:  
"The error was: 'dict object' has no attribute 'id'"

What's in "/my/path/digitalocean.yml': line 33, column 7"? Anything  
that hits your eye?

Johannes

---

<div class="post-metadata">

**Author:** ![Simon\_Wydooghe](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@Simon\_Wydooghe](https://forum.ansible.com/u/Simon_Wydooghe)\
**Post date:** [January 8, 2017, 12:13pm UTC](https://forum.ansible.com/t/digital-ocean-module-and-host-vars/23389/3 "2017-01-08T12:13:58Z")

</div>

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
