Skip to content

Commit

Permalink
Disable isolation from ansible-compat Runtime
Browse files Browse the repository at this point in the history
From now on, molecule will not rely on magic alteration of ansible
configuration for role paths, collections or plugins.
  • Loading branch information
ssbarnea committed Jul 10, 2023
1 parent 7584a16 commit e7ccfc7
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
matrix: ${{ fromJson(needs.pre.outputs.matrix) }}

env:
PYTEST_REQPASS: 446
PYTEST_REQPASS: 445
steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion src/molecule/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class App:

def __init__(self) -> None:
"""Create a new app instance."""
self.runtime = Runtime(isolated=True)
self.runtime = Runtime(isolated=False)


app = App()
9 changes: 0 additions & 9 deletions src/molecule/provisioner/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,6 @@ def default_env(self):
# top of the collection_path_list. This prevents dependency commands
# from installing dependencies to user list of collections.
collections_path_list = [
util.abs_path(
os.path.join(
self._config.scenario.config.runtime.cache_dir,
"collections",
),
),
util.abs_path(
os.path.join(self._config.scenario.ephemeral_directory, "collections"),
),
Expand Down Expand Up @@ -499,9 +493,6 @@ def default_env(self):
)

roles_path_list = [
util.abs_path(
os.path.join(self._config.scenario.config.runtime.cache_dir, "roles"),
),
util.abs_path(
os.path.join(self._config.scenario.ephemeral_directory, "roles"),
),
Expand Down
39 changes: 0 additions & 39 deletions src/molecule/test/a_unit/command/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,45 +216,6 @@ def test_execute_cmdline_scenarios_exit_nodestroy(
assert not _patched_sysexit.called


def test_runtime_paths(config_instance: config.Config, _patched_sysexit):
# the ansible_collections_path and ansible_roles_path from the runtime
# should be added to the provisioner's paths
scenario_name = None
args: dict[str, str] = {}
command_args = {"destroy": "never", "subcommand": "verify"}

base.result_callback()
base.execute_cmdline_scenarios(scenario_name, args, command_args)

home = os.path.expanduser("~")
cache_dir = config_instance.runtime.cache_dir
runtime_roles_path = config_instance.runtime.environ.get("ANSIBLE_ROLES_PATH")
assert isinstance(runtime_roles_path, str)
provisioner_roles_path = config_instance.provisioner.env.get("ANSIBLE_ROLES_PATH")
runtime_collections_path = config_instance.runtime.environ.get(
config_instance.ansible_collections_path,
)
assert isinstance(runtime_collections_path, str)
provisioner_collections_path = config_instance.provisioner.env.get(
config_instance.ansible_collections_path,
)

assert runtime_roles_path.startswith(
f"{cache_dir}/roles:"
f"{home}/.ansible/roles:"
f"/usr/share/ansible/roles:"
f"/etc/ansible/roles",
)

assert runtime_collections_path.startswith(
f"{cache_dir}/collections:{home}/.ansible/collections",
)

assert provisioner_roles_path.startswith(f"{cache_dir}/roles")

assert provisioner_collections_path.startswith(f"{cache_dir}/collections")


def test_execute_subcommand(config_instance: config.Config):
# scenario's config.action is mutated in-place for every sequence action,
# so make sure that is currently set to the executed action
Expand Down

0 comments on commit e7ccfc7

Please sign in to comment.