ansible-collections / community.digitalocean

This Ansible collection contains modules for assisting in the automation of the DigitalOcean cloud.
https://galaxy.ansible.com/community/digitalocean/
GNU General Public License v3.0
141 stars 57 forks source link

Firewall not set to new droplet #202

Open habibimustafa opened 2 years ago

habibimustafa commented 2 years ago
SUMMARY

When creating a new droplet with a firewall configuration, the new droplet still doesn't have a firewall.

ISSUE TYPE
COMPONENT NAME

community.digitalocean.digital_ocean_droplet

ANSIBLE VERSION
ansible 2.10.7
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/myusername/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/myusername/.local/lib/python3.9/site-packages/ansible
  executable location = /home/myusername/.local/bin/ansible
  python version = 3.9.7 (default, Aug 31 2021, 13:28:12) [GCC 11.1.0]
COLLECTION VERSION
Collection             Version
---------------------- -------
community.digitalocean 1.13.0 
CONFIGURATION
COLLECTIONS_PATHS(/etc/ansible/ansible.cfg) = ['/home/myusername/.ansible/collections', '/usr/share/ansible/collections']
OS / ENVIRONMENT
Operating System: Manjaro Linux 21.1.6 Pahvo                   
Kernel: Linux 5.13.19-2-MANJARO
STEPS TO REPRODUCE
---
- hosts: local
  become: true

  vars:
    my_token: ...

  tasks:
    - name: 'Create a DigitalOcean Droplet'
      community.digitalocean.digital_ocean_droplet:
        oauth_token: "{{ my_token }}"        
        name: node-name-1
        state: present
        size: s-1vcpu-1gb
        image: ubuntu-18-04-x64
        region: sgp1
        firewall:
          - web-server-fw
ansible-playbook -vv project.yml
EXPECTED RESULTS

a new droplet with 'web-server-fw' firewall created

ACTUAL RESULTS

a new droplet without any firewall created

danxg87 commented 2 years ago

Taking a look into this now; it seems the get_droplet() func was the issue at first glance/running some debugging. It was only going to work if unique_name was true. I will fix this and make sure I have ample tests around this so we no longer have that gap. TYVM for bringing this up!

byoung0589 commented 2 years ago

Ran into this issue on 1.19.0, would be nice to have this fixed. Playbook registers as failed when you specify a firewall for a new droplet even though the droplet creation succeeds.