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

allow lookups in 'filter' variables aws_ec2.yml file #2378

Open
1 task done
t794104 opened this issue Nov 6, 2024 · 0 comments · May be fixed by #2379
Open
1 task done

allow lookups in 'filter' variables aws_ec2.yml file #2378

t794104 opened this issue Nov 6, 2024 · 0 comments · May be fixed by #2379

Comments

@t794104
Copy link

t794104 commented Nov 6, 2024

Summary

There is a limited list of vars that support lookups in the aws_ec2.yml file. I'd like too add the filters var too that list.

With this feature it become possible too filter the inventroy based on env vars. In our case we can have dynamic inv for each developer.

Issue Type

Feature Idea

Component Name

The inventory.py in plugins/plugin_utils

Additional Information

        def get(self, *args):
            value = self.original_options.get(*args)
            if (
                not value
                or not self.templar
                or args[0] not in self.TEMPLATABLE_OPTIONS
            ):
                return value

            if isinstance(value, dict):
                new = {}
                for i in value:
                    new[i] = self.templar.template(variable=value[i], disable_lookups=False)
                return new
            
            return self.templar.template(variable=value, disable_lookups=False)

Above is the fix for the 'get' function together with adding the filters var too the list

        TEMPLATABLE_OPTIONS = (
            "access_key",
            "secret_key",
            "session_token",
            "profile",
            "endpoint_url",
            "assume_role_arn",
            "region",
            "regions",
            "filters",
        )

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@t794104 t794104 linked a pull request Nov 6, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant