]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
Fix config_template to consistently order sections
authorAndy McCrae <andy.mccrae@gmail.com>
Fri, 16 Mar 2018 15:24:53 +0000 (15:24 +0000)
committerSébastien Han <seb@redhat.com>
Wed, 21 Mar 2018 05:11:26 +0000 (06:11 +0100)
In ec042219e64a321fa67fce0384af76eeb238c645 we added OrderedDict and
sorted to be able to preserve order for config_template k,v pairs inside
a section.

This patch adds a similar ordering for the sections themselves, which
could still change order and intiiate handler restarts.

OrderedDict isn't needed because we use .items() to return a list that
can then be sorted().

(cherry picked from commit fe4ba9d1353abb49775d5541060a55919978f45f)

plugins/actions/_v1_config_template.py
plugins/actions/_v2_config_template.py

index 95de13ef1c455944fd1466c91d613669e5f35135..6f8e55e30c284e97c42fa4d1e56ff26d4079b5e6 100644 (file)
@@ -26,7 +26,6 @@ from ansible import errors
 from ansible.runner.return_data import ReturnData
 from ansible import utils
 from ansible.utils import template
-from collections import OrderedDict
 
 CONFIG_TYPES = {
     'ini': 'return_config_overrides_ini',
@@ -145,14 +144,14 @@ class ConfigTemplateParser(ConfigParser.RawConfigParser):
     def write(self, fp):
         if self._defaults:
             fp.write("[%s]\n" % 'DEFAULT')
-            for key, value in OrderedDict(sorted(self._defaults.items())).items():
+            for key, value in sorted(self._defaults.items()):
                 self._write_check(fp, key=key, value=value)
             else:
                 fp.write("\n")
 
-        for section in self._sections:
+        for section in sorted(self._sections):
             fp.write("[%s]\n" % section)
-            for key, value in OrderedDict(sorted(self._sections[section].items())).items():
+            for key, value in sorted(self._sections[section].items()):
                 self._write_check(fp, key=key, value=value, section=True)
             else:
                 fp.write("\n")
index 787cd0f9f57c7808218ddfdf9dec8b61f588388d..64d57c74570e6165a7c7f922fa45d96ef03f0d95 100644 (file)
@@ -37,7 +37,6 @@ from ansible.plugins.action import ActionBase
 from ansible.utils.unicode import to_bytes, to_unicode
 from ansible import constants as C
 from ansible import errors
-from collections import OrderedDict
 
 CONFIG_TYPES = {
     'ini': 'return_config_overrides_ini',
@@ -173,14 +172,14 @@ class ConfigTemplateParser(ConfigParser.RawConfigParser):
     def write(self, fp):
         if self._defaults:
             fp.write("[%s]\n" % 'DEFAULT')
-            for key, value in OrderedDict(sorted(self._defaults.items())).items():
+            for key, value in sorted(self._defaults.items()):
                 self._write_check(fp, key=key, value=value)
             else:
                 fp.write("\n")
 
-        for section in self._sections:
+        for section in sorted(self._sections):
             fp.write("[%s]\n" % section)
-            for key, value in OrderedDict(sorted(self._sections[section].items())).items():
+            for key, value in sorted(self._sections[section].items()):
                 self._write_check(fp, key=key, value=value, section=True)
             else:
                 fp.write("\n")