Awx: Dynamic Inventory of hosts from OpenStack: ansible_ssh_host is private IP and not floating

Created on 30 Apr 2020  路  7Comments  路  Source: ansible/awx

ISSUE TYPE
  • Documentation

    COMPONENT NAME
  • API

    SUMMARY

Hi,
I'm during the synchronization of OpenStack and AWX. I made a dynamic inventory of hosts that are deployed on my OpenStack cloud using the appriopriate credentials. The hosts are detected correctly, and doing job templates manually works, but I will be in need of making an API callbacks and SSH using floating ips of the virtual machines. So, right now I can see in AWX, in the host variables that these parameters are the private-networks IPs:
ansible_host: 192.168.100.11
ansible_ssh_host: 192.168.100.11
I can see that both IPs are discovered:
addresses:
private:
- 'OS-EXT-IPS-MAC:mac_addr': 'fa:16:3e:19:9f:fb'
'OS-EXT-IPS:type': fixed
addr: 192.168.100.11
version: 4
- 'OS-EXT-IPS-MAC:mac_addr': 'fa:16:3e:19:9f:fb'
'OS-EXT-IPS:type': floating
addr: 10.0.0.147
version: 4

For this inventory job I use the venv: /var/lib/awx/venv/ansible
I can't find out in the docs, how I can change the script to take the floating IPs from an inventory as an assible_ssh_host parameter.. In this case 10.0.0.147

ENVIRONMENT
  • AWX version: 11.0.0
  • AWX install method: docker
  • Ansible version: 2.9.5
  • Operating System: CentOS7
STEPS TO REPRODUCE
EXPECTED RESULTS

ansible_ssh_host: 10.0.0.147 <-- floating ip from OpenStack

ACTUAL RESULTS

ansible_ssh_host: 192.168.100.11 <-- right now i collect private ip from OpenStack

ADDITIONAL INFORMATION
api needs_info

All 7 comments

@mareckis,

Any chance you could give this a shot on the latest version of AWX, 11.2.0?

We recently merged in a change that moves us to the _newer_ openstack collection (https://galaxy.ansible.com/openstack/cloud) for inventory syncs, and I'm wondering if there's a change there that might address what you're seeing.

@emonty you have any pointers here that might help? I'm not super familiar with how this inventory plugin is configured.

The inventory plugin should be using server.interface_ip for the ansible_ssh_host setting unless private: true has been specified. Can you tell me the values of public_v4, private_v4 and interface_ip on the server record?

https://github.com/ansible/awx/blob/devel/awx/main/models/inventory.py#L2406

@mareckis

Have you tried specifying private: false in the inventory source definition?

image

bash-4.4$ cat /tmp/awx_638_5gygj0xf/tmp6rl5wtxs
clouds:
  devstack:
    auth:
      auth_url: http://example.org
      domain_name: Domain Name!
      password: password
      project_domain_name: Project Domain Name!
      project_name: Tenant!
      username: user
    private: false
    verify: true

Hi,
@emonty @ryanpetrello
Specified the private parameter in the inventory source definition, run the inventory sync job again after the change. As previously 2 hosts are detected on the OpenStack cloud (Packstack actually) and updated. Still didn't change anything. Below, I attach the part of output of variables from one of the hosts that are synced with AWX:

ansible_host: 192.168.100.11
ansible_ssh_host: 192.168.100.11

openstack:
'OS-DCF:diskConfig': MANUAL
'OS-EXT-AZ:availability_zone': nova
'OS-EXT-SRV-ATTR:host': localhost.localdomain
'OS-EXT-SRV-ATTR:hostname': eva-new
'OS-EXT-SRV-ATTR:hypervisor_hostname': localhost.localdomain
'OS-EXT-SRV-ATTR:instance_name': instance-00000008
'OS-EXT-SRV-ATTR:kernel_id': ''
'OS-EXT-SRV-ATTR:launch_index': 0
'OS-EXT-SRV-ATTR:ramdisk_id': ''
'OS-EXT-SRV-ATTR:reservation_id': r-w89wtaix
'OS-EXT-SRV-ATTR:root_device_name': /dev/vda
'OS-EXT-SRV-ATTR:user_data': >-
IyEvYmluL2Jhc2ggLXYKY3VybCAtayAtLWRhdGEgImhvc3RfY29uZmlnX2tleT1jNWZkMGE5ZS04YjQ4LTQ4MmItOGZlMi1kNDYwNWI5ZTBhOTYiIGh0dHBzOi8vMTAuMC4wLjEzNzo4MC9hcGkvdjIvam9iX3RlbXBsYXRlcy8xMC9jYWxsYmFjay8K
'OS-EXT-STS:power_state': 1
'OS-EXT-STS:task_state': null
'OS-EXT-STS:vm_state': active
'OS-SCH-HNT:scheduler_hints': null
'OS-SRV-USG:launched_at': '2020-04-28T15:25:29.000000'
'OS-SRV-USG:terminated_at': null
accessIPv4: 192.168.100.11
accessIPv6: ''
addresses:
private:
- 'OS-EXT-IPS-MAC:mac_addr': 'fa:16:3e:19:9f:fb'
'OS-EXT-IPS:type': fixed
addr: 192.168.100.11
version: 4

- 'OS-EXT-IPS-MAC:mac_addr': 'fa:16:3e:19:9f:fb'
'OS-EXT-IPS:type': floating
addr: 10.0.0.147
version: 4

adminPass: null
az: nova
block_device_mapping: null
cloud: devstack
config_drive: ''
created: '2020-04-28T15:25:11Z'
created_at: '2020-04-28T15:25:11Z'
description: null
disk_config: MANUAL
flavor:
disk: 20
ephemeral: 0
extra_specs: {}
name: m2.small
original_name: m2.small
ram: 2048
swap: 0
vcpus: 1
has_config_drive: false
host: localhost.localdomain
hostId: 0b49e21a1af92086e635abe501ada552901996391c0f2636b8c5ac58
host_id: 0b49e21a1af92086e635abe501ada552901996391c0f2636b8c5ac58
host_status: UP
hostname: eva-new
hypervisor_hostname: localhost.localdomain
id: 2ddb4762-f13b-4d71-925d-12f47c7ab055
image:
id: a38bfe51-4deb-48f4-b8f1-62f61da3a21a
name: EVA_openstack
instance_name: instance-00000008
interface_ip: 192.168.100.11
kernel_id: ''
key_name: heat
launch_index: 0
launched_at: '2020-04-28T15:25:29.000000'
location:
cloud: devstack
project:
domain_id: null
domain_name: Default
id: 0370ca298cb64e608d3d0973d15234c9
name: admin
region_name: ''
zone: nova
locked: false
metadata: {}
name: eva_new
networks: {}
'os-extended-volumes:volumes_attached': []
personality: null
power_state: 1
private_v4: 192.168.100.11
progress: 0
project_id: 0370ca298cb64e608d3d0973d15234c9
properties:
'OS-DCF:diskConfig': MANUAL
'OS-EXT-AZ:availability_zone': nova
'OS-EXT-SRV-ATTR:host': localhost.localdomain
'OS-EXT-SRV-ATTR:hostname': eva-new
'OS-EXT-SRV-ATTR:hypervisor_hostname': localhost.localdomain
'OS-EXT-SRV-ATTR:instance_name': instance-00000008
'OS-EXT-SRV-ATTR:kernel_id': ''
'OS-EXT-SRV-ATTR:launch_index': 0
'OS-EXT-SRV-ATTR:ramdisk_id': ''
'OS-EXT-SRV-ATTR:reservation_id': r-w89wtaix
'OS-EXT-SRV-ATTR:root_device_name': /dev/vda
'OS-EXT-SRV-ATTR:user_data': >-
IyEvYmluL2Jhc2ggLXYKY3VybCAtayAtLWRhdGEgImhvc3RfY29uZmlnX2tleT1jNWZkMGE5ZS04YjQ4LTQ4MmItOGZlMi1kNDYwNWI5ZTBhOTYiIGh0dHBzOi8vMTAuMC4wLjEzNzo4MC9hcGkvdjIvam9iX3RlbXBsYXRlcy8xMC9jYWxsYmFjay8K
'OS-EXT-STS:power_state': 1
'OS-EXT-STS:task_state': null
'OS-EXT-STS:vm_state': active
'OS-SCH-HNT:scheduler_hints': null
'OS-SRV-USG:launched_at': '2020-04-28T15:25:29.000000'
'OS-SRV-USG:terminated_at': null
host_status: UP
locked: false
'os-extended-volumes:volumes_attached': []
trusted_image_certificates: null
public_v4: 10.0.0.147
public_v6: ''
ramdisk_id: ''
region: ''
reservation_id: r-w89wtaix
root_device_name: /dev/vda
scheduler_hints: null

As you can see the public_v4 (floating_ip_addr) is subnet 10.0.0.x,, the tenant network is (192.168.100.x private). The AWX is working only under floating subnet which is 10.0.0.137, also I would like to make a Callback API request from Heat which is under 10.0.0.136 to the API of the AWX module, but need to have a clear situation to make jobs using the floating addresses.

@blomquisg @emonty @ryanpetrello
Any solutions that would make it happen to work?

So - that looks like private: true is being set somewhere. If you look at the things you highlighted, you see that we did detect public_v4: 10.0.0.147. But interface_ip and accessIPv4 are both set to 192.168.100.11. The only thing that causes that is for private: true to be set in the cloud definition. This is the relvant sdk code:

    if cloud.private and server['private_v4']:
        server['accessIPv4'] = server['private_v4']
    else:
        server['accessIPv4'] = server['public_v4']

I'm not sure where all to tell you to look for the setting - in my world I would just look in the clouds.yaml, which could be in /etc/openstack/clouds.yaml or ~/.config/openstack/clouds.yaml - but I think here AWX manages that for you. @ryanpetrello are there other places it might be picking up that setting?

@mareckis,

Can you try on the latest version of AWX?

When I tried this last week and set the private: false as a source var on the inventory source, it was properly respected and generated the clouds.yaml in the way @emonty described:

https://github.com/ansible/awx/issues/6892#issuecomment-621988063

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shortsteps picture shortsteps  路  3Comments

agaffney picture agaffney  路  3Comments

cs35-owncloud picture cs35-owncloud  路  3Comments

marshmalien picture marshmalien  路  3Comments

darkaxl picture darkaxl  路  3Comments