Browse code

Scan group_vars/host_vars in sorted order

(cherry picked from commit a9b15ce88169160846d73e3ad5ce19b4154b2e51)

André Althaus authored on 2017/11/16 18:37:45
Showing 3 changed files
... ...
@@ -180,6 +180,8 @@ Ansible Changes By Release
180 180
   (https://github.com/ansible/ansible/pull/33100)
181 181
 * restore error on orphan group:vars delcaration for ini inventories
182 182
   https://github.com/ansible/ansible/pull/32866
183
+* restore host/group_vars merge order
184
+  https://github.com/ansible/ansible/pull/32963
183 185
 
184 186
 <a id="2.4.1"></a>
185 187
 
... ...
@@ -282,7 +282,7 @@ the 'raleigh' group might look like::
282 282
 It is okay if these files do not exist, as this is an optional feature.
283 283
 
284 284
 As an advanced use case, you can create *directories* named after your groups or hosts, and
285
-Ansible will read all the files in these directories. An example with the 'raleigh' group::
285
+Ansible will read all the files in these directories in lexicographical order. An example with the 'raleigh' group::
286 286
 
287 287
     /etc/ansible/group_vars/raleigh/db_settings
288 288
     /etc/ansible/group_vars/raleigh/cluster_settings
... ...
@@ -134,7 +134,7 @@ class VarsModule(BaseVarsPlugin):
134 134
     def _get_dir_files(self, path):
135 135
 
136 136
         found = []
137
-        for spath in os.listdir(path):
137
+        for spath in sorted(os.listdir(path)):
138 138
             if not spath.startswith(u'.') and not spath.endswith(u'~'):  # skip hidden and backups
139 139
 
140 140
                 ext = os.path.splitext(spath)[-1]