Skip to content

Commit 17e7fa9

Browse files
authored
Avoid running code on ansiblelint.config import (#1870)
1 parent 99f88e1 commit 17e7fa9

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/ansiblelint/config.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,3 @@ def ansible_version(version: str = "") -> Version:
162162
)
163163
sys.exit(ANSIBLE_MISSING_RC)
164164
return Version(version)
165-
166-
167-
if ansible_collections_path() in os.environ:
168-
collection_list = os.environ[ansible_collections_path()].split(":")

src/ansiblelint/prerun.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@
1313
import tenacity
1414
from packaging import version
1515

16-
from ansiblelint.config import (
17-
ansible_collections_path,
18-
collection_list,
19-
options,
20-
parse_ansible_version,
21-
)
16+
from ansiblelint.config import ansible_collections_path, options, parse_ansible_version
2217
from ansiblelint.constants import (
2318
ANSIBLE_DEFAULT_ROLES_PATH,
2419
ANSIBLE_MIN_VERSION,
@@ -309,6 +304,10 @@ def _prepare_ansible_paths() -> None:
309304
"""Configure Ansible environment variables."""
310305
library_paths: List[str] = []
311306
roles_path: List[str] = []
307+
collection_list: List[str] = []
308+
309+
if ansible_collections_path() in os.environ:
310+
collection_list = os.environ[ansible_collections_path()].split(":")
312311

313312
for path_list, path in (
314313
(library_paths, "plugins/modules"),

0 commit comments

Comments
 (0)