Update physical host mapping for ansible 2.4+
On ansible 2.4+, when 'ansible_host' is defined in the inventory ini file, the physical host mapping in the strategy plugin works as expected. However, if the ansible_host setting is in host_vars/<host>.yml, then the mapping does not work. Change-Id: I22c09c4de86233329f337b535b709cd5320c40d3
This commit is contained in:
parent
fef14ca3c7
commit
76bec48bc9
|
@ -132,7 +132,9 @@ class StrategyModule(LINEAR.StrategyModule):
|
|||
physical_hosts = groups.get('hosts', groups.get('all', {}))
|
||||
physical_host_addrs = {}
|
||||
for physical_host in physical_hosts:
|
||||
physical_host_vars = self._inventory.get_host(physical_host).vars
|
||||
physical_host_vars = self._variable_manager.get_vars(
|
||||
host=self._inventory.get_host(physical_host)
|
||||
)
|
||||
physical_host_addr = physical_host_vars.get('ansible_host',
|
||||
physical_host)
|
||||
physical_host_addrs[physical_host] = physical_host_addr
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
# Copyright 2018, Logan Vig <logan2211@gmail.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Defining this here instead of the inventory ini file tests
|
||||
# I22c09c4de86233329f337b535b709cd5320c40d3
|
||||
ansible_host: 127.0.0.1
|
|
@ -7,7 +7,7 @@ container2
|
|||
|
||||
# This is used to test I75f9d0f55ecd875caa1bf608a77c92f950b679a1
|
||||
[hosts]
|
||||
localhost_alt ansible_host=localhost
|
||||
localhost_alt
|
||||
[all_containers]
|
||||
container3 physical_host=localhost_alt
|
||||
|
||||
|
|
Loading…
Reference in New Issue