Use OrderedDict to sort the hostname before the alias

With ansible 2.4 we need to define the hostname first
to be usable after with :children in the inventory
If not, the Controller name is unknown for ansible
intentory.

Closes-Bug: #1728733

Change-Id: Ie943138c2da5d6acab2a75db3afd8fdad7558de2
This commit is contained in:
Mathieu Bultel 2017-10-30 11:19:30 +01:00
parent bc3b90c2a8
commit 4518273685
1 changed files with 13 additions and 10 deletions

View File

@ -15,6 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from collections import OrderedDict
from heatclient.exc import HTTPNotFound
HOST_NETWORK = 'ctlplane'
@ -112,7 +114,7 @@ class TripleoInventory(object):
return self.UNDERCLOUD_SERVICES
def list(self):
ret = {
ret = OrderedDict({
'undercloud': {
'hosts': ['localhost'],
'vars': {
@ -125,7 +127,7 @@ class TripleoInventory(object):
'username': self.configs.username,
},
}
}
})
swift_url = self.session.get_endpoint(service_type='object-store',
interface='public')
@ -160,6 +162,15 @@ class TripleoInventory(object):
if hostnames:
names = hostnames.get(HOST_NETWORK) or []
shortnames = [n.split(".%s." % HOST_NETWORK)[0] for n in names]
# Create a group per hostname to map hostname to IP
ips = role_net_ip_map[role][HOST_NETWORK]
for idx, name in enumerate(shortnames):
ret[name] = {'hosts': [ips[idx]]}
if 'server_ids' in role_node_id_map:
ret[name]['vars'] = {
'deploy_server_id': role_node_id_map[
'server_ids'][role][idx]}
children.append(role)
ret[role] = {
'children': sorted(shortnames),
@ -170,14 +181,6 @@ class TripleoInventory(object):
'role_name': role,
}
}
# Create a group per hostname to map hostname to IP
ips = role_net_ip_map[role][HOST_NETWORK]
for idx, name in enumerate(shortnames):
ret[name] = {'hosts': [ips[idx]]}
if 'server_ids' in role_node_id_map:
ret[name]['vars'] = {
'deploy_server_id': role_node_id_map[
'server_ids'][role][idx]}
if children:
ret['overcloud'] = {