From 5be187d1fb3823c56c5243292798d2987c63d45c Mon Sep 17 00:00:00 2001 From: Logan V Date: Sat, 10 Sep 2016 23:58:06 -0500 Subject: [PATCH] Add ansible_host to dynamic inventory Since ansible_ssh_host is deprecated per http://docs.ansible.com/ansible/intro_inventory.html this change will allow add the new ansible_host var to the inventory so ansible_ssh_host references can begin transitioning to ansible_host. Once that is complete ansible_ssh_host can be removed. Change-Id: I8e7497a7eb7145a5908995cbc1991bfe4efa5946 Closes-Bug: #1622281 --- playbooks/inventory/dynamic_inventory.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/playbooks/inventory/dynamic_inventory.py b/playbooks/inventory/dynamic_inventory.py index 06c1b9f9b4..c3ef1eb2be 100755 --- a/playbooks/inventory/dynamic_inventory.py +++ b/playbooks/inventory/dynamic_inventory.py @@ -40,6 +40,7 @@ INVENTORY_SKEL = { # inventory setup should be added to this list. REQUIRED_HOSTVARS = [ 'properties', + 'ansible_host', 'ansible_ssh_host', 'physical_host_group', 'container_address', @@ -255,6 +256,7 @@ def _build_container_hosts(container_affinity, container_hosts, type_and_name, hostvars_options.update({ 'properties': properties, + 'ansible_host': address, 'ansible_ssh_host': address, 'container_address': address, 'container_name': container_host_name, @@ -445,6 +447,7 @@ def user_defined_setup(config, inventory): hvs[_key] = {} hvs[_key].update({ + 'ansible_host': _value['ip'], 'ansible_ssh_host': _value['ip'], 'container_address': _value['ip'], 'is_metal': True, @@ -661,6 +664,7 @@ def _add_additional_networks(key, inventory, ip_q, q_name, netmask, interface, network['address'] = phg['ip'] if is_ssh_address is True: + container['ansible_host'] = networks[old_address]['address'] container['ansible_ssh_host'] = networks[old_address]['address'] if is_container_address is True: