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

Add jinja2 support for tag filters in the aws_ec2 inventory plugin #58213

Open

Conversation

Projects
None yet
2 participants
@diego1q2w
Copy link

commented Jun 21, 2019

SUMMARY

Some time ago my team and I decided to use workspaces in AWS so each member can test in their own isolated space within the same AWS profile, the integration with ansible was quite easy by setting a tag Workspace as shown below:

filters:
  tag-key: Managed
  tag:Workspace: diego

The problem with this is that we have to remember to set it back to default each time before we commit to avoid having other members running into your space, not a big deal, it became a bit annoying, though :). We came up with some hacky solutions just to get by, but then we thought that a better solution would be somehow supporting ENV variables, and thus jinja2 became a natural choice adding more flexibility. Without further ado the inventory filters would look as follows:

filters:
  tag-key: Managed
  tag:Workspace: "{{ lookup('env','AWS_WORKSPACE') }}"
ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

Add jinja2 support for tag filters in the aws_ec2 inventory plugin

ADDITIONAL INFORMATION
The same output but dynamic input 

Thanks for reading and I am open for suggestions.
Looking forward to seeing this on the next release :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.