From e208a522fe1d7d2489285018136bd5dee81793e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Althaus?= Date: Thu, 16 Nov 2017 10:37:45 +0100 Subject: [PATCH] Scan group_vars/host_vars in sorted order (cherry picked from commit a9b15ce88169160846d73e3ad5ce19b4154b2e51) --- CHANGELOG.md | 2 ++ docs/docsite/rst/intro_inventory.rst | 2 +- lib/ansible/plugins/vars/host_group_vars.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96cc6e6644e..966912e2b67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -180,6 +180,8 @@ Ansible Changes By Release (https://github.com/ansible/ansible/pull/33100) * restore error on orphan group:vars delcaration for ini inventories https://github.com/ansible/ansible/pull/32866 +* restore host/group_vars merge order + https://github.com/ansible/ansible/pull/32963 diff --git a/docs/docsite/rst/intro_inventory.rst b/docs/docsite/rst/intro_inventory.rst index 3f8d5b430bd..5d7701c147d 100644 --- a/docs/docsite/rst/intro_inventory.rst +++ b/docs/docsite/rst/intro_inventory.rst @@ -282,7 +282,7 @@ the 'raleigh' group might look like:: It is okay if these files do not exist, as this is an optional feature. As an advanced use case, you can create *directories* named after your groups or hosts, and -Ansible will read all the files in these directories. An example with the 'raleigh' group:: +Ansible will read all the files in these directories in lexicographical order. An example with the 'raleigh' group:: /etc/ansible/group_vars/raleigh/db_settings /etc/ansible/group_vars/raleigh/cluster_settings diff --git a/lib/ansible/plugins/vars/host_group_vars.py b/lib/ansible/plugins/vars/host_group_vars.py index 3b531af6e24..d27b337ff03 100644 --- a/lib/ansible/plugins/vars/host_group_vars.py +++ b/lib/ansible/plugins/vars/host_group_vars.py @@ -134,7 +134,7 @@ class VarsModule(BaseVarsPlugin): def _get_dir_files(self, path): found = [] - for spath in os.listdir(path): + for spath in sorted(os.listdir(path)): if not spath.startswith(u'.') and not spath.endswith(u'~'): # skip hidden and backups ext = os.path.splitext(spath)[-1]