Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passwordstore lookup creates subkeys even when create==false and subkey does not exist #9105

Open
1 task done
mluzarreta opened this issue Nov 7, 2024 · 3 comments · May be fixed by #9106
Open
1 task done

Passwordstore lookup creates subkeys even when create==false and subkey does not exist #9105

mluzarreta opened this issue Nov 7, 2024 · 3 comments · May be fixed by #9106
Labels
bug This issue/PR relates to a bug has_pr

Comments

@mluzarreta
Copy link
Contributor

Summary

When using passwordstore lookup to retrieve subkeys, if the subkey is missing, the lookup will create it even if create == false
This bug has been introduced with #8952

Issue Type

Bug Report

Component Name

passwordstore lookup

Ansible Version

$ ansible --version
ansible [core 2.18.0]
  config file = None
  configured module search path = ['/home/manu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.12/site-packages/ansible
  ansible collection location = /home/manu/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.12.7 (main, Oct  1 2024, 11:15:50) [GCC 14.2.1 20240910] (/usr/bin/python)
  jinja version = 3.1.4
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

# /home/manu/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 10.0.0

Configuration

$ ansible-config dump --only-changed
CONFIG_FILE() = None
EDITOR(env: EDITOR) = hx

OS / Environment

Archlinux

Steps to Reproduce

Initial state : a password named example/test already exists but NO subkey

$ pass example/test
.vzaq:,cCvr_Lxeu
lookup_pass: First generated by ansible on 07/11/2024 11:34:53

We try to retrieve a non-existent subkey

ansible -m debug -i localhost, -a "msg={{ lookup('community.general.passwordstore', 'example/test', subkey='foo') }}" localhost

Expected Results

With missing_subkey: empty

ansible -m debug -i localhost, -a "msg={{ lookup('community.general.passwordstore', 'example/test', subkey='foo') }}" localhost
localhost | SUCCESS => {
    "msg": ""
}

Actual Results

Subkey is created even when create == false

ansible -m debug -i localhost, -a "msg={{ lookup('community.general.passwordstore', 'example/test', subkey='foo') }}" localhost
localhost | SUCCESS => {
    "msg": "IJdLJcEoPGJ7dCX1"
}

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
mluzarreta added a commit to mluzarreta/community.general that referenced this issue Nov 7, 2024
@ansibullbot
Copy link
Collaborator

Files identified in the description:

  • lib/ansible/plugins/lookup

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot ansibullbot added the bug This issue/PR relates to a bug label Nov 7, 2024
@felixfontein
Copy link
Collaborator

!component =plugins/lookup/passwordstore.py

@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug has_pr
Projects
None yet
3 participants