diff --git a/changelogs/fragments/5027-fix-returnall-for-gopass.yaml b/changelogs/fragments/5027-fix-returnall-for-gopass.yaml new file mode 100644 index 0000000000..766f87e91a --- /dev/null +++ b/changelogs/fragments/5027-fix-returnall-for-gopass.yaml @@ -0,0 +1,2 @@ +bugfixes: + - passwordstore lookup plugin - fix ``returnall`` for gopass (https://github.com/ansible-collections/community.general/pull/5027). diff --git a/plugins/lookup/passwordstore.py b/plugins/lookup/passwordstore.py index 2f904abdb2..5ead6ce0e3 100644 --- a/plugins/lookup/passwordstore.py +++ b/plugins/lookup/passwordstore.py @@ -261,11 +261,11 @@ class LookupModule(LookupBase): def is_real_pass(self): if self.realpass is None: try: - self.passoutput = to_text( + passoutput = to_text( check_output2([self.pass_cmd, "--version"], env=self.env), errors='surrogate_or_strict' ) - self.realpass = 'pass: the standard unix password manager' in self.passoutput + self.realpass = 'pass: the standard unix password manager' in passoutput except (subprocess.CalledProcessError) as e: raise AnsibleError(e) @@ -331,7 +331,6 @@ class LookupModule(LookupBase): try: self.passoutput = to_text( check_output2([self.pass_cmd, 'show'] + - (['--password'] if self.backend == 'gopass' else []) + [self.passname], env=self.env), errors='surrogate_or_strict' ).splitlines() diff --git a/tests/integration/targets/lookup_passwordstore/tasks/tests.yml b/tests/integration/targets/lookup_passwordstore/tasks/tests.yml index 34899ef5c9..5ac9a948a9 100644 --- a/tests/integration/targets/lookup_passwordstore/tasks/tests.yml +++ b/tests/integration/targets/lookup_passwordstore/tasks/tests.yml @@ -318,9 +318,6 @@ if [ "$1" = "--version" ]; then exit 2 fi - if [ "$1" = "show" ] && [ "$2" != "--password" ]; then - exit 3 - fi echo "gopass_ok" dest: "{{ gopasspath }}" mode: '0755'