-1

We have centralised ansible awx tower and using aws ec2 plugin to sync the hosts. Because the hostnames are private dns of aws we're unable to connect from ansible (nodes are in another account, but vpcs are peered). So from the awx console is there a way we can just list and connect using primary private IPs? (host has multiple secondery IPs)

Our current inventory source variables to filter the hosts:

---
keyed_groups:
<filter-by-tags>
groups:
  tags
filters:
  instance-state-name : running
  vpc-id: vpc-xxxxxxx

In the inventory source variables I have tried setting up:

vpc_destination_variable: private_ip_address
Zeitounator
  • 38,476
  • 7
  • 53
  • 66
L_sama
  • 23
  • 3

1 Answers1

0

Found the solution, need to add the below lines to the source variable.

compose:
  # Use the private IP address to connect to the host
  # (note: this does not modify inventory_hostname, which is set via I(hostnames))
  ansible_host: private_ip_address

Reference: https://docs.ansible.com/ansible/latest/collections/amazon/aws/aws_ec2_inventory.html

L_sama
  • 23
  • 3