Skip to content

Commit 8415b33

Browse files
ssbarneaabhikdps
andauthored
Document future test isolation behavior in all ansible-dev-tools (#527)
Related: https://issues.redhat.com/browse/AAP-37861 Co-authored-by: Abhinav Anand <[email protected]>
1 parent e97e50b commit 8415b33

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ When it comes to creating automation content using Ansible, there are several pa
2222
- Simplified Ansible Automation: ansible-dev-tools focuses on crafting your automation scenarios and workflows with speed by reducing boilerplate code without
2323
dealing with the intricacies of managing and integrating different Ansible libraries.
2424

25+
- Promote and provide [test isolation] from system and user environments.
26+
2527
For those looking for an IDE-based experience, we also recommend you get familiar with the [Ansible extension for VSCode](https://marketplace.visualstudio.com/items?itemName=redhat.ansible).
2628

2729
## Included Packages

docs/user-guide/test-isolation.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Test Isolation
2+
3+
!!! note
4+
5+
The test isolation behaviors described below are expected to be fully implemented
6+
by the end of **February 2025** and will affect [ansible-lint][ansible-lint], [molecule][molecule] and [ansible-dev-environment (ade)][ansible-dev-environment] in particular.
7+
8+
One very common problem in software development is reproducibility of test
9+
results across the various environments:
10+
11+
- local development, aka "works on my machine"
12+
- CI/CD testing pipelines
13+
- staging and production environments
14+
15+
A very common source of producing divergent results across these are the
16+
dependencies, which can be:
17+
18+
- used dependencies that are not declared but happen to be installed
19+
on a developer's machine
20+
- different versions of the same dependency
21+
- conflicts between dependencies
22+
23+
Historically, most of ansible-dev-tools tried to address these by installing
24+
dependencies in a controlled way and trying to avoid installing them in the
25+
default user home directory, as this might affect other projects in
26+
an unpredictable way.
27+
28+
Starting with early 2025, all ansible-dev-tools will aim to implement the
29+
following predictable behaviors:
30+
31+
- Prefer being run from within a python virtual environment, warning the user
32+
if this not the case.
33+
- Dynamically modify Ansible environment to prefer installation of dependencies
34+
such as collections, roles and python packages inside the current virtual
35+
environment.
36+
37+
## Isolated mode (virtual environment) \[default\]
38+
39+
This is the recommended way to run ansible-dev-tools. If a virtual environment
40+
is not detected, a warning will be displayed, prompting the user to use one
41+
for better isolation.
42+
43+
It should be noted that our tools will look for a `.venv` directory inside
44+
the current directory if a virtual environment is not already active and will
45+
try to use it if found.
46+
47+
When running ansible-dev-tools inside a virtual environment, the following
48+
things will happen:
49+
50+
- Few Ansible environment variables will be automatically defined in order to
51+
make `ansible-galaxy` install commands to install content (collections and
52+
roles) directly inside the virtual environment. Ansible-core itself is already able to find content from inside the virtual environment and this takes priority over the other paths.
53+
- Dependencies will automatically be installed inside the virtual environment
54+
55+
## Non-isolated mode (outside virtual environments)
56+
57+
When running ansible-dev-tools outside a virtual environment, our tools will
58+
display a warning message explaining the user that the isolation mode is
59+
disabled.
60+
61+
- No alteration of ansible environment variables will be made. This is different
62+
from the previous behaviors of ansible-lint or molecule, which tried to define
63+
these to point to a temporary directory.
64+
65+
---
66+
67+
[moleclue]: https://ansible.readthedocs.io/projects/molecule/
68+
[ansible-lint]: https://ansible.readthedocs.io/projects/lint/
69+
[ansible-dev-environment]: https://ansible.readthedocs.io/projects/dev-environment/

mise.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[tools]
2+
"npm:prettier" = "latest"

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ nav:
9292
- DevSpaces: devspaces.md
9393
- User Guide:
9494
- user-guide/index.md
95+
- Test Isolation: user-guide/test-isolation.md
9596
- Testing: user-guide/testing.md
9697
- Building a Collection: user-guide/building-collection.md
9798
- Content Best Practices: user-guide/content-best-practices.md

0 commit comments

Comments
 (0)