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

ec2_instance metadata_options are not updated #1864

Closed
1 task done
adpavlov opened this issue Nov 17, 2023 · 0 comments · Fixed by #1918
Closed
1 task done

ec2_instance metadata_options are not updated #1864

adpavlov opened this issue Nov 17, 2023 · 0 comments · Fixed by #1918
Labels
jira needs_verified Some one might want to take a look at this and reproduce it to confirm

Comments

@adpavlov
Copy link

Summary

Trying to update metadata_options. on existing instances

Issue Type

Bug Report

Component Name

ec2_instance

Ansible Version

$ ansible --version
ansible [core 2.15.2]

Collection Versions

$ ansible-galaxy collection list
amazon.aws                    7.0.0

AWS SDK versions

$ pip show boto boto3 botocore
Name: boto3
Version: 1.28.15
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: /home/devops/.local/lib/python3.9/site-packages
Requires: botocore, jmespath, s3transfer
Required-by: 
---
Name: botocore
Version: 1.31.15
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: /home/devops/.local/lib/python3.9/site-packages
Requires: jmespath, python-dateutil, urllib3
Required-by: awscli, boto3, s3transfer

Configuration

$ ansible-config dump --only-changed

OS / Environment

No response

Steps to Reproduce

    - name: Get EC2 instance info
      amazon.aws.ec2_instance_info:
        access_key: "{{ aws_config.access_key }}"
        secret_key: "{{ aws_config.secret_key }}"
        session_token: "{{ aws_config.session_token }}"
        region: "{{ aws_config.region }}"
      register: ec2_instances


    - name: Set http_tokens required for AWS instance
      amazon.aws.ec2_instance:
        access_key: "{{ aws_config.access_key }}"
        secret_key: "{{ aws_config.secret_key }}"
        session_token: "{{ aws_config.session_token }}"
        region: "{{ aws_config.region }}"
        instance_ids: "{{ ec2_instances.instances | selectattr('metadata_options.http_tokens', 'search', 'optional') | map(attribute='instance_id') | list }}"
        metadata_options:
          http_endpoint: enabled
          http_tokens: required
          http_put_response_hop_limit: 2

Expected Results

metadata_options to be updated, but hop count is still 1 and IMDSv2 still optional

Actual Results

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@hakbailey hakbailey added needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI needs_verified Some one might want to take a look at this and reproduce it to confirm jira and removed needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI needs_triage labels Nov 21, 2023
softwarefactory-project-zuul bot pushed a commit that referenced this issue Dec 20, 2023
)

ec2_instance: add support for modifying instance metadata options

SUMMARY

Fixes #1864
This PR add support for modifying instance metadata options.
Uses client. modify_instance_metadata_options()

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

ec2_instance
ADDITIONAL INFORMATION

Reviewed-by: Helen Bailey <[email protected]>
Reviewed-by: Mark Chappell
Reviewed-by: Bikouo Aubin
Reviewed-by: GomathiselviS
Reviewed-by: Mandar Kulkarni <[email protected]>
patchback bot pushed a commit that referenced this issue Dec 20, 2023
)

ec2_instance: add support for modifying instance metadata options

SUMMARY

Fixes #1864
This PR add support for modifying instance metadata options.
Uses client. modify_instance_metadata_options()

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

ec2_instance
ADDITIONAL INFORMATION

Reviewed-by: Helen Bailey <[email protected]>
Reviewed-by: Mark Chappell
Reviewed-by: Bikouo Aubin
Reviewed-by: GomathiselviS
Reviewed-by: Mandar Kulkarni <[email protected]>
(cherry picked from commit cef7268)
softwarefactory-project-zuul bot pushed a commit that referenced this issue Dec 20, 2023
) (#1934)

[PR #1918/cef72686 backport][stable-7] ec2_instance: add support for modifying instance metadata options

This is a backport of PR #1918 as merged into main (cef7268).
SUMMARY

Fixes #1864
This PR add support for modifying instance metadata options.
Uses client. modify_instance_metadata_options()

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

ec2_instance
ADDITIONAL INFORMATION

Reviewed-by: Mark Chappell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira needs_verified Some one might want to take a look at this and reproduce it to confirm
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants