Merge "Specify vars after children sections"

This commit is contained in:
Zuul 2017-10-31 22:27:25 +00:00 committed by Gerrit Code Review
commit bcbc953aa2
2 changed files with 11 additions and 5 deletions

View File

@ -0,0 +1,6 @@
---
fixes:
- tripleo-ansible-inventory has been updated to output the vars sections
after the children sections. Due to a change in ansible 2.4, having them
in the other order caused no hosts to match the generated static inventory.
See https://bugs.launchpad.net/tripleo/+bug/1729058

View File

@ -90,17 +90,17 @@ def write_static_inventory(inventory_file_path, inventory):
config.add_section(section_name)
for host in section['hosts']:
config.set(section_name, host)
if 'children' in section:
children_section_name = "%s:%s" % (section_name, 'children')
config.add_section(children_section_name)
for child in section['children']:
config.set(children_section_name, child)
if 'vars' in section:
vars_section_name = "%s:%s" % (section_name, 'vars')
config.add_section(vars_section_name)
for var, value in section['vars'].items():
if value != None:
config.set(vars_section_name, var, value)
if 'children' in section:
children_section_name = "%s:%s" % (section_name, 'children')
config.add_section(children_section_name)
for child in section['children']:
config.set(children_section_name, child)
config.write(inventory_file)