Skip to content

Commit 5ceaf50

Browse files
committed
Isolate testing from user environment
1 parent a4d7d79 commit 5ceaf50

File tree

6 files changed

+12
-5
lines changed

6 files changed

+12
-5
lines changed

.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
# PWD is supposed to be the directory container the .envrc file based on the
3+
# specs. This trick should isolate our testing from user environment.
4+
ANSIBLE_HOME=$PWD/.ansible
5+
ANSIBLE_CONFIG=$PWD/ansible.cfg

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ celerybeat.pid
120120
*.sage.py
121121

122122
# Environments
123-
.env
124123
.venv
125124
env/
126125
venv/
@@ -170,3 +169,4 @@ cython_debug/
170169

171170
.DS_Store
172171
_readthedocs/
172+
.ansible

.tool-versions

Lines changed: 0 additions & 2 deletions
This file was deleted.

ansible.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[defaults]
2+
# isolate project testing from user local setup
3+
collections_path = .

src/ansible_dev_environment/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ def ensure_isolated(self) -> None:
109109
self.output.hint(hint)
110110
errored = True
111111

112-
home_coll = Path.home() / ".ansible/collections/ansible_collections"
112+
home_coll = Path(os.environ.get("ANSIBLE_HOME", "~/.ansible")).expanduser() / "collections/ansible_collections"
113113
if home_coll.exists() and tuple(home_coll.iterdir()):
114114
err = f"Collections found in {home_coll}"
115115
self.output.error(err)
116-
hint = "Run `rm -rf ~/.ansible/collections` to remove them."
116+
hint = f"Run `rm -rf {home_coll}` to remove them or configure ANSIBLE_HOME to point to a different location."
117117
self.output.hint(hint)
118118
errored = True
119119

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package = editable
1818
extras =
1919
test
2020
pass_env =
21+
ANSIBLE_*
2122
CI
2223
CONTAINER_*
2324
DOCKER_*

0 commit comments

Comments
 (0)