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
This commit is contained in:
Mark Chesney 2019-09-03 23:28:56 -07:00 committed by ansibot
parent 3f9316bca2
commit 01f4081b66
2 changed files with 5 additions and 1 deletions

View file

@ -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)

View file

@ -252,7 +252,9 @@ class DODroplet(object):
self.module.exit_json(changed=False, data=droplet_data) self.module.exit_json(changed=False, data=droplet_data)
if self.module.check_mode: if self.module.check_mode:
self.module.exit_json(changed=True) 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 json_data = response.json
if response.status_code >= 400: if response.status_code >= 400:
self.module.fail_json(changed=False, msg=json_data['message']) self.module.fail_json(changed=False, msg=json_data['message'])