diff --git a/changelogs/fragments/8689-passwordstore-lock-naming.yml b/changelogs/fragments/8689-passwordstore-lock-naming.yml new file mode 100644 index 0000000000..c5c9a82d78 --- /dev/null +++ b/changelogs/fragments/8689-passwordstore-lock-naming.yml @@ -0,0 +1,2 @@ +minor_changes: + - passwordstore lookup plugin - add the current user to the lockfile file name to address issues on multi-user systems (https://github.com/ansible-collections/community.general/pull/8689). diff --git a/plugins/lookup/passwordstore.py b/plugins/lookup/passwordstore.py index 9814fe133b..ff1352e1e4 100644 --- a/plugins/lookup/passwordstore.py +++ b/plugins/lookup/passwordstore.py @@ -468,7 +468,8 @@ class LookupModule(LookupBase): def opt_lock(self, type): if self.get_option('lock') == type: tmpdir = os.environ.get('TMPDIR', '/tmp') - lockfile = os.path.join(tmpdir, '.passwordstore.lock') + user = os.environ.get('USER') + lockfile = os.path.join(tmpdir, '.{0}.passwordstore.lock'.format(user)) with FileLock().lock_file(lockfile, tmpdir, self.lock_timeout): self.locked = type yield