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_metadata_facts: Add support to query instance tags + values #2293

Closed
1 task done
drewoconnor opened this issue Sep 11, 2024 · 1 comment · Fixed by #2398
Closed
1 task done

ec2_metadata_facts: Add support to query instance tags + values #2293

drewoconnor opened this issue Sep 11, 2024 · 1 comment · Fixed by #2398
Labels
docs feature This issue/PR relates to a feature request jira

Comments

@drewoconnor
Copy link

Summary

https://docs.ansible.com/ansible/latest/collections/amazon/aws/ec2_metadata_facts_module.html#return-ansible_facts/ansible_ec2_instance_tags_keys

States that it returns the keys. But, there is no way to get the values.

Can we add a way to get the tag Values?

Issue Type

Feature Idea

Component Name

ec2_metadata_facts

Additional Information

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@abikouo abikouo added feature This issue/PR relates to a feature request needs_verified Some one might want to take a look at this and reproduce it to confirm and removed needs_triage labels Sep 11, 2024
@tremble tremble added docs and removed needs_verified Some one might want to take a look at this and reproduce it to confirm labels Sep 11, 2024
@tremble
Copy link
Contributor

tremble commented Sep 11, 2024

It's currently not very "obvious" but they are returned...

Running the integration test we have for this module:

TASK [amazon.aws.ec2_metadata_facts] *******************************************
...
ok: [34.239.124.147] => {
    "ansible_facts": {
        "ansible_ec2_ami_id": "ami-07320b1482d6ac29f",
...
        "ansible_ec2_instance_tags_keys": [
            "Name",
            "camelCaseKey",
            "snake_case_key"
        ],
...
        "ansible_ec2_tags_instance_Name": "ansible-test-28009695-ec2-metadata-facts",
        "ansible_ec2_tags_instance_camelCaseKey": "aCamelCaseValue",
        "ansible_ec2_tags_instance_snake_case_key": "a_snake_case_value",
        "ansible_ec2_user_data": "None"
    },
    "changed": false,
    "invocation": {
        "module_args": {
            "metadata_token_ttl_seconds": 240
        }
    }
}

The tag values are accessible under ansible_ec2_tags_instance_<tag_name>, so this is more a case of missing documentation bug than a missing feature.

Originally it wasn't possible to return dictionaries as fact values, this is now possible, so it might make sense to support returning the tags as a dict...

patchback bot pushed a commit that referenced this issue Dec 3, 2024
SUMMARY
Fixes #2293
A list of instance tag keys was added to the return values in version 5.5.0. This adds a new return value that includes the full key:value pairs for the instance tags.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
ec2_metadata_facts

Reviewed-by: Mark Chappell
Reviewed-by: Helen Bailey <hebailey@redhat.com>
Reviewed-by: Alina Buzachis
Reviewed-by: Bikouo Aubin
(cherry picked from commit 43387ec)
softwarefactory-project-zuul bot pushed a commit that referenced this issue Dec 3, 2024
This is a backport of PR #2398 as merged into main (43387ec).
SUMMARY
Fixes #2293
A list of instance tag keys was added to the return values in version 5.5.0. This adds a new return value that includes the full key:value pairs for the instance tags.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
ec2_metadata_facts

Reviewed-by: Alina Buzachis
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this issue Jan 15, 2025
…tions#2398)

SUMMARY
Fixes ansible-collections#2293
A list of instance tag keys was added to the return values in version 5.5.0. This adds a new return value that includes the full key:value pairs for the instance tags.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
ec2_metadata_facts

Reviewed-by: Mark Chappell
Reviewed-by: Helen Bailey <hebailey@redhat.com>
Reviewed-by: Alina Buzachis
Reviewed-by: Bikouo Aubin
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this issue Jan 15, 2025
…tions#2398)

SUMMARY
Fixes ansible-collections#2293
A list of instance tag keys was added to the return values in version 5.5.0. This adds a new return value that includes the full key:value pairs for the instance tags.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
ec2_metadata_facts

Reviewed-by: Mark Chappell
Reviewed-by: Helen Bailey <hebailey@redhat.com>
Reviewed-by: Alina Buzachis
Reviewed-by: Bikouo Aubin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs feature This issue/PR relates to a feature request jira
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants