diff --git a/Makefile b/Makefile index ee1bcc5f68..a3fc3e0520 100644 --- a/Makefile +++ b/Makefile @@ -959,4 +959,4 @@ wsl2-systemd-check: .PHONY: wsl2-trust-windows # Trust Windows certificates in WSL2. wsl2-trust-windows: - @bash scripts/system/tls/trust/wsl2.sh \ No newline at end of file + @bash scripts/system/tls/trust/wsl2.sh diff --git a/roles/sys-service/handlers/main.yml b/roles/sys-service/handlers/main.yml index 162a28e43c..8af583adc5 100644 --- a/roles/sys-service/handlers/main.yml +++ b/roles/sys-service/handlers/main.yml @@ -41,7 +41,8 @@ system_service_unit_result: >- {{ system_service_show.stdout_lines | default([]) | select('match', '^Result=') | map('regex_replace', '^Result=', '') | first | default('') | trim }} system_service_unit_exec_status: >- - {{ system_service_show.stdout_lines | default([]) | select('match', '^ExecMainStatus=') | map('regex_replace', '^ExecMainStatus=', '') | first | default('') | trim }} + {{ system_service_show.stdout_lines | default([]) | select('match', '^ExecMainStatus=') | map('regex_replace', '^ExecMainStatus=', '') | first | default('') + | trim }} system_service_debug_unit: "{{ system_service_name }}" system_service_debug_context_lines: - "system_service_id={{ system_service_id }}" @@ -55,5 +56,5 @@ Unable to start service {{ system_service_name }}. See shared service diagnostics above. when: - not (system_service_suppress_flush | bool) - - (systemd_set_state.failed | default(false) | bool) or (system_service_state != omit and (system_service_unit_result not in ['success', ''] or system_service_unit_exec_status - not in ['0', ''])) + - (systemd_set_state.failed | default(false) | bool) or (system_service_state != omit and (system_service_unit_result not in ['success', ''] or + system_service_unit_exec_status not in ['0', ''])) diff --git a/roles/sys-service/vars/main.yml b/roles/sys-service/vars/main.yml index 275e85119f..ad89c55845 100644 --- a/roles/sys-service/vars/main.yml +++ b/roles/sys-service/vars/main.yml @@ -8,7 +8,8 @@ system_service_scope: "system" # 'system' for root units, 'user' for per-login u system_service_unit_dir: "{{ DIR_SYSTEM_SERVICE if system_service_scope == 'system' else DIR_SYSTEM_SERVICE_USER }}" system_service_unit_owner: "{{ 'root' if system_service_scope == 'system' else omit }}" system_service_unit_become: "{{ system_service_scope == 'system' }}" -system_service_systemctl_show: "{{ ['systemctl'] + (['--user'] if system_service_scope == 'user' else []) + ['--no-pager', 'show', '-p', 'Result', '-p', 'ExecMainStatus'] }}" +system_service_systemctl_show: "{{ ['systemctl'] + (['--user'] if system_service_scope == 'user' else []) + ['--no-pager', 'show', '-p', 'Result', '-p', 'ExecMainStatus'] + }}" system_service_role_name: "{{ system_service_id | regex_replace('@','') }}" system_service_role_dir: "{{ lookup('path_absolute', 'roles', system_service_role_name) }}" diff --git a/roles/web-app-nextcloud/meta/addons/bbb.yml b/roles/web-app-nextcloud/meta/addons/bbb.yml index 6cf6253514..662805ccf5 100644 --- a/roles/web-app-nextcloud/meta/addons/bbb.yml +++ b/roles/web-app-nextcloud/meta/addons/bbb.yml @@ -16,4 +16,5 @@ config: configvalue: "{{ lookup('config','web-app-bigbluebutton', 'secrets.credentials.shared_secret', '') }}" - appid: "bbb" configkey: "api.url" - configvalue: "{{ ([lookup('tls', 'web-app-bigbluebutton', 'url.base'), lookup('config', 'web-app-bigbluebutton', 'services.bigbluebutton.api_suffix', '')] | url_join) ~ '/' }}" + configvalue: "{{ ([lookup('tls', 'web-app-bigbluebutton', 'url.base'), lookup('config', 'web-app-bigbluebutton', 'services.bigbluebutton.api_suffix', '')] | + url_join) ~ '/' }}" diff --git a/roles/web-app-nextcloud/meta/addons/integration_openai.yml b/roles/web-app-nextcloud/meta/addons/integration_openai.yml index ef112912f9..452a314f9a 100644 --- a/roles/web-app-nextcloud/meta/addons/integration_openai.yml +++ b/roles/web-app-nextcloud/meta/addons/integration_openai.yml @@ -11,5 +11,4 @@ config: plugin_configuration: - appid: "integration_openai" configkey: "url" - configvalue: "{{ (lookup('tls', 'web-app-openwebui', 'url.origin') ~ '/api') if ('web-app-openwebui' in group_names) else (LITELLM_BASE_LOCAL_URL - ~ '/v1') }}" + configvalue: "{{ (lookup('tls', 'web-app-openwebui', 'url.origin') ~ '/api') if ('web-app-openwebui' in group_names) else (LITELLM_BASE_LOCAL_URL ~ '/v1') }}" diff --git a/roles/web-app-nextcloud/tasks/addons/integration_openproject_provision.yml b/roles/web-app-nextcloud/tasks/addons/integration_openproject_provision.yml index ebe8ce88f7..47bedad88c 100644 --- a/roles/web-app-nextcloud/tasks/addons/integration_openproject_provision.yml +++ b/roles/web-app-nextcloud/tasks/addons/integration_openproject_provision.yml @@ -53,7 +53,8 @@ container exec -i {{ NEXTCLOUD_OPENPROJECT_LOCAL_CID | quote }} bash -lc 'cd /app && bundle exec rails runner -' - stdin: "{{ 'require \"json\"\n' ~ nextcloud_op_provision_input ~ lookup('file', 'ruby/utils/doorkeeper_allow_onion_redirect.rb') ~ '\n' ~ lookup('file', 'ruby/addons/openproject/ensure_nextcloud_storage.rb') }}" + stdin: "{{ 'require \"json\"\n' ~ nextcloud_op_provision_input ~ lookup('file', 'ruby/utils/doorkeeper_allow_onion_redirect.rb') ~ '\n' ~ lookup('file', 'ruby/addons/openproject/ensure_nextcloud_storage.rb') + }}" delegate_to: "{{ NEXTCLOUD_OPENPROJECT_HOST_NODE }}" register: nextcloud_op_storage_create changed_when: >- diff --git a/roles/web-app-seaweedfs/vars/main.yml b/roles/web-app-seaweedfs/vars/main.yml index 23a1089944..3ce1d0adfd 100644 --- a/roles/web-app-seaweedfs/vars/main.yml +++ b/roles/web-app-seaweedfs/vars/main.yml @@ -26,7 +26,8 @@ SEAWEEDFS_S3_REGION: "{{ lookup('config', application_id, 'services.seaweedfs.re # Exception: curl expands the credential itself via --variable, because --user "$VAR" puts it on curl's argv, visible in the host's ps. SEAWEEDFS_S3_ADMIN_CURL: >- container exec -i -e SEAWEEDFS_ADMIN_CREDENTIALS {{ SEAWEEDFS_CONTAINER_ADDRESS }} - sh -c 'exec {{ lookup('timeout', 30) | curl(retries=0) }} -S --aws-sigv4 "aws:amz:{{ SEAWEEDFS_S3_REGION }}:s3" --variable %SEAWEEDFS_ADMIN_CREDENTIALS --expand-user "{{ '{{' }}SEAWEEDFS_ADMIN_CREDENTIALS{{ '}}' }}" "$@"' curl + sh -c 'exec {{ lookup('timeout', 30) | curl(retries=0) }} -S --aws-sigv4 "aws:amz:{{ SEAWEEDFS_S3_REGION }}:s3" --variable %SEAWEEDFS_ADMIN_CREDENTIALS --expand-user + "{{ '{{' }}SEAWEEDFS_ADMIN_CREDENTIALS{{ '}}' }}" "$@"' curl SEAWEEDFS_S3_CONFIG_PATH: "{{ [ lookup('container', application_id, 'directories.volumes'), 's3.json' ] | path_join }}" diff --git a/tests/lint/ansible/roles/test_vhost_cross_cutting_includes.py b/tests/lint/ansible/roles/test_vhost_cross_cutting_includes.py index 087267f4f5..30e9165a9f 100644 --- a/tests/lint/ansible/roles/test_vhost_cross_cutting_includes.py +++ b/tests/lint/ansible/roles/test_vhost_cross_cutting_includes.py @@ -141,7 +141,9 @@ def is_proxy_gated(role: str) -> bool: vhost carries no gate. """ sso = sso_block(role) - return sso is not None and bool(sso.get("enabled")) and sso.get("flavor") == "oauth2" + return ( + sso is not None and bool(sso.get("enabled")) and sso.get("flavor") == "oauth2" + ) def declares_acl(role: str) -> bool: diff --git a/tests/unit/python/roles/web-app-nextcloud/filter_plugins/test_nextcloud_oauth_client.py b/tests/unit/python/roles/web-app-nextcloud/filter_plugins/test_nextcloud_oauth_client.py index d041ec79ba..55ca3c97d9 100644 --- a/tests/unit/python/roles/web-app-nextcloud/filter_plugins/test_nextcloud_oauth_client.py +++ b/tests/unit/python/roles/web-app-nextcloud/filter_plugins/test_nextcloud_oauth_client.py @@ -11,7 +11,10 @@ from . import PROJECT_ROOT def _load_module(): - path = PROJECT_ROOT / "roles/web-app-nextcloud/filter_plugins/nextcloud_oauth_client.py" + path = ( + PROJECT_ROOT + / "roles/web-app-nextcloud/filter_plugins/nextcloud_oauth_client.py" + ) spec = importlib.util.spec_from_file_location("nextcloud_oauth_client", str(path)) module = importlib.util.module_from_spec(spec) assert spec and spec.loader @@ -45,14 +48,22 @@ class TestNextcloudOauthClientState(unittest.TestCase): for action in ("redirect_fixed", "created"): with self.subTest(action=action): state = MODULE.nextcloud_oauth_client_state( - _stdout({"action": action, "id": 7, "client_id": "abc", "removed": 0}) + _stdout( + {"action": action, "id": 7, "client_id": "abc", "removed": 0} + ) ) self.assertTrue(state["changed"]) def test_the_marker_is_found_among_php_notices(self): state = MODULE.nextcloud_oauth_client_state( _stdout( - {"action": "created", "id": 9, "client_id": "x", "client_secret": "s", "removed": 1}, + { + "action": "created", + "id": 9, + "client_id": "x", + "client_secret": "s", + "removed": 1, + }, before="PHP Deprecated: something\n", after="PHP Notice: else\n", ) @@ -63,9 +74,11 @@ class TestNextcloudOauthClientState(unittest.TestCase): def test_a_missing_or_doubled_marker_fails(self): line = _stdout({"action": "unchanged", "id": 1, "client_id": "a", "removed": 0}) for stdout in ("", "PHP Fatal error: class not found\n", line + line): - with self.subTest(stdout=stdout[:20]): - with self.assertRaises(AnsibleFilterError): - MODULE.nextcloud_oauth_client_state(stdout) + with ( + self.subTest(stdout=stdout[:20]), + self.assertRaises(AnsibleFilterError), + ): + MODULE.nextcloud_oauth_client_state(stdout) def test_an_unknown_action_fails(self): with self.assertRaises(AnsibleFilterError): diff --git a/tests/unit/python/roles/web-app-stalwart/test_forward_batch.py b/tests/unit/python/roles/web-app-stalwart/test_forward_batch.py index d0ded36e5b..304599ea3d 100644 --- a/tests/unit/python/roles/web-app-stalwart/test_forward_batch.py +++ b/tests/unit/python/roles/web-app-stalwart/test_forward_batch.py @@ -72,9 +72,7 @@ def _fact(path: str, name: str, fact: str, **variables): def _body(path: str, name: str, **variables) -> dict: task = _task(path, name) return json.loads( - _render( - task["vars"]["stalwart_jmap_body"], **_with_task_vars(task, variables) - ) + _render(task["vars"]["stalwart_jmap_body"], **_with_task_vars(task, variables)) ) @@ -246,7 +244,11 @@ class TestForwardPhases(unittest.TestCase): [ [ "Blob/get", - {"accountId": account, "ids": [blob], "properties": ["data:asText"]}, + { + "accountId": account, + "ids": [blob], + "properties": ["data:asText"], + }, address, ] for address, account, blob in ( diff --git a/tests/unit/python/roles/web-app-stalwart/test_store_guard.py b/tests/unit/python/roles/web-app-stalwart/test_store_guard.py index f5efbe430d..d4fac3929c 100644 --- a/tests/unit/python/roles/web-app-stalwart/test_store_guard.py +++ b/tests/unit/python/roles/web-app-stalwart/test_store_guard.py @@ -32,7 +32,9 @@ PRE_1_0 = "Ensure Stalwart opens no store from before 1.0" MIGRATION = "store_guard/migrate.yml" SKIPPED = {"skipped": True, "changed": False} -NO_MARKER = {"stalwart_store_marker_file": {"changed": False, "stat": {"exists": False}}} +NO_MARKER = { + "stalwart_store_marker_file": {"changed": False, "stat": {"exists": False}} +} def _render(template: str, **variables): @@ -49,7 +51,9 @@ def _module(task: dict, name: str) -> dict | None: def _layout_version() -> str: - return load_yaml_any(str(VARS), default_if_missing={})["STALWART_STORE_LAYOUT_VERSION"] + return load_yaml_any(str(VARS), default_if_missing={})[ + "STALWART_STORE_LAYOUT_VERSION" + ] def _written_marker() -> str: @@ -57,7 +61,8 @@ def _written_marker() -> str: copy = next( t["stack_host_copy"] for t in tasks - if t.get("stack_host_copy", {}).get("dest") == "{{ STALWART_STORE_MARKER_FILE }}" + if t.get("stack_host_copy", {}).get("dest") + == "{{ STALWART_STORE_MARKER_FILE }}" ) return _render(copy["content"], STALWART_STORE_LAYOUT_VERSION=_layout_version()) @@ -80,7 +85,9 @@ def _guard(results: dict[str, dict], *, shared: bool) -> str: } for task in load_yaml_any(str(GUARD), default_if_missing=[]): when = task.get("when", []) - if not all(_holds(c, facts) for c in (when if isinstance(when, list) else [when])): + if not all( + _holds(c, facts) for c in (when if isinstance(when, list) else [when]) + ): if "register" in task: facts[task["register"]] = SKIPPED continue diff --git a/tests/unit/python/utils/packages/test_plan.py b/tests/unit/python/utils/packages/test_plan.py index 990b002b6e..23ebbbf609 100644 --- a/tests/unit/python/utils/packages/test_plan.py +++ b/tests/unit/python/utils/packages/test_plan.py @@ -209,7 +209,9 @@ class TestMergePlans(unittest.TestCase): def test_bootstrap_packages_install_before_every_name(self): epel = {"repo": {"bootstrap_package": "epel-release"}} - merged = merge_plans([_plan("git"), _plan("micro", **epel), _plan("jq", **epel)]) + merged = merge_plans( + [_plan("git"), _plan("micro", **epel), _plan("jq", **epel)] + ) self.assertEqual( [_names(call) for call in merged[0]], [["epel-release"], ["git", "micro", "jq"]], diff --git a/tests/unit/python/utils/packages/test_registry.py b/tests/unit/python/utils/packages/test_registry.py index 0892322ff3..866d12ac92 100644 --- a/tests/unit/python/utils/packages/test_registry.py +++ b/tests/unit/python/utils/packages/test_registry.py @@ -229,15 +229,11 @@ class TestRegistry(unittest.TestCase): self.assertTrue(self._declaration("git").batch) def test_batch_false_keeps_the_id_out_of_the_batch(self): - _write_role( - self.root, "role-a", {"git": {"Debian": ["git"], "batch": False}} - ) + _write_role(self.root, "role-a", {"git": {"Debian": ["git"], "batch": False}}) self.assertFalse(self._declaration("git").batch) def test_the_batch_flag_is_no_distro_key(self): - _write_role( - self.root, "role-a", {"git": {"Debian": ["git"], "batch": False}} - ) + _write_role(self.root, "role-a", {"git": {"Debian": ["git"], "batch": False}}) self.assertIsNone(resolve(self._declaration("git"), "arch")) def test_non_boolean_batch_raises(self): diff --git a/tests/unit/python/utils/roles/test_invocations.py b/tests/unit/python/utils/roles/test_invocations.py index 489c8a9f4d..bc733816c5 100644 --- a/tests/unit/python/utils/roles/test_invocations.py +++ b/tests/unit/python/utils/roles/test_invocations.py @@ -114,7 +114,9 @@ class TestRoleInvocations(_TreeMixin, unittest.TestCase): self.assertEqual(self._invoked(tasks), {"role-b", "role-c"}) def test_quoted_names_are_ignored_while_every_include_resolves(self): - self._write(_role_file("role-a", ROLE_FILE_VARS_MAIN), {"OTHER": "{{ 'role-c' }}"}) + self._write( + _role_file("role-a", ROLE_FILE_VARS_MAIN), {"OTHER": "{{ 'role-c' }}"} + ) self.assertEqual( self._invoked([{"include_role": {"name": "role-b"}}]), {"role-b"} ) @@ -156,9 +158,7 @@ class TestStageInvocations(_TreeMixin, unittest.TestCase): [{"include_role": {"name": "role-b"}, "when": "'role-b' in group_names"}] ) self.assertEqual( - stage_invocations( - path, frozenset(ROLES), seeds=[], group_names=["role-b"] - ), + stage_invocations(path, frozenset(ROLES), seeds=[], group_names=["role-b"]), {"role-b"}, ) @@ -172,15 +172,11 @@ class TestStageInvocations(_TreeMixin, unittest.TestCase): ] ) self.assertEqual( - stage_invocations( - path, frozenset(ROLES), seeds=[], group_names=["role-b"] - ), + stage_invocations(path, frozenset(ROLES), seeds=[], group_names=["role-b"]), set(), ) self.assertEqual( - stage_invocations( - path, frozenset(ROLES), seeds=["role-b"], group_names=[] - ), + stage_invocations(path, frozenset(ROLES), seeds=["role-b"], group_names=[]), {"role-b"}, ) diff --git a/utils/packages/batch.py b/utils/packages/batch.py index 70f820d0c1..64eec9be92 100644 --- a/utils/packages/batch.py +++ b/utils/packages/batch.py @@ -45,4 +45,6 @@ def batch_ids(roles: Iterable[str], project_root: Path) -> list[str]: project_root: repository root holding the package registry. """ by_role = batch_ids_by_role(project_root) - return sorted({package_id for role in roles for package_id in by_role.get(role, ())}) + return sorted( + {package_id for role in roles for package_id in by_role.get(role, ())} + )