Skip to content

Commit 4792ce2

Browse files
Merge branch 'main' into task/main/fix_documentation_links
2 parents 9a52e1d + 54e52eb commit 4792ce2

File tree

8 files changed

+91
-36
lines changed

8 files changed

+91
-36
lines changed

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ jobs:
2929
with:
3030
fetch-depth: 0 # needed by setuptools-scm
3131
- name: Build dists
32-
run: python -m tox -e pkg
32+
run: python3 -m tox -e pkg
3333
- name: Publish to pypi.org
3434
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/tox.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
matrix: ${{ fromJson(needs.pre.outputs.matrix) }}
4848

4949
env:
50-
PYTEST_REQPASS: 450
50+
PYTEST_REQPASS: 452
5151
environment: test
5252
steps:
5353
- uses: actions/checkout@v4

docs/ci.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@ steps:
197197
inputs:
198198
versionSpec: "3.10"
199199
200-
- script: python -m pip install "molecule[lint]" "python-vagrant" "molecule-vagrant" "ansible"
200+
- script: python3 -m pip install "molecule[lint]" "python-vagrant" "molecule-vagrant" "ansible"
201201
displayName: Install dependencies
202202
203-
- script: python -m pip install "python-tss-sdk"
203+
- script: python3 -m pip install "python-tss-sdk"
204204
displayName: Role-specific dependencies
205205
206206
- script: |

docs/installation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ $ python3 -m pip install --user "molecule-plugins[podman]"
9393

9494
Installing molecule package also installed its main script `molecule`,
9595
usually in `PATH`. Users should know that molecule can also be called as
96-
a python module, using `python -m molecule ...`. This alternative method
96+
a python module, using `python3 -m molecule ...`. This alternative method
9797
has some benefits:
9898

9999
- allows to explicitly control which Python interpreter is used by

src/molecule/provisioner/ansible.py

+40-26
Original file line numberDiff line numberDiff line change
@@ -515,32 +515,7 @@ def default_env(self):
515515
self._config.ansible_collections_path: ":".join(collections_path_list),
516516
"ANSIBLE_LIBRARY": ":".join(self._get_modules_directories()),
517517
"ANSIBLE_FILTER_PLUGINS": ":".join(
518-
[
519-
self._get_filter_plugin_directory(),
520-
util.abs_path(
521-
os.path.join(
522-
self._config.scenario.ephemeral_directory,
523-
"plugins",
524-
"filter",
525-
),
526-
),
527-
util.abs_path(
528-
os.path.join(
529-
self._config.project_directory,
530-
"plugins",
531-
"filter",
532-
),
533-
),
534-
util.abs_path(
535-
os.path.join(
536-
os.path.expanduser("~"),
537-
".ansible",
538-
"plugins",
539-
"filter",
540-
),
541-
),
542-
"/usr/share/ansible/plugins/filter",
543-
],
518+
self._get_filter_plugins_directories(),
544519
),
545520
},
546521
)
@@ -1012,5 +987,44 @@ def _get_modules_directories(self) -> list[str]:
1012987
def _get_filter_plugin_directory(self):
1013988
return util.abs_path(os.path.join(self._get_plugin_directory(), "filter"))
1014989

990+
def _get_filter_plugins_directories(self) -> list[str]:
991+
"""Return list of ansilbe filter plugins includes directories."""
992+
paths: list[str | None] = []
993+
if os.environ.get("ANSIBLE_FILTER_PLUGINS"):
994+
paths = list(
995+
map(util.abs_path, os.environ["ANSIBLE_FILTER_PLUGINS"].split(":")),
996+
)
997+
998+
paths.extend(
999+
[
1000+
self._get_filter_plugin_directory(),
1001+
util.abs_path(
1002+
os.path.join(
1003+
self._config.scenario.ephemeral_directory,
1004+
"plugins",
1005+
"filter",
1006+
),
1007+
),
1008+
util.abs_path(
1009+
os.path.join(
1010+
self._config.project_directory,
1011+
"plugins",
1012+
"filter",
1013+
),
1014+
),
1015+
util.abs_path(
1016+
os.path.join(
1017+
os.path.expanduser("~"),
1018+
".ansible",
1019+
"plugins",
1020+
"filter",
1021+
),
1022+
),
1023+
"/usr/share/ansible/plugins/filter",
1024+
],
1025+
)
1026+
1027+
return [path for path in paths if path is not None]
1028+
10151029
def _absolute_path_for(self, env, key):
10161030
return ":".join([self.abs_path(p) for p in env[key].split(":")])

test/a_unit/provisioner/test_ansible.py

+41
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,47 @@ def test_get_filter_plugin_directory(_instance):
749749
assert x == parts[-5:]
750750

751751

752+
def test_get_filter_plugins_directories_default(_instance, monkeypatch):
753+
monkeypatch.delenv("ANSIBLE_FILTER_PLUGINS", raising=False)
754+
755+
paths = _instance._get_filter_plugins_directories()
756+
757+
assert len(paths) == 5
758+
assert re.search(r"molecule/provisioner/ansible/plugins/filter$", paths[0])
759+
assert re.search(r"\.cache/molecule/[^/]+/default/plugins/filter$", paths[1])
760+
assert re.search(r"/filter$", paths[2])
761+
assert re.search(r"\.ansible/plugins/filter$", paths[3])
762+
assert re.search(r"/usr/share/ansible/plugins/filter$", paths[4])
763+
764+
765+
def tes_get_filter_plugins_directories_single_ansible_filter_plugins(
766+
_instance,
767+
monkeypatch,
768+
):
769+
monkeypatch.setenv("ANSIBLE_FILTER_PLUGINS", "/abs/path/plugins/filter")
770+
771+
paths = _instance._get_filter_plugins_directories()
772+
773+
assert len(paths) == 6
774+
assert paths[0] == "/abs/path/plugins/filter"
775+
776+
777+
def test_get_filter_plugins_directories_multi_ansible_filter_plugins(
778+
_instance,
779+
monkeypatch,
780+
):
781+
monkeypatch.setenv(
782+
"ANSIBLE_FILTER_PLUGINS",
783+
"relpath/plugins/filter:/abs/path/plugins/filter",
784+
)
785+
786+
paths = _instance._get_filter_plugins_directories()
787+
788+
assert len(paths) == 7
789+
assert paths[0].endswith("relpath/plugins/filter")
790+
assert paths[1] == "/abs/path/plugins/filter"
791+
792+
752793
def test_absolute_path_for(_instance):
753794
env = {"foo": "foo:bar"}
754795
x = ":".join(

test/scenarios/verifier/.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ repos:
44
hooks:
55
- id: flake8
66
name: flake8
7-
entry: python -m flake8 --max-line-length=120
7+
entry: python3 -m flake8 --max-line-length=120
88
language: system
99
types: [python]

tox.ini

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ commands =
5555
# failsafe as pip may install incompatible dependencies
5656
pip check
5757
# failsafe for preventing changes that may break pytest collection
58-
sh -c "PYTEST_ADDOPTS= python -m pytest -p no:cov --collect-only >>/dev/null"
58+
sh -c "PYTEST_ADDOPTS= python3 -m pytest -p no:cov --collect-only >>/dev/null"
5959
sh -c "rm -f .tox/.coverage.*"
6060
# html report is used by Zuul CI to display reports
6161
coverage run -m pytest {env:_EXTRAS} {env:PYTEST_ADDOPTS:} {posargs}
@@ -71,7 +71,7 @@ description = Runs all linting tasks
7171
basepython = python3.10
7272
commands =
7373
# to run a single linter you can do "pre-commit run flake8"
74-
python -m pre_commit run {posargs:--all --show-diff-on-failure}
74+
python3 -m pre_commit run {posargs:--all --show-diff-on-failure}
7575
deps =
7676
pre-commit>=2.21.0
7777
check-jsonschema>=0.20.0
@@ -105,11 +105,11 @@ deps =
105105
setenv =
106106
commands =
107107
rm -rfv {toxinidir}/dist/
108-
python -m build \
108+
python3 -m build \
109109
--outdir {toxinidir}/dist/ \
110110
{toxinidir}
111111
# metadata validation
112-
sh -c "python -m twine check --strict {toxinidir}/dist/*"
112+
sh -c "python3 -m twine check --strict {toxinidir}/dist/*"
113113

114114
[testenv:snap]
115115
description = Builds a snap package

0 commit comments

Comments
 (0)