From 9ff8d8d898d4ed16e770d22041c7b0a99e87925d Mon Sep 17 00:00:00 2001 From: Mark Chesney Date: Tue, 3 Sep 2019 23:28:56 -0700 Subject: [PATCH] Fix creation of DigitalOcean droplets using digital_ocean_droplet module (#61655) * Omit disallowed 'id' attribute in request body to create a droplet * Add changelog fragment for PR #61655 --- .../fragments/61655-fix-digital-ocean-droplet-create.yaml | 2 ++ .../modules/cloud/digital_ocean/digital_ocean_droplet.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/61655-fix-digital-ocean-droplet-create.yaml diff --git a/changelogs/fragments/61655-fix-digital-ocean-droplet-create.yaml b/changelogs/fragments/61655-fix-digital-ocean-droplet-create.yaml new file mode 100644 index 00000000000..d1043be8fea --- /dev/null +++ b/changelogs/fragments/61655-fix-digital-ocean-droplet-create.yaml @@ -0,0 +1,2 @@ +bugfixes: + - digital_ocean_droplet - Fix creation of DigitalOcean droplets using digital_ocean_droplet module (https://github.com/ansible/ansible/pull/61655) diff --git a/lib/ansible/modules/cloud/digital_ocean/digital_ocean_droplet.py b/lib/ansible/modules/cloud/digital_ocean/digital_ocean_droplet.py index 743cb4ecdae..01c583e3c17 100644 --- a/lib/ansible/modules/cloud/digital_ocean/digital_ocean_droplet.py +++ b/lib/ansible/modules/cloud/digital_ocean/digital_ocean_droplet.py @@ -252,7 +252,9 @@ class DODroplet(object): self.module.exit_json(changed=False, data=droplet_data) if self.module.check_mode: self.module.exit_json(changed=True) - response = self.rest.post('droplets', data=self.module.params) + request_params = dict(self.module.params) + del request_params['id'] + response = self.rest.post('droplets', data=request_params) json_data = response.json if response.status_code >= 400: self.module.fail_json(changed=False, msg=json_data['message'])