diff options
| author | Doug Szumski <doug@stackhpc.com> | 2018-03-15 16:58:54 +0000 |
|---|---|---|
| committer | Doug Szumski <doug@stackhpc.com> | 2018-03-16 15:26:41 +0000 |
| commit | d32c708290dcd0934441687606497f5d133627ab (patch) | |
| tree | 95d7a5324e2a68400c224ea30ed546c9fec78532 /ansible/action_plugins | |
| parent | a909943bf3720a24f53107cdbed304ca84a88657 (diff) | |
| download | kolla-ansible-d32c708290dcd0934441687606497f5d133627ab.tar.gz kolla-ansible-d32c708290dcd0934441687606497f5d133627ab.zip | |
Support parsing ini files with no sections
Services such as Zookeeper and Kafka use ini files which do not
explicitly specify sections. This change supports merging ini
files with no sections, so that the configuration for these
services follows the example configuration provided for them
as closely as possible.
Closes-Bug: #1756101
Partially-Implements: blueprint monasca-roles
Change-Id: I1061729875e5545c7af7d80779f9c2124b6c7134
Diffstat (limited to 'ansible/action_plugins')
| -rw-r--r-- | ansible/action_plugins/merge_configs.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/ansible/action_plugins/merge_configs.py b/ansible/action_plugins/merge_configs.py index 11462f4b3..556bfa83b 100644 --- a/ansible/action_plugins/merge_configs.py +++ b/ansible/action_plugins/merge_configs.py @@ -25,6 +25,8 @@ from six import StringIO from oslo_config import iniparser +_ORPHAN_SECTION = 'TEMPORARY_ORPHAN_VARIABLE_SECTION' + class OverrideConfigParser(iniparser.BaseParser): @@ -34,6 +36,8 @@ class OverrideConfigParser(iniparser.BaseParser): self._cur_section = None def assignment(self, key, value): + if self._cur_section is None: + self.new_section(_ORPHAN_SECTION) cur_value = self._cur_section.get(key) if len(value) == 1 and value[0] == '': value = [] @@ -44,6 +48,7 @@ class OverrideConfigParser(iniparser.BaseParser): def parse(self, lineiter): self._cur_sections = collections.OrderedDict() + self._cur_section = None super(OverrideConfigParser, self).parse(lineiter) # merge _cur_sections into _sections @@ -77,7 +82,8 @@ class OverrideConfigParser(iniparser.BaseParser): write_key_value(key, values) for section in self._sections: - fp.write('[{}]\n'.format(section)) + if section != _ORPHAN_SECTION: + fp.write('[{}]\n'.format(section)) write_section(self._sections[section]) fp.write('\n') |
