diff options
Diffstat (limited to 'src/ansible_compat/runtime.py')
-rw-r--r-- | src/ansible_compat/runtime.py | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/ansible_compat/runtime.py b/src/ansible_compat/runtime.py index ad81132..4556b7e 100644 --- a/src/ansible_compat/runtime.py +++ b/src/ansible_compat/runtime.py @@ -1,4 +1,5 @@ """Ansible runtime environment manager.""" + from __future__ import annotations import contextlib @@ -94,11 +95,11 @@ class Plugins: # pylint: disable=too-many-instance-attributes lookup: dict[str, str] = field(init=False) netconf: dict[str, str] = field(init=False) shell: dict[str, str] = field(init=False) - vars: dict[str, str] = field(init=False) # noqa: A003 + vars: dict[str, str] = field(init=False) module: dict[str, str] = field(init=False) strategy: dict[str, str] = field(init=False) test: dict[str, str] = field(init=False) - filter: dict[str, str] = field(init=False) # noqa: A003 + filter: dict[str, str] = field(init=False) role: dict[str, str] = field(init=False) keyword: dict[str, str] = field(init=False) @@ -589,6 +590,7 @@ class Runtime: _logger.error(result.stderr) raise AnsibleCommandError(result) + # pylint: disable=too-many-locals def prepare_environment( # noqa: C901 self, required_collections: dict[str, str] | None = None, @@ -608,7 +610,10 @@ class Runtime: # https://docs.ansible.com/ansible-tower/latest/html/userguide/projects.html#ansible-galaxy-support # https://docs.ansible.com/ansible-tower/latest/html/userguide/projects.html#collections-support for req_file in REQUIREMENT_LOCATIONS: - self.install_requirements(Path(req_file), retry=retry, offline=offline) + file_path = Path(req_file) + if self.project_dir: + file_path = self.project_dir / req_file + self.install_requirements(file_path, retry=retry, offline=offline) self._prepare_ansible_paths() @@ -773,13 +778,15 @@ class Runtime: ] alterations_list.extend( - [ - (roles_path, f"{self.cache_dir}/roles", False), - (library_paths, f"{self.cache_dir}/modules", False), - (collections_path, f"{self.cache_dir}/collections", False), - ] - if self.isolated - else [], + ( + [ + (roles_path, f"{self.cache_dir}/roles", False), + (library_paths, f"{self.cache_dir}/modules", False), + (collections_path, f"{self.cache_dir}/collections", False), + ] + if self.isolated + else [] + ), ) for path_list, path_, must_be_present in alterations_list: @@ -853,7 +860,7 @@ class Runtime: fqrn = _get_role_fqrn(galaxy_info, project_dir) if role_name_check in [0, 1]: - if not re.match(r"[a-z0-9][a-z0-9_]+\.[a-z][a-z0-9_]+$", fqrn): + if not re.match(r"[a-z0-9][a-z0-9_-]+\.[a-z][a-z0-9_]+$", fqrn): msg = MSG_INVALID_FQRL.format(fqrn) if role_name_check == 1: _logger.warning(msg) |