-
Notifications
You must be signed in to change notification settings - Fork 341
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
Create droppath option in ssm_parameter.py #1756
Create droppath option in ssm_parameter.py #1756
Conversation
Docs Build 📝Thank you for contribution!✨ This PR has been merged and your docs changes will be incorporated when they are next published. |
Build failed. ❌ ansible-galaxy-importer FAILURE in 3m 56s |
Build failed. ✔️ ansible-galaxy-importer SUCCESS in 8m 48s |
Build succeeded. ✔️ ansible-galaxy-importer SUCCESS in 3m 38s |
Build failed. ✔️ ansible-galaxy-importer SUCCESS in 4m 21s |
Build failed. ✔️ ansible-galaxy-importer SUCCESS in 5m 07s |
Build failed. ✔️ ansible-galaxy-importer SUCCESS in 5m 04s |
Build failed. ✔️ ansible-galaxy-importer SUCCESS in 5m 28s |
Build failed. ✔️ ansible-galaxy-importer SUCCESS in 5m 15s |
Fix indentation
Sorry it's taken so long to review this. I've rebased and fixed up the integration tests. |
Build succeeded. ✔️ ansible-galaxy-importer SUCCESS in 5m 26s |
Build succeeded (gate pipeline). ✔️ ansible-galaxy-importer SUCCESS in 3m 42s |
c535e63
into
ansible-collections:main
Backport to stable-8: 💚 backport PR created✅ Backport PR branch: Backported as #2274 🤖 @patchback |
SUMMARY In the event that there exists two parameters in Parameter Store path/to/params/foo/bar/param and path/to/params/x/y/param, a user attempting to recursively pull all parameters under the path/to/params path with the command {{ lookup('amazon.aws.aws_ssm', '/PATH/to/params', region='ap-southeast-2', shortnames=true, bypath=true, recursive=true ) }}" will be unable to use the shortnames argument without creating a conflict between the two param results. Only one param key will exist in the resulting dictionary. This is problematic for users that wish to lookup a parameter hierarchy with repetitive names in the final value of the parameter path. In this scenario, users are currently forced to use the fully qualified parameter name when interacting with their dictionary results. This pull request introduces the droppath option, which will drop the common lookup path from the names of all parameters. In the scenario above, the resulting dictionary would contain both a foo/bar/param and a /x/y/param allowing users to refer to them by their minimally differentiated name. ISSUE TYPE Feature Pull Request COMPONENT NAME lookup ADDITIONAL INFORMATION Step by step Setup Create parameter path/to/params/foo/bar/param with value abc Create parameter path/to/params/x/y/param with value 123 Run shortnames name: return a dictionary of ssm parameters from a hierarchy path with shortened names (param instead of /PATH/to/param) debug: msg="{{ lookup('amazon.aws.aws_ssm', '/PATH/to/params', region='ap-southeast-2', shortnames=true, bypath=true, recursive=true ) }}" Observe result {'param': '123'} Run droppath name: return a dictionary of ssm parameters from a hierarchy path with shortened names (param instead of /PATH/to/param) debug: msg="{{ lookup('amazon.aws.aws_ssm', '/PATH/to/params', region='ap-southeast-2', droppath=true, bypath=true, recursive=true ) }}" Observe result {'/foo/bar/param': 'abc', '/x/y/param': '123'} Run both name: return a dictionary of ssm parameters from a hierarchy path with shortened names (param instead of /PATH/to/param) debug: msg="{{ lookup('amazon.aws.aws_ssm', '/PATH/to/params', region='ap-southeast-2', droppath=true, shortnames = true, bypath=true, recursive=true ) }}" Observe error shortnames and droppath are mutually exclusive. They cannot both be set to true. Reviewed-by: Mark Chappell (cherry picked from commit c535e63)
This is a backport of PR #1756 as merged into main (c535e63). SUMMARY In the event that there exists two parameters in Parameter Store path/to/params/foo/bar/param and path/to/params/x/y/param, a user attempting to recursively pull all parameters under the path/to/params path with the command {{ lookup('amazon.aws.aws_ssm', '/PATH/to/params', region='ap-southeast-2', shortnames=true, bypath=true, recursive=true ) }}" will be unable to use the shortnames argument without creating a conflict between the two param results. Only one param key will exist in the resulting dictionary. This is problematic for users that wish to lookup a parameter hierarchy with repetitive names in the final value of the parameter path. In this scenario, users are currently forced to use the fully qualified parameter name when interacting with their dictionary results. This pull request introduces the droppath option, which will drop the common lookup path from the names of all parameters. In the scenario above, the resulting dictionary would contain both a foo/bar/param and a /x/y/param allowing users to refer to them by their minimally differentiated name. ISSUE TYPE Feature Pull Request COMPONENT NAME lookup ADDITIONAL INFORMATION Step by step Setup Create parameter path/to/params/foo/bar/param with value abc Create parameter path/to/params/x/y/param with value 123 Run shortnames name: return a dictionary of ssm parameters from a hierarchy path with shortened names (param instead of /PATH/to/param) debug: msg="{{ lookup('amazon.aws.aws_ssm', '/PATH/to/params', region='ap-southeast-2', shortnames=true, bypath=true, recursive=true ) }}" Observe result {'param': '123'} Run droppath name: return a dictionary of ssm parameters from a hierarchy path with shortened names (param instead of /PATH/to/param) debug: msg="{{ lookup('amazon.aws.aws_ssm', '/PATH/to/params', region='ap-southeast-2', droppath=true, bypath=true, recursive=true ) }}" Observe result {'/foo/bar/param': 'abc', '/x/y/param': '123'} Run both name: return a dictionary of ssm parameters from a hierarchy path with shortened names (param instead of /PATH/to/param) debug: msg="{{ lookup('amazon.aws.aws_ssm', '/PATH/to/params', region='ap-southeast-2', droppath=true, shortnames = true, bypath=true, recursive=true ) }}" Observe error shortnames and droppath are mutually exclusive. They cannot both be set to true. Reviewed-by: Mark Chappell
SUMMARY
In the event that there exists two parameters in Parameter Store
path/to/params/foo/bar/param
andpath/to/params/x/y/param
, a user attempting to recursively pull all parameters under thepath/to/params
path with the command{{ lookup('amazon.aws.aws_ssm', '/PATH/to/params', region='ap-southeast-2', shortnames=true, bypath=true, recursive=true ) }}"
will be unable to use theshortnames
argument without creating a conflict between the twoparam
results. Only oneparam
key will exist in the resulting dictionary.This is problematic for users that wish to lookup a parameter hierarchy with repetitive names in the final value of the parameter path. In this scenario, users are currently forced to use the fully qualified parameter name when interacting with their dictionary results.
This pull request introduces the droppath option, which will drop the common lookup path from the names of all parameters. In the scenario above, the resulting dictionary would contain both a
foo/bar/param
and a/x/y/param
allowing users to refer to them by their minimally differentiated name.ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
Step by step
Setup
Run shortnames
debug: msg="{{ lookup('amazon.aws.aws_ssm', '/PATH/to/params', region='ap-southeast-2', shortnames=true, bypath=true, recursive=true ) }}"
{'param': '123'}
Run droppath
debug: msg="{{ lookup('amazon.aws.aws_ssm', '/PATH/to/params', region='ap-southeast-2', droppath=true, bypath=true, recursive=true ) }}"
{'/foo/bar/param': 'abc', '/x/y/param': '123'}
Run both
debug: msg="{{ lookup('amazon.aws.aws_ssm', '/PATH/to/params', region='ap-southeast-2', droppath=true, shortnames = true, bypath=true, recursive=true ) }}"
shortnames and droppath are mutually exclusive. They cannot both be set to true.