diff --git a/changelogs/fragments/1589-passwordstore-fix-passwordstore.py-to-be-compatible-with-gopass.yaml b/changelogs/fragments/1589-passwordstore-fix-passwordstore.py-to-be-compatible-with-gopass.yaml new file mode 100644 index 0000000000..8a781f4a90 --- /dev/null +++ b/changelogs/fragments/1589-passwordstore-fix-passwordstore.py-to-be-compatible-with-gopass.yaml @@ -0,0 +1,5 @@ +bugfixes: + - passwordstore lookup plugin - fix compatibility with gopass when used with + ``create=true``. While pass returns 1 on a non-existent password, gopass + returns 10, or 11, depending on whether a similar named password was stored. + We now just check standard output and that the return code is not zero (https://github.com/ansible-collections/community.general/pull/1589). diff --git a/plugins/lookup/passwordstore.py b/plugins/lookup/passwordstore.py index e3d486886c..4d0f646125 100644 --- a/plugins/lookup/passwordstore.py +++ b/plugins/lookup/passwordstore.py @@ -214,7 +214,7 @@ class LookupModule(LookupBase): name, value = line.split(':', 1) self.passdict[name.strip()] = value.strip() except (subprocess.CalledProcessError) as e: - if e.returncode == 1 and 'not in the password store' in e.output: + if e.returncode != 0 and 'not in the password store' in e.output: # if pass returns 1 and return string contains 'is not in the password store.' # We need to determine if this is valid or Error. if not self.paramvals['create']: