Repository navigation
feat(preflight): add preflight validation role - #107
Conversation
Validates the migration environment before seeding AAP: OpenShift API authentication, CNV and MTV operator CSV health, AAP access, vCenter connectivity, and VDDK init image configuration. All checks run and report a summary; the play fails if anything failed. Connection variables cascade from AAP-injected environment variables to inventory host variables resolved through preflight_target_name, preflight_source_name, and preflight_aap_name, so the role runs identically from an AAP job template and from a controller with the sample inventory. Automates the manual "Validate your environment" console checks from the journey documentation. Includes the vmf_preflight.yml playbook and an antsibull changelog fragment.
- Detect k8s probe failure via a missing resources key — failed_when: false clears the failed flag on the registered result, so the probe-failure detail must key off resources absence - Add preflight_aap_api_path option: AAP 2.5 platform deployments serve the controller API at /api/controller/v2/; the default /api/v2/ 404s there (verified live) - Assert only over checks that ran (ran flag on record tasks) so isolated --tags debug runs end green when the targeted check passed - Cascade openshift_temporary_api_key and cluster-host cnv/mtv namespaces from the target host; pass convert_bool to the falsy filter so string-False defaults are caught - Reject plaintext credential-bearing endpoints in pre-validation - Add integration test scaffolding (tests/integration/targets, extensions/molecule)
acfee99 to
621fb0c
Compare
sabre1041
left a comment
There was a problem hiding this comment.
Good start to a preflight check list. A few items:
- Running to the following issue as it relates to verifying vmware
"module_stderr": "Traceback (most recent call last):\n File \"/root/.ansible/tmp/ansible-tmp-1792093923.5295908-74-157229115925727/AnsiballZ_vcenter_datacenter_info.py\", line 107, in <module>\n _ansiballz_main()\n File \"/root/.ansible/tmp/ansible-tmp-1792093923.5295908-74-157229115925727/AnsiballZ_vcenter_datacenter_info.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/root/.ansible/tmp/ansible-tmp-1792093923.5295908-74-157229115925727/AnsiballZ_vcenter_datacenter_info.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.vmware.vmware_rest.plugins.modules.vcenter_datacenter_info', init_globals=dict(_module_fqn='ansible_collections.vmware.vmware_rest.plugins.modules.vcenter_datacenter_info', _modlib_path=modlib_path),\n File \"<frozen runpy>\", line 226, in run_module\n File \"<frozen runpy>\", line 98, in _run_module_code\n File \"<frozen runpy>\", line 88, in _run_code\n File \"/tmp/ansible_vmware.vmware_rest.vcenter_datacenter_info_payload_zx9mk_bn/ansible_vmware.vmware_rest.vcenter_datacenter_info_payload.zip/ansible_collections/vmware/vmware_rest/plugins/modules/vcenter_datacenter_info.py\", line302, in <module>\n File \"/usr/lib64/python3.12/asyncio/base_events.py\", line 691, in run_until_complete\n return future.result()\n ^^^^^^^^^^^^^^^\n File \"/tmp/ansible_vmware.vmware_rest.vcenter_datacenter_info_payload_zx9mk_bn/ansible_vmware.vmware_rest.vcenter_datacenter_info_payload.zip/ansible_collections/vmware/vmware_rest/plugins/modules/vcenter_datacenter_info.py\", line 248, in main\n File \"/tmp/ansible_vmware.vmware_rest.vcenter_datacenter_info_payload_zx9mk_bn/ansible_vmware.vmware_rest.vcenter_datacenter_info_payload.zip/ansible_collections/vmware/vmware_rest/plugins/modules/vcenter_datacenter_info.py\", line 275, in entry_point\n File \"/usr/local/lib64/python3.12/site-packages/aiohttp/client_reqrep.py\", line 777, in json\n raise ContentTypeError(\naiohttp.client_exceptions.ContentTypeError: 404, message='Attempt to decode JSON with unexpected mimetype: text/plain; charset=utf-8', url='https://vcenter.apps.ocpv07.rhdp.net/api/vcenter/datacenter'\nUnclosed client session\nclient_session: <aiohttp.client.ClientSession object at 0xffffa49088f0>\nUnclosed connector\nconnections: ['deque([(<aiohttp.client_proto.ResponseHandler object at 0xffffa3596e40>, 40212.0821937)])']\nconnector: <aiohttp.connector.TCPConnector object at 0xffffa483ce90>\n",
- Whats the best way to ignore certain types of checks. Skipping tags?
- As @tech2734 mentioned, should default
preflight_aap_api_path=/api/controller/v2/ - Provides a suggestion to resolve an issue faced when turning off certificate verification to OpenShift
Assisted-by: opencode:publishers/prelude-maas/models/glm-53-flash
|
Both reviews addressed on
CI green on 7d2a394 (pre-commit, ansible-lint, gitleaks, PR validation). |
|
@sabre1041 — the traceback is tolerated as of What the traceback itself means: the endpoint at On that cluster: A plain-text/HTML 404 page confirms the route (or an intermediate proxy) is not forwarding the path to vCenter — fix the route backend, or point The crash itself is upstream |
The certified vmware.vmware_rest collection requires vCenter 7.0+ and cannot reach 6.x at all (no /api/ tree) — the reporter's cluster runs a 6.5-era vCenter behind a proxy that maps only /sdk and /rest. The fallback uses community.vmware.vmware_datacenter_info (pyVmomi, 6.5+, already a collection dependency) and runs only when the REST probe cannot return data. Module tier justification (community content): certified successor vmware.vmware does not yet ship a datacenter_info module, so this is the only content covering the 6.x path. Assisted-by: opencode:publishers/prelude-maas/models/glm-53-flash
The proxied REST path on 6.x vCenters can answer with an empty datacenter list instead of failing — the fallback now also triggers on that, and the merge prefers a result with datacenters so the check reports the real count via the SOAP SDK. Verified against a 6.5-era vCenter behind a path-mapping proxy: the check reports connectivity + authentication via the SOAP fallback where the certified REST collection cannot reach the API at all. Assisted-by: opencode:publishers/prelude-maas/models/glm-53-flash
Assisted-by: opencode:publishers/prelude-maas/models/glm-53-flash
|
@sabre1041 — the vCenter check now passes against your environment. Verified with a read-only run of the role against What the probes found on that cluster:
The fix ( Module tier note: |
Under ansible-test the target runs from a temp-dir copy where the
repo-relative {{ role_path }}/../../../.. no longer reaches the
collection's roles/ directory. include_role with tasks_from resolves
through the installed collection in both layouts, matching how the
sibling cleanup targets already reference collection content.
Assisted-by: opencode:publishers/prelude-maas/models/glm-53-flash
tech2734
left a comment
There was a problem hiding this comment.
Found a bug during live testing against the homelab environment: the validate_certs cascade silently flips false → true due to the default(true, true) pattern. Two suggestions below.
The inner default(true, true) treated a legitimate false from the inventory as undefined and replaced it with true, silently re-enabling TLS verification for the vCenter and AAP checks. The inner default now catches only an undefined key, matching the openshift_verify_ssl pattern. Assisted-by: opencode:publishers/prelude-maas/models/glm-53-flash
|
Fixed in 166a5cc.
Thanks John for the find, Andy for the pointer. |
What
Adds a
preflightrole andvmf_preflight.ymlplaybook that validate the migration environment before seeding AAP:/api/controller/v2/me/probe (path configurable for AAP 2.4 and earlier)A single summary report fails the play if any check failed, so one run reports everything that needs attention.
Why
The migration playbooks currently fail late and deep — for example, a scheme'd VDDK image reaches the provider CR and Forklift rejects it with
VDDKInitImageUnavailabletwo stages later. Preflight validates the environment up front with an actionable message per check.Design notes
K8S_AUTH_API_KEY,VMWARE_HOST,AAP_*), falling back to the temporary API key alternative documented in the sample inventory. Namespace variables resolve through the target cluster host as well as extra vars.httpsand do not embeduser:pass@.no_logis controlled bypreflight_secure_logging(default true) on all credential-bearing probes; hostnames and usernames appear in success/detail messages, never secrets.--tagsdebug runs end green when the targeted check passed. A source whosetypeis notvmwareskips the vCenter and VDDK checks.Testing
ansible-lint(production profile) passes clean across the role, playbook, and test files.preflight_reportintegration test (tests/integration/targets/preflight_report/, molecule scenariointegration_preflight_report) covers the report summary paths: isolated tagged runs, all-passed full runs with mixed boolean forms, and a failed full run whose summary marks each failed check.include_role, which resolves under ansible-test's temp-dir layout. The recap showsok=18whereinclude_tasksruns showed 24; coverage is unchanged (eight cases, three rescues, two skips).