I'm sure there must be a simple answer, but, when I use the aws_ec2 plugin to create a dynamic inventory for Ansible, I use the following setup so that I can pass the profile in to the inventory (to get the correct credentials):
plugin: aws_ec2
aws_profile: "{{ lookup('env', 'AWS_PROFILE') | default('dev-profile', true) }}"
regions:
- us-east-1
Now, I want all of these hosts to be associated with a group which has the name of the AWS_PROFILE passed in. How do I do this?
I tried:
groups:
dev_group: aws_profile == 'dev-profile'
test_group: aws_profile == 'test-profile'
but was unsuccessful (no groups were created).