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_ssm connection - Move connection vars environment handling into options #514

Conversation

dekimsey
Copy link
Contributor

SUMMARY

This fix moves a number of connection related variables to the options parsing step instead of inline. This has the added effect of documenting their existence and making overriding them more consistent with Ansible's UX.

Fixes #343

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

aws_ssm

ADDITIONAL INFORMATION

There were a couple of other minor changes related to logging and silencing curl's progress info outside of the connection vars themselves. I'm happy to pull them out if desired and submit them as a separate PR.

I added fallback on hostnames lookup to match SSH's host handling since that's the defacto connection plugin. This incidentally fixes the way delegation is reported (it didn't show the -> delegated host bit in the logs).
Of note, the ec2.py module sets the instance_id and placement on instances it detects so I added it as first-class fallback for instance_id and region parameters respectively. The get_options parser doesn't handle nested variable lookups, so I had to modify the lookup slightly.

@ansibullbot ansibullbot added bug This issue/PR relates to a bug community_review connection connection plugin needs_triage new_contributor Help guide this first time contributor plugins plugin (any type) labels Mar 30, 2021
Copy link
Collaborator

@jillr jillr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this patch @dekimsey. Could you please add a changelog fragment (https://docs.ansible.com/ansible/latest/community/development_process.html#changelogs-how-to)? It will also need to be rebased to address the git conflict.

@ansibullbot ansibullbot added needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed community_review labels Apr 20, 2021
@tremble tremble changed the title Move connection vars environment handling into options aws_ssm connection - Move connection vars environment handling into options Oct 23, 2021
@gillg
Copy link

gillg commented Jan 9, 2022

In my opinion this PR mix too much things, and use native AWS sdk in documentation is probably a bad idea. Ansible should use it's own variable to avoid scope conflicts. As exemple, we can imagine having different credentials for SSM connection and the bucket used for file transfers.

Anyway, some vars are already used in this SSM plugin so this PR can be probably abandoned in the current state from march.

@gillg
Copy link

gillg commented Jan 9, 2022

My bad, I missunderstood some changes. Most of them are very useful.
What about I'm not fan is officialize usage of native AWS SDK vars.
Anyone else has an opinion ?

plugins/connection/aws_ssm.py Outdated Show resolved Hide resolved
@tremble tremble force-pushed the 343-fix-connection-vars-handling branch from feda6f9 to 3bf7bcf Compare January 20, 2023 19:20
@github-actions
Copy link

github-actions bot commented Jan 20, 2023

Docs Build 📝

Thank you for contribution!✨

This PR has been merged and your docs changes will be incorporated when they are next published.

@ansibullbot ansibullbot added community_review and removed needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Jan 20, 2023
@softwarefactory-project-zuul

This comment was marked as resolved.

@tremble tremble force-pushed the 343-fix-connection-vars-handling branch from 3bf7bcf to 7aace6d Compare January 31, 2023 11:21
@tremble
Copy link
Contributor

tremble commented Jan 31, 2023

Many thanks for taking the time to submit this PR.

Sorry for the delay getting this merged. I've rebased this PR and pruned it right back to "Just what it says on the tin". Including not trying to get clever with "placement".

While it's true that this is re-using the AWS environment variables, that's what the module's always done (and what we usually do), and I don't think dropping those variables would be a good idea.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

✔️ ansible-galaxy-importer SUCCESS in 3m 55s
✔️ build-ansible-collection SUCCESS in 5m 24s
✔️ ansible-test-sanity-docker-devel SUCCESS in 8m 45s (non-voting)
✔️ ansible-test-sanity-docker-milestone SUCCESS in 8m 57s (non-voting)
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 8m 58s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 9m 51s
✔️ ansible-test-sanity-docker-stable-2.14 SUCCESS in 9m 32s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 7m 04s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 5m 47s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 5m 35s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 6m 03s
✔️ ansible-test-changelog SUCCESS in 2m 14s
✔️ ansible-test-splitter SUCCESS in 2m 44s
✔️ integration-community.aws-1 SUCCESS in 9m 19s
✔️ integration-community.aws-2 SUCCESS in 8m 05s
✔️ integration-community.aws-3 SUCCESS in 9m 02s
✔️ integration-community.aws-4 SUCCESS in 9m 01s
✔️ integration-community.aws-5 SUCCESS in 10m 00s
✔️ integration-community.aws-6 SUCCESS in 10m 05s
✔️ integration-community.aws-7 SUCCESS in 9m 13s
✔️ integration-community.aws-8 SUCCESS in 9m 40s
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED
⚠️ integration-community.aws-14 SKIPPED
⚠️ integration-community.aws-15 SKIPPED
⚠️ integration-community.aws-16 SKIPPED
⚠️ integration-community.aws-17 SKIPPED
⚠️ integration-community.aws-18 SKIPPED
⚠️ integration-community.aws-19 SKIPPED
⚠️ integration-community.aws-20 SKIPPED
⚠️ integration-community.aws-21 SKIPPED
⚠️ integration-community.aws-22 SKIPPED

@tremble tremble added mergeit Merge the PR (SoftwareFactory) backport-5 PR should be backported to the stable-5 branch labels Jan 31, 2023
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).

✔️ ansible-galaxy-importer SUCCESS in 5m 21s
✔️ build-ansible-collection SUCCESS in 5m 35s
✔️ ansible-test-sanity-docker-devel SUCCESS in 10m 12s (non-voting)
✔️ ansible-test-sanity-docker-milestone SUCCESS in 12m 43s (non-voting)
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 12m 35s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 12m 31s
✔️ ansible-test-sanity-docker-stable-2.14 SUCCESS in 11m 47s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 6m 31s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 5m 52s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 04s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 7m 06s
✔️ ansible-test-changelog SUCCESS in 2m 20s
✔️ ansible-test-splitter SUCCESS in 2m 31s
✔️ integration-community.aws-1 SUCCESS in 10m 35s
✔️ integration-community.aws-2 SUCCESS in 7m 29s
✔️ integration-community.aws-3 SUCCESS in 9m 23s
✔️ integration-community.aws-4 SUCCESS in 8m 46s
✔️ integration-community.aws-5 SUCCESS in 9m 03s
✔️ integration-community.aws-6 SUCCESS in 8m 25s
✔️ integration-community.aws-7 SUCCESS in 7m 52s
✔️ integration-community.aws-8 SUCCESS in 9m 13s
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED
⚠️ integration-community.aws-14 SKIPPED
⚠️ integration-community.aws-15 SKIPPED
⚠️ integration-community.aws-16 SKIPPED
⚠️ integration-community.aws-17 SKIPPED
⚠️ integration-community.aws-18 SKIPPED
⚠️ integration-community.aws-19 SKIPPED
⚠️ integration-community.aws-20 SKIPPED
⚠️ integration-community.aws-21 SKIPPED
⚠️ integration-community.aws-22 SKIPPED

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit 94d1295 into ansible-collections:main Jan 31, 2023
@patchback
Copy link

patchback bot commented Jan 31, 2023

Backport to stable-5: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-5/94d12952f12188940f759454032e870890191086/pr-514

Backported as #1683

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Jan 31, 2023
aws_ssm connection - Move connection vars environment handling into options

SUMMARY
This fix moves a number of connection related variables to the options parsing step instead of inline. This has the added effect of documenting their existence and making overriding them more consistent with Ansible's UX.
Fixes #343
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
aws_ssm
ADDITIONAL INFORMATION

There were a couple of other minor changes related to logging and silencing curl's progress info outside of the connection vars themselves. I'm happy to pull them out if desired and submit them as a separate PR.
I added fallback on hostnames lookup to match SSH's host handling since that's the defacto connection plugin. This incidentally fixes the way delegation is reported (it didn't show the -> delegated host bit in the logs).
Of note, the ec2.py module sets the instance_id and placement on instances it detects so I added it as first-class fallback for instance_id and region parameters respectively. The get_options parser doesn't handle nested variable lookups, so I had to modify the lookup slightly.

Reviewed-by: Jill R <None>
Reviewed-by: Guillaume GILL <None>
Reviewed-by: Mark Chappell <None>
(cherry picked from commit 94d1295)
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Jan 31, 2023
)

[PR #514/94d12952 backport][stable-5] aws_ssm connection - Move connection vars environment handling into options

This is a backport of PR #514 as merged into main (94d1295).
SUMMARY
This fix moves a number of connection related variables to the options parsing step instead of inline. This has the added effect of documenting their existence and making overriding them more consistent with Ansible's UX.
Fixes #343
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME
aws_ssm
ADDITIONAL INFORMATION


There were a couple of other minor changes related to logging and silencing curl's progress info outside of the connection vars themselves. I'm happy to pull them out if desired and submit them as a separate PR.
I added fallback on hostnames lookup to match SSH's host handling since that's the defacto connection plugin. This incidentally fixes the way delegation is reported (it didn't show the -> delegated host bit in the logs).
Of note, the ec2.py module sets the instance_id and placement on instances it detects so I added it as first-class fallback for instance_id and region parameters respectively. The get_options parser doesn't handle nested variable lookups, so I had to modify the lookup slightly.

Reviewed-by: Mark Chappell <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-5 PR should be backported to the stable-5 branch bug This issue/PR relates to a bug community_review connection connection plugin mergeit Merge the PR (SoftwareFactory) new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot connect to ec2 instance via aws_ssm if AWS_SESSION_TOKEN is missing
6 participants