From 6feee18292ace835c529d594e37da93350428ed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Moser?= Date: Fri, 16 Jun 2017 18:45:58 +0200 Subject: [PATCH] host_group_vars: skip files having blacklisted ending (#25730) * vars: skip backup files * vars: extend doc for ignored files --- lib/ansible/plugins/vars/host_group_vars.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/vars/host_group_vars.py b/lib/ansible/plugins/vars/host_group_vars.py index 73aeec881c..1d2255d172 100644 --- a/lib/ansible/plugins/vars/host_group_vars.py +++ b/lib/ansible/plugins/vars/host_group_vars.py @@ -23,6 +23,7 @@ DOCUMENTATION: description: - Loads YAML vars into corresponding groups/hosts in group_vars/ and host_vars/ directories. - Files are restricted by extension to one of .yaml, .json, .yml or no extension. + - Hidden (starting with '.') and backup (ending with '~') files and directories are ignored. - Only applies to inventory sources that are existing paths. notes: - It takes the place of the previously hardcoded group_vars/host_vars loading. @@ -121,7 +122,7 @@ class VarsModule(BaseVarsPlugin): found = [] for spath in os.listdir(path): - if not spath.startswith('.'): # skip hidden + if not spath.startswith('.') and not spath.endswith('~'): # skip hidden and backups ext = os.path.splitext(spath)[-1] full_spath = os.path.join(path, spath)