-
Notifications
You must be signed in to change notification settings - Fork 328
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
ec2_metadata_facts - Handle decompression when EC2 instance user-data is compressed #1575
ec2_metadata_facts - Handle decompression when EC2 instance user-data is compressed #1575
Conversation
…od from ansible.module_utils.urls does not decompress the user-data unless the header explicitly contains 'Content-Encoding' = 'gzip'. Signed-off-by: Alina Buzachis <abuzachis@redhat.com>
af14a87
to
8ac8799
Compare
c5dacef
to
275bcb4
Compare
Signed-off-by: Alina Buzachis <abuzachis@redhat.com>
275bcb4
to
5c13b0a
Compare
try: | ||
if is_compressed: | ||
# Data is compressed, attempt decompression and decode using UTF-8 | ||
decoded_data = zlib.decompress(data, zlib.MAX_WBITS | 32).decode("utf-8") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the decompression succeeds, but the decoding fails with a UnicodeDecodeError
, then the except UnicodeDecodeError
block is going to fail because it will try to decode compressed data. The easiest way to handle this is probably with two try/except blocks, one to decompress the data, and the other to decode it.
Build succeeded. ✔️ ansible-galaxy-importer SUCCESS in 4m 10s |
Signed-off-by: Alina Buzachis <abuzachis@redhat.com>
Build succeeded. ✔️ ansible-galaxy-importer SUCCESS in 3m 38s |
Signed-off-by: Alina Buzachis <abuzachis@redhat.com>
9bd0523
to
82a7a6f
Compare
changelogs/fragments/20230526-ec2_mertadata_facts-handle_compressed_user_data.yml
Outdated
Show resolved
Hide resolved
Signed-off-by: Alina Buzachis <abuzachis@redhat.com>
changelogs/fragments/20230526-ec2_mertadata_facts-handle_compressed_user_data.yml
Outdated
Show resolved
Hide resolved
Build succeeded. ✔️ ansible-galaxy-importer SUCCESS in 4m 04s |
Build succeeded (gate pipeline). ✔️ ansible-galaxy-importer SUCCESS in 5m 12s |
f1fe603
into
ansible-collections:main
Backport to stable-5: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply f1fe603 on top of patchback/backports/stable-5/f1fe603084fdf05b70a856ea137a608eb663ccb9/pr-1575 Backporting merged PR #1575 into main
🤖 @patchback |
Backport to stable-6: 💚 backport PR created✅ Backport PR branch: Backported as #1580 🤖 @patchback |
… is compressed (#1575) ec2_metadata_facts - Handle decompression when EC2 instance user-data is compressed SUMMARY Handle decompression when user-data is compressed. The fetch_url method from ansible.module_utils.urls does not decompress the user-data because the header is missing (The API does not set 'Content-Encoding' = 'gzip'). ISSUE TYPE Bugfix Pull Request COMPONENT NAME ec2_metadata_facts ADDITIONAL INFORMATION Reviewed-by: Mike Graves <mgraves@redhat.com> Reviewed-by: Mark Chappell Reviewed-by: Alina Buzachis (cherry picked from commit f1fe603)
… is compressed (#1575) (#1580) [PR #1575/f1fe6030 backport][stable-6] ec2_metadata_facts - Handle decompression when EC2 instance user-data is compressed This is a backport of PR #1575 as merged into main (f1fe603). SUMMARY Handle decompression when user-data is compressed. The fetch_url method from ansible.module_utils.urls does not decompress the user-data because the header is missing (The API does not set 'Content-Encoding' = 'gzip'). ISSUE TYPE Bugfix Pull Request COMPONENT NAME ec2_metadata_facts ADDITIONAL INFORMATION Reviewed-by: Alina Buzachis
…le-collections#1575) ssm_parameter: add support for tags (ansible-collections#1573) SUMMARY Adding support for tags following community guidelines and other practices from other modules. secretsmanager_secret was used along with helper functions from ec2 code. Addresses open issue for feature request ansible-collections#1573. ISSUE TYPE Feature Pull Request COMPONENT NAME ssm_parameter ADDITIONAL INFORMATION Reviewed-by: Alina Buzachis <None> Reviewed-by: Michael Haskell (mikehas) <None> Reviewed-by: Dennis Qian <None> Reviewed-by: Markus Bergholz <git@osuv.de> Reviewed-by: Mark Chappell <None>
…le-collections#1575) ssm_parameter: add support for tags (ansible-collections#1573) SUMMARY Adding support for tags following community guidelines and other practices from other modules. secretsmanager_secret was used along with helper functions from ec2 code. Addresses open issue for feature request ansible-collections#1573. ISSUE TYPE Feature Pull Request COMPONENT NAME ssm_parameter ADDITIONAL INFORMATION Reviewed-by: Alina Buzachis <None> Reviewed-by: Michael Haskell (mikehas) <None> Reviewed-by: Dennis Qian <None> Reviewed-by: Markus Bergholz <git@osuv.de> Reviewed-by: Mark Chappell <None>
…le-collections#1575) ssm_parameter: add support for tags (ansible-collections#1573) SUMMARY Adding support for tags following community guidelines and other practices from other modules. secretsmanager_secret was used along with helper functions from ec2 code. Addresses open issue for feature request ansible-collections#1573. ISSUE TYPE Feature Pull Request COMPONENT NAME ssm_parameter ADDITIONAL INFORMATION Reviewed-by: Alina Buzachis <None> Reviewed-by: Michael Haskell (mikehas) <None> Reviewed-by: Dennis Qian <None> Reviewed-by: Markus Bergholz <git@osuv.de> Reviewed-by: Mark Chappell <None>
SUMMARY
Handle decompression when user-data is compressed. The fetch_url method from ansible.module_utils.urls does not decompress the user-data because the header is missing (The API does not set 'Content-Encoding' = 'gzip').
ISSUE TYPE
COMPONENT NAME
ec2_metadata_facts
ADDITIONAL INFORMATION