diff --git a/changelogs/fragments/326-project-name-param.yaml b/changelogs/fragments/326-project-name-param.yaml new file mode 100644 index 00000000..aecbd974 --- /dev/null +++ b/changelogs/fragments/326-project-name-param.yaml @@ -0,0 +1,5 @@ +bugfixes: + - The C(project_name) parameter for many modules was used by alias C(project) internally in the + codebase, but to work properly C(project_name) must be used in the code. Replace + self.module.params.get("project") with self.module.params.get("project_name") + (https://github.com/ansible-collections/community.digitalocean/issues/326). \ No newline at end of file diff --git a/plugins/modules/digital_ocean_block_storage.py b/plugins/modules/digital_ocean_block_storage.py index 8597eb1e..58bc546f 100644 --- a/plugins/modules/digital_ocean_block_storage.py +++ b/plugins/modules/digital_ocean_block_storage.py @@ -182,7 +182,7 @@ class DOBlockStorage(object): def __init__(self, module): self.module = module self.rest = DigitalOceanHelper(module) - if self.module.params.get("project"): + if self.module.params.get("project_name"): # only load for non-default project assignments self.projects = DigitalOceanProjects(module, self.rest) @@ -295,7 +295,7 @@ def create_block_storage(self): status = response.status_code json = response.json if status == 201: - project_name = self.module.params.get("project") + project_name = self.module.params.get("project_name") if ( project_name ): # empty string is the default project, skip project assignment diff --git a/plugins/modules/digital_ocean_database.py b/plugins/modules/digital_ocean_database.py index cfcecbff..9fc03527 100644 --- a/plugins/modules/digital_ocean_database.py +++ b/plugins/modules/digital_ocean_database.py @@ -208,7 +208,7 @@ class DODatabase(object): def __init__(self, module): self.module = module self.rest = DigitalOceanHelper(module) - if self.module.params.get("project"): + if self.module.params.get("project_name"): # only load for non-default project assignments self.projects = DigitalOceanProjects(module, self.rest) # pop wait and wait_timeout so we don't include it in the POST data @@ -335,7 +335,7 @@ def create(self): if self.wait: json_data = self.ensure_online(database_id) - project_name = self.module.params.get("project") + project_name = self.module.params.get("project_name") if project_name: # empty string is the default project, skip project assignment urn = "do:dbaas:{0}".format(database_id) assign_status, error_message, resources = self.projects.assign_to_project( diff --git a/plugins/modules/digital_ocean_domain.py b/plugins/modules/digital_ocean_domain.py index d7003a4c..502420df 100644 --- a/plugins/modules/digital_ocean_domain.py +++ b/plugins/modules/digital_ocean_domain.py @@ -192,7 +192,7 @@ def run(module): do_manager = DoManager(module) state = module.params.get("state") - if module.params.get("project"): + if module.params.get("project_name"): # only load for non-default project assignments projects = DigitalOceanProjects(module, do_manager) @@ -214,7 +214,7 @@ def run(module): # few times before giving up and returning null. domain_name = module.params.get("name") - project_name = module.params.get("project") + project_name = module.params.get("project_name") urn = "do:domain:{0}".format(domain_name) for i in range(ZONE_FILE_ATTEMPTS): diff --git a/plugins/modules/digital_ocean_droplet.py b/plugins/modules/digital_ocean_droplet.py index fff079c6..495aca7b 100644 --- a/plugins/modules/digital_ocean_droplet.py +++ b/plugins/modules/digital_ocean_droplet.py @@ -319,7 +319,7 @@ def __init__(self, module): self.name = None self.size = None self.status = None - if self.module.params.get("project"): + if self.module.params.get("project_name"): # only load for non-default project assignments self.projects = DigitalOceanProjects(module, self.rest) self.firewalls = self.get_firewalls() @@ -779,7 +779,7 @@ def create(self, state): if json_data: droplet = json_data.get("droplet", droplet) - project_name = self.module.params.get("project") + project_name = self.module.params.get("project_name") if project_name: # empty string is the default project, skip project assignment urn = "do:droplet:{0}".format(droplet_id) assign_status, error_message, resources = self.projects.assign_to_project( diff --git a/plugins/modules/digital_ocean_floating_ip.py b/plugins/modules/digital_ocean_floating_ip.py index d4d6ff26..ed84d284 100644 --- a/plugins/modules/digital_ocean_floating_ip.py +++ b/plugins/modules/digital_ocean_floating_ip.py @@ -435,11 +435,11 @@ def create_floating_ips(module, rest): json_data = response.json if status_code == 202: if module.params.get( - "project" + "project_name" ): # only load for non-default project assignments rest = DigitalOceanHelper(module) projects = DigitalOceanProjects(module, rest) - project_name = module.params.get("project") + project_name = module.params.get("project_name") if ( project_name ): # empty string is the default project, skip project assignment diff --git a/plugins/modules/digital_ocean_load_balancer.py b/plugins/modules/digital_ocean_load_balancer.py index c49ae444..d0da6f7d 100644 --- a/plugins/modules/digital_ocean_load_balancer.py +++ b/plugins/modules/digital_ocean_load_balancer.py @@ -467,7 +467,7 @@ def __init__(self, module): self.module.params.pop("oauth_token") self.wait = self.module.params.pop("wait", True) self.wait_timeout = self.module.params.pop("wait_timeout", 600) - if self.module.params.get("project"): + if self.module.params.get("project_name"): # only load for non-default project assignments self.projects = DigitalOceanProjects(module, self.rest) @@ -716,7 +716,7 @@ def create(self): if self.wait: self.ensure_active() - project_name = self.module.params.get("project") + project_name = self.module.params.get("project_name") if project_name: # empty string is the default project, skip project assignment urn = "do:loadbalancer:{0}".format(self.id) (