Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

networks ( both v4 and v6 ) in droplet.networks are empty #220

Closed
Lvl4Sword opened this issue Feb 7, 2022 · 13 comments · Fixed by #265
Closed

networks ( both v4 and v6 ) in droplet.networks are empty #220

Lvl4Sword opened this issue Feb 7, 2022 · 13 comments · Fixed by #265
Labels
bug Something isn't working module

Comments

@Lvl4Sword
Copy link

SUMMARY

When creating a droplet, there are no ipv4 or ipv6 addresses present.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.digitalocean

ANSIBLE VERSION
ansible 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]
COLLECTION VERSION
ansible-galaxy collection list
usage: ansible-galaxy collection [-h] COLLECTION_ACTION ...
ansible-galaxy collection: error: argument COLLECTION_ACTION: invalid choice: 'list' (choose from 'init', 'build', 'publish', 'install')
CONFIGURATION
ANSIBLE_SSH_RETRIES(/etc/ansible/ansible.cfg) = 10
DEFAULT_CALLBACK_WHITELIST(/etc/ansible/ansible.cfg) = ['timer']
PERSISTENT_CONNECT_TIMEOUT(/etc/ansible/ansible.cfg) = 300
OS / ENVIRONMENT

Ubuntu 20.04 LTS

STEPS TO REPRODUCE
  1. Make a droplet
  2. Notice the IP addresses are missing
  3. ????
- name: Create a new Droplet
  community.digitalocean.digital_ocean_droplet:
    state: present
    oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}"
    name: mydroplet
    size: s-1vcpu-1gb
    region: sfo3
    image: ubuntu-20-04-x64
    wait_timeout: 500
    ssh_keys: [ .... ]
  register: my_droplet
EXPECTED RESULTS

IP addresses are present

ACTUAL RESULTS

They are not present


@mamercad mamercad added the bug Something isn't working label Feb 7, 2022
@mamercad
Copy link
Collaborator

mamercad commented Feb 7, 2022

Looks like the module isn't waiting long enough, or polling correctly -- I've tried this with state active as well. In the mean time, as a workaround, you could use something like:

- name: Wait for a minute
  ansible.builtin.pause:
    minutes: 1

- name: Get Droplet Info
  community.digitalocean.digital_ocean_droplet_info:
    oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}"
    name: mydroplet
  register: my_droplet_info

...after your creation play.

@Lvl4Sword
Copy link
Author

I'm getting the following when the droplet is being created now:

The full traceback is:
Traceback (most recent call last):
  File "/home/flask/.ansible/tmp/ansible-tmp-1644265527.2138073-146419079816711/AnsiballZ_digital_ocean_droplet.py", line 102, in <module>
    _ansiballz_main()
  File "/home/flask/.ansible/tmp/ansible-tmp-1644265527.2138073-146419079816711/AnsiballZ_digital_ocean_droplet.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/flask/.ansible/tmp/ansible-tmp-1644265527.2138073-146419079816711/AnsiballZ_digital_ocean_droplet.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.community.digitalocean.plugins.modules.digital_ocean_droplet', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib/python3.8/runpy.py", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_community.digitalocean.digital_ocean_droplet_payload_w31be1sn/ansible_community.digitalocean.digital_ocean_droplet_payload.zip/ansible_collections/community/digitalocean/plugins/modules/digital_ocean_droplet.py", line 909, in <module>
  File "/tmp/ansible_community.digitalocean.digital_ocean_droplet_payload_w31be1sn/ansible_community.digitalocean.digital_ocean_droplet_payload.zip/ansible_collections/community/digitalocean/plugins/modules/digital_ocean_droplet.py", line 905, in main
  File "/tmp/ansible_community.digitalocean.digital_ocean_droplet_payload_w31be1sn/ansible_community.digitalocean.digital_ocean_droplet_payload.zip/ansible_collections/community/digitalocean/plugins/modules/digital_ocean_droplet.py", line 858, in core
  File "/tmp/ansible_community.digitalocean.digital_ocean_droplet_payload_w31be1sn/ansible_community.digitalocean.digital_ocean_droplet_payload.zip/ansible_collections/community/digitalocean/plugins/modules/digital_ocean_droplet.py", line 734, in create
AttributeError: 'NoneType' object has no attribute 'get'

@mamercad
Copy link
Collaborator

mamercad commented Feb 7, 2022

Interesting; is the behavior different with unique_name: true?

@Lvl4Sword
Copy link
Author

This happens specifically if unique_name is true

@mamercad
Copy link
Collaborator

mamercad commented Feb 7, 2022

Hrm, the reason why I asked is because unique_name: true isn't set in the example that you're posting. Could you (after redacting anything sensitive), provide the playbook so that I can reproduce this locally?

@Lvl4Sword
Copy link
Author

Something like the following will trigger it:

- name: Create a new Droplet
  community.digitalocean.digital_ocean_droplet:
    state: present
    name: "{{ droplet_name }}"
    unique_name: yes
    oauth_token: "{{ do_oauth_token }}"
    size_id: s-1vcpu-2gb
    region_id: nyc1
    image_id: ubuntu-20-04-x64
    ipv6: yes
    monitoring: yes
    ssh_keys: ['Redacted']
    wait_timeout: 300
    tags: ['test']
  register: my_droplet

@mamercad
Copy link
Collaborator

mamercad commented Feb 7, 2022

I wasn't able to reproduce this, here's my first run output and playbook.

@Lvl4Sword
Copy link
Author

Kind of weird, I'm not getting the issue now.

@mamercad
Copy link
Collaborator

mamercad commented Feb 7, 2022

Since that's the case, likely something going on with the Cloud at that point in time. Regardless, tracebacks shouldn't happen; so, we can leave this open for sure.

@mpontillo
Copy link
Collaborator

Looks like the traceback is happening in this section of code; when the response object is checked for the json data result, response.json is coming back as None.

It might be possible that the API returned an error and the code didn't catch it; I don't see any checking for status_code, for example.

@Lvl4Sword
Copy link
Author

Lvl4Sword commented Feb 9, 2022

To elaborate on the above, it looks like creation of a droplet seems to take as long as the timeout.
I've noticed the timeout is reached on a few occasions, and this is evident by the amount of time my playbook is taking.
Which, considering I've set a 300 second timeout.. should be more than enough.

@apple4ever
Copy link

I ran into this problem, and adding unique_name: true fixed it for me.

@mamercad mamercad added the module label May 5, 2022
coreywright added a commit to coreywright/community.digitalocean that referenced this issue Jun 2, 2022
When updating droplet info while waiting after creation, instead of
using `get_droplet()` and being dependent upon the optional
`unique_name` feature, use `get_by_id()` with the droplet's ID which
we definitively have having just created the droplet.

Fixes ansible-collections#220.
coreywright added a commit to coreywright/community.digitalocean that referenced this issue Jun 2, 2022
When updating droplet info while waiting after creation, instead of
using `get_droplet()` and being dependent upon the optional
`unique_name` feature, use `get_by_id()` with the droplet's ID which
we should have having just created the droplet.

Fixes ansible-collections#220.
@coreywright
Copy link
Contributor

the problem was during the post-API-create wait the updated droplet info was retrieved with get_droplet(), which is dependent upon unique_name (as expressed in a comment within the code), where instead get_by_id() should be used as we have the droplet ID (having just created the droplet and received it from the API) and just used it in the create to power the droplet on/off.

relevant code block is here.

coreywright added a commit to coreywright/community.digitalocean that referenced this issue Jun 6, 2022
When updating droplet info while waiting after creation, instead of
using `get_droplet()` and being dependent upon the optional
`unique_name` feature, use `get_by_id()` with the droplet's ID which
we should have having just created the droplet.

Fixes ansible-collections#220.
coreywright added a commit to coreywright/community.digitalocean that referenced this issue Jun 6, 2022
When updating droplet info while waiting after creation, instead of
using `get_droplet()` and being dependent upon the optional
`unique_name` feature, use `get_by_id()` with the droplet's ID which
we should have having just created the droplet.

Fixes ansible-collections#220.
coreywright added a commit to coreywright/community.digitalocean that referenced this issue Jun 8, 2022
When updating droplet info while waiting after creation, instead of
using `get_droplet()` and being dependent upon the optional
`unique_name` feature, use `get_by_id()` with the droplet's ID which
we should have having just created the droplet.

Fixes ansible-collections#220.
mamercad pushed a commit that referenced this issue Jun 9, 2022
When updating droplet info while waiting after creation, instead of
using `get_droplet()` and being dependent upon the optional
`unique_name` feature, use `get_by_id()` with the droplet's ID which
we should have having just created the droplet.

Fixes #220.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants