Skip to content

Commit

Permalink
Avoid duplicates when injecting extra ansible lookup paths (#1348)
Browse files Browse the repository at this point in the history
  • Loading branch information
joren485 committed Feb 14, 2021
1 parent 99366d2 commit e99b2cc
Showing 1 changed file with 9 additions and 11 deletions.
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

0 comments on commit e99b2cc

Please sign in to comment.