From 325ee46393b8286bd25b7f5ed2ef3fc7b5f370b7 Mon Sep 17 00:00:00 2001 From: Manuel Luzarreta Date: Thu, 7 Nov 2024 11:54:45 +0100 Subject: [PATCH 1/2] bugfix - Prevent passwordstore lookup to create subkey when create == false Fixes#9105 --- ...dstore-fix-subkey-creation-even-when-create-==-false.yml | 2 ++ plugins/lookup/passwordstore.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/9106-passwordstore-fix-subkey-creation-even-when-create-==-false.yml diff --git a/changelogs/fragments/9106-passwordstore-fix-subkey-creation-even-when-create-==-false.yml b/changelogs/fragments/9106-passwordstore-fix-subkey-creation-even-when-create-==-false.yml new file mode 100644 index 00000000000..2b0f62d6160 --- /dev/null +++ b/changelogs/fragments/9106-passwordstore-fix-subkey-creation-even-when-create-==-false.yml @@ -0,0 +1,2 @@ +bugfixes: + - passwordstore lookup plugin - Fix subkey creation even when `create == false` (https://github.com/ansible-collections/community.general/pull/9106). diff --git a/plugins/lookup/passwordstore.py b/plugins/lookup/passwordstore.py index f35d268995a..00472213ad4 100644 --- a/plugins/lookup/passwordstore.py +++ b/plugins/lookup/passwordstore.py @@ -582,9 +582,9 @@ def run(self, terms, variables, **kwargs): if self.paramvals['overwrite']: with self.opt_lock('write'): result.append(self.update_password()) - elif self.paramvals["subkey"] != "password" and not self.passdict.get(self.paramvals['subkey']): # password exists but not the subkey - with self.opt_lock('write'): - result.append(self.update_password()) + if self.paramvals["subkey"] != "password" and not self.passdict.get(self.paramvals['subkey']): # password exists but not the subkey + with self.opt_lock('write'): + result.append(self.update_password()) else: result.append(self.get_passresult()) else: # password does not exist From b1511bf0bb976c373c36a841f48256258b8cbf22 Mon Sep 17 00:00:00 2001 From: Manuel Luzarreta Date: Fri, 8 Nov 2024 16:43:57 +0100 Subject: [PATCH 2/2] Update changelogs/fragments/9106-passwordstore-fix-subkey-creation-even-when-create-==-false.yml Co-authored-by: Felix Fontein --- ...swordstore-fix-subkey-creation-even-when-create-==-false.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/9106-passwordstore-fix-subkey-creation-even-when-create-==-false.yml b/changelogs/fragments/9106-passwordstore-fix-subkey-creation-even-when-create-==-false.yml index 2b0f62d6160..a51f190c217 100644 --- a/changelogs/fragments/9106-passwordstore-fix-subkey-creation-even-when-create-==-false.yml +++ b/changelogs/fragments/9106-passwordstore-fix-subkey-creation-even-when-create-==-false.yml @@ -1,2 +1,2 @@ bugfixes: - - passwordstore lookup plugin - Fix subkey creation even when `create == false` (https://github.com/ansible-collections/community.general/pull/9106). + - passwordstore lookup plugin - fix subkey creation even when ``create`` is ``false`` (https://github.com/ansible-collections/community.general/pull/9106).