From 194c9c41eb19a4bf82e37c64cffa4f23b0e4fed9 Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Wed, 12 Oct 2016 21:36:52 -0600 Subject: [PATCH] Fix search path for relative paths in roles (fixes #17877) (cherry picked from commit 72f0aaf606aa3399c0713ad1eaac394c3846813c) --- lib/ansible/parsing/dataloader.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ansible/parsing/dataloader.py b/lib/ansible/parsing/dataloader.py index 2b0c9975477..a240e4cf4b3 100644 --- a/lib/ansible/parsing/dataloader.py +++ b/lib/ansible/parsing/dataloader.py @@ -313,7 +313,11 @@ class DataLoader(): search.append(os.path.join(os.path.dirname(b_mydir), b_dirname, b_source)) search.append(os.path.join(b_mydir, b_source)) else: - search.append(os.path.join(b_upath, b_dirname, b_source)) + # don't add dirname if user already is using it in source + if b_source.split(b'/')[0] == b_dirname: + search.append(os.path.join(b_upath, b_source)) + else: + search.append(os.path.join(b_upath, b_dirname, b_source)) search.append(os.path.join(b_upath, b'tasks', b_source)) elif b_dirname not in b_source.split(b'/'): # don't add dirname if user already is using it in source