AWS Inventory seems to using script, not plugin

43 views
Skip to first unread message

Guy Matz

unread,
Oct 12, 2020, 2:57:33 PM10/12/20
to AWX Project
Hi!  I'm trying to get an inventory from AWS and I don't see anywhere to enter in the information I have in my aws_ec2.yaml file  . . .  Is it possible that I'm looking at a version that uses the old script instead?  Here's what I'm seeing
Screen Shot 2020-10-12 at 2.56.05 PM.png
Aren't there supposed to be fields for region, Instance FIlter, Only Group By, etc?  Anyone have any idea what I'm doing wrong?

Thanks!
Guy
 ______________ 
<  AWX 15.0.0  >
 -------------- 
        \   ^__^
         \  (oo)\_______
            (__)      A )\/\
                ||----w |
                ||     ||

Ansible 2.9.13

Bill Nottingham

unread,
Oct 12, 2020, 3:20:53 PM10/12/20
to Guy Matz, AWX Project
Guy Matz (guy...@gmail.com) said:
> Hi! I'm trying to get an inventory from AWS and I don't see anywhere to
> enter in the information I have in my aws_ec2.yaml file . . . Is it
> possible that I'm looking at a version that uses the old script instead?

The configuration goes in the source variables.

Bill

Guy Matz

unread,
Oct 12, 2020, 4:46:21 PM10/12/20
to Bill Nottingham, AWX Project
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.html
plugin: 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
Reply all
Reply to author
Forward
0 new messages