community.digitalocean icon indicating copy to clipboard operation
community.digitalocean copied to clipboard

Droplet `project_name` not working

Open mamercad opened this issue 2 years ago • 1 comments

@mamercad Thank you for your quick response! When using project_name as documented in https://docs.ansible.com/ansible/latest/collections/community/digitalocean/digital_ocean_droplet_module.html#parameter-project_name - my droplets wind up in my default project, not the specified project. But if I use the project alias like in your example, then it works! The droplets wind up in the specified project.

(sorry for deleting and reposting this comment - I thought I had gotten things mixed up, misinterpreting the results. But looks like it really is working)

@dschilling No problem; though, I'm perplexed on why this doesn't work. I'll have to dig into that a bit at some point.

Originally posted by @mamercad in https://github.com/ansible-collections/community.digitalocean/issues/201#issuecomment-1124360015

mamercad avatar May 11 '22 23:05 mamercad

I've reproduced this; using project works, using project_name does not (Droplet ended up in the default project).

mamercad avatar May 11 '22 23:05 mamercad

I bumped into this issue, but I noticed that the problem for me was with project names containing underscores: in that case the droplet would be created in the default project.

Here's a small reproducible code, that also creates the project defined in the variable.

---
- hosts: localhost
  connection: local
  gather_facts: false

  vars:
#    project_name: test-project
    project_name: test_project

  tasks:
    - name: Create a new separate project from the default
      community.digitalocean.digital_ocean_project:
        name: "{{ project_name }}"
        state: present
        oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}"
        description: "This project is a test"
        purpose: "Operational/Developer tooling"
        environment: "Production"

    - name: 'Create a DigitalOcean Droplet'
      community.digitalocean.digital_ocean_droplet:
        oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}"
        name: nodename
        project_name: "{{ project_name }}"
        state: present
        size: s-1vcpu-1gb
        image: ubuntu-22-04-x64
        region: sfo3

bebosudo avatar Oct 23 '22 07:10 bebosudo