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

Open
1 task done
drewoconnor opened this issue Sep 11, 2024 · 1 comment · May be fixed by #2398
Open
1 task done

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

drewoconnor opened this issue Sep 11, 2024 · 1 comment · May be 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...

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