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

digital_ocean_droplet action raises python error when api returns 500 #192

Open
y8 opened this issue Nov 19, 2021 · 1 comment
Open

digital_ocean_droplet action raises python error when api returns 500 #192

y8 opened this issue Nov 19, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@y8
Copy link

y8 commented Nov 19, 2021

SUMMARY

When API returns 500 status, digital_ocean_droplet with action: create raises python error.

ISSUE TYPE
  • Bug Report
COMPONENT NAME
ANSIBLE VERSION
ansible [core 2.11.6]
  config file =<snip>/ansible.cfg
  configured module search path = ['/Users/<snip>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/Cellar/ansible/4.8.0/libexec/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/y13/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.10.0 (default, Oct 12 2021, 22:37:59) [Clang 13.0.0 (clang-1300.0.29.3)]
  jinja version = 3.0.2
  libyaml = True
COLLECTION VERSION
# /Users/<snip>/.ansible/collections/ansible_collections
Collection             Version
---------------------- -------
community.digitalocean 1.12.0

# /opt/homebrew/Cellar/ansible/4.8.0/libexec/lib/python3.10/site-packages/ansible_collections
Collection             Version
---------------------- -------
community.digitalocean 1.11.0
CONFIGURATION
DEFAULT_STDOUT_CALLBACK(<snip>/ansible.cfg) = debug
DEFAULT_VAULT_PASSWORD_FILE(<snip>/ansible.cfg) = <snip>
OS / ENVIRONMENT

MacBookAir10,1 (M1, aarch64)
Darwin 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:24 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T8101 arm64

STEPS TO REPRODUCE

You can't reproduce actual API failure, but it can be reproduced by mocking response with code 500 and body:

{ "id": "unprocessable_entity", "message": "Internal Server Error"}
- name: Create droplet
  delegate_to: localhost
  community.digitalocean.digital_ocean_droplet:
    state: active
    name: test-name
    unique_name: yes
    private_networking: yes
    monitoring: yes
    size: "s-1vcpu-2gb-amd"
    image: "docker-20-04"
    region: "fra1"
    wait: yes
    wait_timeout: 500
  register: droplet_info

Raised 'NoneType' object has no attribute 'get'
Stacktrace points to:

droplet_id = droplet.get("id", None)

I suppose status_code should be checked before droplet and droplet_id are fetched from response

Thanks!

@mamercad mamercad added the bug Something isn't working label Nov 20, 2021
@djholms
Copy link

djholms commented Nov 26, 2021

I have the same issue.
System: Debian 11

  config file = /home/user/workspace/debug_DigitalOcean_Droplet_Management/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]

Collection

# /home/user/.ansible/collections/ansible_collections
Collection             Version
---------------------- -------
community.digitalocean 1.12.0 

Manifest

- name: Create a new droplet
  community.digitalocean.digital_ocean_droplet:
    state: present
    name: mydroplet
    oauth_token: XXX
    size: 2gb
    region: sfo1
    image: ubuntu-18-04-x64
    wait_timeout: 500
    ssh_keys: [ .... ]
  register: my_droplet

Issue is the same as in topic
Thanks for support

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

No branches or pull requests

3 participants