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

aws_secret lookup doesn't honor on_missing when using nested #1781

Closed
1 task done
gionn opened this issue Sep 29, 2023 · 1 comment · Fixed by #1972
Closed
1 task done

aws_secret lookup doesn't honor on_missing when using nested #1781

gionn opened this issue Sep 29, 2023 · 1 comment · Fixed by #1972
Labels
bug This issue/PR relates to a bug needs_info This issue requires further information. Please answer any outstanding questions

Comments

@gionn
Copy link
Contributor

gionn commented Sep 29, 2023

Summary

I am using multiple lookup calls to populate secret variables from a single AWS secret containing multiple (nested) secrets, however it seems that on_missing applies only to the aws secret itself while I was hoping to get the same behaviour only when the nested key is missing inside the aws secret.

Issue Type

Bug Report

Component Name

amazon.aws.aws_secret

Ansible Version

$ ansible --version
ansible [core 2.14.4]
  config file = /Users/Giovanni.Toraldo/src/alfresco/alfresco-ansible-deployment/ansible.cfg
  configured module search path = ['/Users/Giovanni.Toraldo/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/Giovanni.Toraldo/.virtualenvs/alfresco-ansible-deployment-LdMEq9P-/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/Giovanni.Toraldo/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/Giovanni.Toraldo/.virtualenvs/alfresco-ansible-deployment-LdMEq9P-/bin/ansible
  python version = 3.10.12 (main, Jul 28 2023, 18:44:44) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/Users/Giovanni.Toraldo/.virtualenvs/alfresco-ansible-deployment-LdMEq9P-/bin/python)
  jinja version = 3.1.2
  libyaml = True

Collection Versions

$ ansible-galaxy collection list
Collection                     Version
------------------------------ -------
amazon.aws                     6.3.0  
ansible.posix                  1.5.4  
ansible.utils                  2.6.0  
community.aws                  6.3.0  
community.crypto               2.10.0 
community.docker               3.4.8  
community.general              7.4.0  
community.postgresql           2.1.0  
middleware_automation.common   1.1.2  
middleware_automation.keycloak 1.3.0  

AWS SDK versions

$ pip show boto boto3 botocore
WARNING: Package(s) not found: boto
Name: boto3
Version: 1.26.9
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email: 
License: Apache License 2.0
Location: /Users/Giovanni.Toraldo/.virtualenvs/alfresco-ansible-deployment-LdMEq9P-/lib/python3.10/site-packages
Requires: botocore, jmespath, s3transfer
Required-by: 
---
Name: botocore
Version: 1.29.165
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email: 
License: Apache License 2.0
Location: /Users/Giovanni.Toraldo/.virtualenvs/alfresco-ansible-deployment-LdMEq9P-/lib/python3.10/site-packages
Requires: jmespath, python-dateutil, urllib3
Required-by: boto3, s3transfer

Configuration

$ ansible-config dump --only-changed

OS / Environment

Ubuntu

Steps to Reproduce

sync_db_password: "{{ lookup('amazon.aws.aws_secret', user_provided_project_name + '.sync_db_password', on_missing='warn', nested=true) }}"
identity_admin_password: "{{ lookup('amazon.aws.aws_secret', user_provided_project_name + '.identity_admin_password', on_missing='warn', nested=true) }}"

Expected Results

Expecting just a warning if the secret exists but doesn't contain identity_admin_password

Actual Results

fatal: [localhost]: FAILED! => {"msg": "An unhandled exception occurred while templating '{'sync_db_password': \"{{ lookup('amazon.aws.aws_secret', user_provided_project_name + '.sync_db_password', on_missing='warn', nested=true) }}\", 'identity_admin_password': \"{{ lookup('amazon.aws.aws_secret', user_provided_project_name + '.identity_admin_password', on_missing='warn', nested=true) }}\"}'. Error was a <class 'ansible.errors.AnsibleLookupError'>, original message: Successfully retrieved secret but there exists no key identity_admin_password in the secret"}

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@hakbailey hakbailey added needs_verified Some one might want to take a look at this and reproduce it to confirm and removed needs_triage labels Oct 3, 2023
abikouo pushed a commit to abikouo/amazon.aws that referenced this issue Oct 24, 2023
…nsible-collections#1773) (ansible-collections#1781)

eks_nodegroup - fixing remote access and added to integration tests

SUMMARY
This was incorrectly merged directly into stable-5 rather than main.
Fixes ansible-collections#1771
Handling remote_access configuration the right way that boto understands it. Also included it to integration tests.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
eks_nodegroup
ADDITIONAL INFORMATION
This is pulling ansible-collections#1773 from stable-5 into main
Reviewed-by: Markus Bergholz
Reviewed-by: Thomas Bruckmann
Reviewed-by: Mark Chappell

Reviewed-by: Markus Bergholz <git@osuv.de>
@abikouo abikouo added bug This issue/PR relates to a bug and removed needs_verified Some one might want to take a look at this and reproduce it to confirm labels Feb 12, 2024
@abikouo
Copy link
Contributor

abikouo commented Feb 12, 2024

@gionn Thanks for raising the issue, I have created a Pull request to fix it. Could you please give a try with #1972
Thanks

@abikouo abikouo added the needs_info This issue requires further information. Please answer any outstanding questions label Feb 12, 2024
softwarefactory-project-zuul bot pushed a commit that referenced this issue Feb 14, 2024
…nd on_missing=warn (#1972)

lookup/secretsmanager_secret - fix issue with missing nested secret and on_missing=warn

SUMMARY

Fixes #1781
The lookup was raising an error instead of a warning message

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

lookup/secretsmanager_secret

Reviewed-by: Mandar Kulkarni <mandar242@gmail.com>
Reviewed-by: Alina Buzachis
patchback bot pushed a commit that referenced this issue Feb 14, 2024
…nd on_missing=warn (#1972)

lookup/secretsmanager_secret - fix issue with missing nested secret and on_missing=warn

SUMMARY

Fixes #1781
The lookup was raising an error instead of a warning message

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

lookup/secretsmanager_secret

Reviewed-by: Mandar Kulkarni <mandar242@gmail.com>
Reviewed-by: Alina Buzachis
(cherry picked from commit 08e7d70)
patchback bot pushed a commit that referenced this issue Feb 14, 2024
…nd on_missing=warn (#1972)

lookup/secretsmanager_secret - fix issue with missing nested secret and on_missing=warn

SUMMARY

Fixes #1781
The lookup was raising an error instead of a warning message

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

lookup/secretsmanager_secret

Reviewed-by: Mandar Kulkarni <mandar242@gmail.com>
Reviewed-by: Alina Buzachis
(cherry picked from commit 08e7d70)
softwarefactory-project-zuul bot pushed a commit that referenced this issue Feb 28, 2024
…nd on_missing=warn (#1972) (#1975)

[PR #1972/08e7d700 backport][stable-7] lookup/secretsmanager_secret - fix issue with missing nested secret and on_missing=warn

This is a backport of PR #1972 as merged into main (08e7d70).
SUMMARY

Fixes #1781
The lookup was raising an error instead of a warning message

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

lookup/secretsmanager_secret

Reviewed-by: Alina Buzachis
Reviewed-by: Mark Chappell
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this issue Mar 1, 2024
…nd on_missing=warn (ansible-collections#1972)

lookup/secretsmanager_secret - fix issue with missing nested secret and on_missing=warn

SUMMARY

Fixes ansible-collections#1781
The lookup was raising an error instead of a warning message

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

lookup/secretsmanager_secret

Reviewed-by: Mandar Kulkarni <mandar242@gmail.com>
Reviewed-by: Alina Buzachis
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 needs_info This issue requires further information. Please answer any outstanding questions
Projects
None yet
3 participants