Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid duplicates when injecting extra ansible lookup paths #1348

Merged
merged 1 commit into from Feb 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/ansiblelint/_prerun.py
Expand Up @@ -100,17 +100,15 @@ def _prepare_ansible_paths() -> None:
if 'ANSIBLE_LIBRARY' in os.environ:
library_paths = os.environ['ANSIBLE_LIBRARY'].split(':')

if os.path.exists("plugins/modules") and "plugins/modules" not in library_paths:
library_paths.append("plugins/modules")

if os.path.exists(".cache/collections"):
collection_list.append(".cache/collections")
if os.path.exists(".cache/modules"):
library_paths.append(".cache/modules")
if os.path.exists("roles"):
roles_path.append("roles")
if os.path.exists(".cache/roles"):
roles_path.append(".cache/roles")
for path_list, path in (
(library_paths, "plugins/modules"),
(library_paths, ".cache/modules"),
(collection_list, ".cache/collections"),
(roles_path, "roles"),
(roles_path, ".cache/roles"),
):
if path not in path_list and os.path.exists(path):
path_list.append(path)

_update_env('ANSIBLE_LIBRARY', library_paths)
_update_env(ansible_collections_path(), collection_list)
Expand Down