From 116a5048252cc0e8d762e669b00d1aae25dd48ac Mon Sep 17 00:00:00 2001 From: Benoit Dunand-Laisin Date: Fri, 25 May 2018 16:09:17 +0200 Subject: [PATCH] Fixes #24241 Module always updates installed plugins (#40645) * Update jenkins_plugin.py When setting state=latest, plugin are always updated because old sha1 is bytes and and is compared to new sha1 which is str (so it always detecting a sha1 change) * Add changelog --- changelogs/fragments/40645-jenkins_plugin.yaml | 2 ++ lib/ansible/modules/web_infrastructure/jenkins_plugin.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/40645-jenkins_plugin.yaml diff --git a/changelogs/fragments/40645-jenkins_plugin.yaml b/changelogs/fragments/40645-jenkins_plugin.yaml new file mode 100644 index 00000000000..5abb724b1e5 --- /dev/null +++ b/changelogs/fragments/40645-jenkins_plugin.yaml @@ -0,0 +1,2 @@ +bugfixes: +- jenkins_plugin: fix plugin always updated even if already uptodate (https://github.com/ansible/ansible/pull/40645) diff --git a/lib/ansible/modules/web_infrastructure/jenkins_plugin.py b/lib/ansible/modules/web_infrastructure/jenkins_plugin.py index 869331b43ef..9ffd04b98af 100644 --- a/lib/ansible/modules/web_infrastructure/jenkins_plugin.py +++ b/lib/ansible/modules/web_infrastructure/jenkins_plugin.py @@ -275,7 +275,7 @@ state: sample: "present" ''' -from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.basic import AnsibleModule, to_bytes from ansible.module_utils.six.moves.urllib.parse import urlencode from ansible.module_utils.urls import fetch_url, url_argument_spec from ansible.module_utils._text import to_native @@ -505,7 +505,7 @@ class JenkinsPlugin(object): sha1sum_old = base64.b64encode(sha1_old.digest()) # If the latest version changed, download it - if sha1sum_old != plugin_data['sha1']: + if sha1sum_old != to_bytes(plugin_data['sha1']): if not self.module.check_mode: r = self._download_plugin(plugin_url) self._write_file(plugin_file, r)