From f70dc261ccae79ba1ae303c14eb9bfbc12a5590a Mon Sep 17 00:00:00 2001 From: Alexis Camilleri <7473485+acamilleri@users.noreply.github.com> Date: Fri, 21 Feb 2020 17:14:22 +0100 Subject: [PATCH] fix(scaleway): use jsonify for application/json content-type only (#66957) * fix(scaleway): use jsonify for application/json content-type * add changelog --- .../66957-scaleway-jsonify-only-for-json-requests.yml | 2 ++ lib/ansible/module_utils/scaleway.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/66957-scaleway-jsonify-only-for-json-requests.yml diff --git a/changelogs/fragments/66957-scaleway-jsonify-only-for-json-requests.yml b/changelogs/fragments/66957-scaleway-jsonify-only-for-json-requests.yml new file mode 100644 index 00000000000..99d0306e0bb --- /dev/null +++ b/changelogs/fragments/66957-scaleway-jsonify-only-for-json-requests.yml @@ -0,0 +1,2 @@ +bugfixes: +- 'scaleway: use jsonify unmarshaller only for application/json requests to avoid breaking the multiline configuration with requests in text/plain (https://github.com/ansible/ansible/issues/65036)' diff --git a/lib/ansible/module_utils/scaleway.py b/lib/ansible/module_utils/scaleway.py index d8202976f2c..50041eff529 100644 --- a/lib/ansible/module_utils/scaleway.py +++ b/lib/ansible/module_utils/scaleway.py @@ -118,11 +118,13 @@ class Scaleway(object): def send(self, method, path, data=None, headers=None, params=None): url = self._url_builder(path=path, params=params) self.warn(url) - data = self.module.jsonify(data) if headers is not None: self.headers.update(headers) + if self.headers['Content-Type'] == "application/json": + data = self.module.jsonify(data) + resp, info = fetch_url( self.module, url, data=data, headers=self.headers, method=method, timeout=self.module.params.get('api_timeout')