That seemed to work! One little hitch: Does anyone know how I can get ansible_hostname to use tag:Name? The code below works on CLI but not in AWX:
# see
https://docs.ansible.com/ansible/latest/plugins/inventory/aws_ec2.htmlplugin: aws_ec2
strict: True
#cache: yes
regions:
- us-east-1
- us-west-1
- us-west-2
# keyed_groups may be used to create custom groups
keyed_groups:
- prefix: arch
key: 'architecture'
- key: tags['Env']|default('NA')
prefix: tag_Env
- key: tags['Role']|default('NA')
prefix: tag_Role
groups:
aws: true
atlassian: "'confluence' in tags|replace('-', '_') or 'jira' in tags|replace('-', '_')"
confluence: "'confluence' in tags|replace('-', '_')"
jira: "'jira' in tags|replace('-', '_')"
prime: "'prime' in tags|replace('-', '_')"
squish: "'testcenter' in tags|replace('-', '_')"
pomerium: "'_pom' in tags|replace('-', '_')"
bastion: "'true' in tags['Bastion']|default('false')|replace('-', '_')"
# NOT using hostnames in favor of jinja below (ansible_ssh_host)
#hostnames:
# - private-ip-address
# - private-dns-name
# - dns-name
# - network-interface.addresses.association.public-ip
## Set individual variables with compose
compose:
ansible_user: tags['User']|default('centos')
ansible_ssh_private_key_file: key_name|default('no_key')|regex_replace('^(.*)$', '~/.ssh/\1.pem')
ansible_ssh_host: public_ip_address
if (
private_ip_address is not defined
or
private_ip_address.startswith('10.')
or
(tags['Env'] is defined and tags['Env']=='test')
)
and (public_ip_address is defined)
else
private_ip_address