The indexer entrypoint is now only our CA-import block followed by exec of the image's own /entrypoint.sh, mounted at /infinito-entrypoint.sh with an explicit command. The certs entrypoint is our own script: it downloads the cert tool only from packages.wazuh.com and fails if that download fails, so there is no silent fallback to the dev bucket. The manager node name is passed in as WAZUH_MANAGER_NODE for both compose and swarm.
Tor: use the shared tor block (bond 0.5, enabled when svc-net-tor is in the node's groups, tor pinned on in both variants) so a node serves one network, onion on a Tor node and clearnet otherwise.
SPOT and sizing: WAZUH_INDEXER_URL replaces four hand-built copies of the indexer URL, and the indexer heap is half of mem_limit instead of a hardcoded 1g (unchanged for the current 2g limit).
Fixes: bcrypt_hash rejects secrets over 72 bytes; the Keycloak group-removal helper uses the same resolver as the add helper and checks every response (the realm is no longer URL-encoded, matching the add helper), and a failed cleanup fails an otherwise passing test; the swarm certs generator removes a stale container before each attempt; vm.max_map_count is set before the early handler flush; securityadmin failed_when now needs rc 0 and the success marker.
The regenerated role README also picks up generator drift (mailu to stalwart).
docker stack deploy ignores depends_on, so manager, indexer and dashboard were scheduled together with certs_generator and rejected with 'bind source path does not exist' for the cert files. stack_ready.sh treats a Rejected newest task as fatal, so the converge failed on its first poll whenever certs_generator had not finished first.
In swarm, the certs_generator service is no longer rendered. Instead the stack host pulls the generator image and runs it once with the same entrypoint, env and mounts, before the stack deploys. The run is checked against a completion marker (sha256 of certs.yml plus tool version) and all eight cert files. Compose mode renders the same output as before.
Existing swarm hosts: a host whose Wazuh stack is already running has no marker yet, so the next deploy stops with an explicit error rather than rotating the CA under the live services. Either run 'docker stack rm wazuh' and redeploy, or write the expected marker value given in the error to <instance>/certs.complete, then redeploy. Compose hosts are not affected.
Per Kevin's review: replaced hardcoded usernames (wazuh-wui, kibanaserver,
admin) across wazuh.yml.j2, compose.yml.j2, internal_users.yml.j2,
roles_mapping.yml.j2, config.yml.j2 and 00_core.yml with
lookup('users', ...) references, following the same pattern already
used by web-svc-coturn and web-app-semaphore. New meta/users.yml
declares web-app-wazuh-dashboard (kibanaserver) and web-app-wazuh-api
(wazuh-wui) as service accounts, and references the existing shared
admin key as a dependency (admin: {}), matching the same pattern used
by openbao, pgadmin, checkmk, semaphore and openldap.
Per CodeRabbit's security finding (CWE-269): scoped readonly_auditor's
index_patterns from '*' to 'wazuh-*', matching the role's own stated
'all Wazuh indices' description. The wildcard previously granted read
access to every index on the cluster, including other users' saved
objects and plugin state, beyond what the role needs or describes.
Wazuh carries no network-specific code any more: the onion front-proxy include, WAZUH_DASHBOARD_ONION_DOMAIN, the forked templates/proxy.conf.j2 vhost and the tor exclusive/primary overrides are gone. The role follows the Tor provider default like every other role with a Tor bond; serving one role on several networks returns generically in the multi-network change.
Without the forked vhost nothing forwards X-Forwarded-Host, so the dashboard OIDC redirect base is the static canonical url.base instead of trust_dynamic_headers.
Also: the dashboard port is read from one variable, the Playwright specs share wazuhLoginViaOidc and withBiberInGroup and assert worker-src blob:, PR-added explanatory comments are removed, and the root README lists the role.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
sys-svc-compose's shared 'compose up' handler resolves its chdir target
via lookup('container', application_id, 'directories.instance') fresh
at flush time, not frozen at the moment it's notified. Many roles set
their own identity via set_fact: application_id: <role> as their first
task (svc-db-openldap, web-app-gitlab, svc-ai-litellm, and many more -
a widespread platform convention), which permanently overwrites the
play-wide fact for every host it runs on. web-app-wazuh instead reads
application_id from vars/main.yml (a role var, lower precedence than
set_fact).
If any role using that set_fact pattern runs in the same play after
Wazuh's own notify: compose-up but before whichever later flush point
(sys-stk-front-proxy's meta: flush_handlers) actually fires the
handler - which happens whenever Wazuh's SSO dependency chain
(Keycloak, OpenLDAP, etc.) is deployed in the same play - the handler
silently targets that other role's directory instead of Wazuh's own.
Confirmed on a live CI run: compose up only ever created openresty's
containers, never any wazuh_* container, despite Wazuh's own
compose.yml.j2 rendering correctly beforehand.
This is a general, platform-wide hazard (any set_fact-identity role
downstream of a deferred shared-handler flush is exposed the same
way), not something fixable from inside this role alone - the proper
fix belongs in sys-svc-compose itself, as its own separate change.
This adds an explicit meta: flush_handlers immediately after the last
notify: compose-up task, before vm.max_map_count or the front-proxy
include - closing the vulnerability window entirely from Wazuh's own
task file: application_id is still guaranteed correct at that point,
since the render task immediately prior already required it to be
correct to write to the right path. Nothing after this point in
00_core.yml depends on the compose stack already being up, so the
earlier flush is semantically safe.
Verified via a repro mirroring the exact scenario (notifier role with
an early flush, then a dependency role doing set_fact: application_id)
using real ansible-playbook: the early flush consumes the notification
before the later role's set_fact can run, confirming the fix closes
the window.
plugins/action/uri_retry.py only bypasses its own internal retry loop
when until: is present on the task - but Ansible core's own retry
loop activates on retries: alone, independent of until:
(ansible/executor/task_executor.py:606-609). The 'Wait for Wazuh
indexer to answer HTTPS requests' task had retries: 60 with no
until:, so both loops fired: core's outer loop invoked the plugin
fresh on each of its own 61 attempts, and the plugin's own inner loop
ran its full 61-attempt cycle every time - up to 61x61 = 3,721 HTTP
requests instead of the intended 61, silently multiplying an
intended ~5-minute patience window into hours with zero log
visibility into the inner loop. This is what was actually consuming
the entire CI job timeout on debian/fedora (rc=124), not a genuine
indexer slow-boot or a resource-contention issue.
Added register: wazuh_indexer_ready + until: wazuh_indexer_ready is
succeeded, matching the existing until: <var> is succeeded idiom
already used elsewhere in the repo (svc-db-mariadb, svc-db-postgres).
This makes uri_retry delegate entirely to Ansible core's single retry
loop, as the plugin was actually designed to do.
Verified against a real HTTP server counting actual requests: 16
requests without the fix (exactly (retries+1)^2 = 4^2), 4 requests
with it (exactly retries+1) - both matching the theorized mechanism
precisely. Confirmed the role's only other uri_retry usage already
has until: and is unaffected.
Ansible validates a notified handler name against the play's handler
registry at the moment a task runs, not at flush time. Handler
registration here is play-global and execution-order-dependent (the
whole task graph is dynamic include_role, no static roles: list), so
compose-up (owned by sys-svc-compose, loaded transitively via
sys-stk-backend) only exists once something in the play has actually
included it.
00_core.yml's four notify: compose-up tasks ran before its own
include_role: name: sys-stk-backend, so on any host where nothing else
pre-loads the handler, the first notify hard-fails: 'The requested
handler compose-up was not found...'. This was masked in every prior
live-deploy verification because Keycloak/OpenLDAP (this role's own
run_after dependencies) are themselves compose-based and register the
handler first when deployed on the same host - but the per-role CI
matrix runs Wazuh standalone, with nothing to mask it.
Verified via a minimal two-role reproduction outside the project tree:
the exact failure reproduces with the original ordering and clears
with the fix, using real ansible-playbook, not just code inspection.
Moved the sys-stk-backend include immediately after the once-flag
guard, before all four notify-bearing tasks.
Registers Wazuh's onion vhost with the front proxy and makes OIDC login
work correctly on either domain, following up on Kevin's request to
integrate this into the PR so CI can actually verify it.
- tasks/00_core.yml registers a second, guarded front-proxy include for
the onion domain (WAZUH_DASHBOARD_ONION_DOMAIN | length > 0), using
the same swarm-mode 'dashboard' compose-service-key fix already
applied to the clearnet include.
- The dashboard's OIDC redirect URL is now derived per request
(opensearch_security.openid.trust_dynamic_headers, driven by
X-Forwarded-Host) instead of a single static base_redirect_url that
could only ever match one of the two domains. Requires this role's
own templates/proxy.conf.j2 (forked from sys-svc-proxy's
basic.conf.j2) since the shared vhost template doesn't forward that
header.
- Restores WAZUH_DASHBOARD_ONION_DOMAIN in vars/main.yml, which had
been dropped during an earlier commit-splitting cleanup in this same
branch's history; removes the now-unused WAZUH_DASHBOARD_BASE_URL.
Trimmed on rebuild: the roles/sys-front-tls/ hunks are dropped; they
served only the dual-stack attempt.
Verification status: make lint-ansible / test-lint / test-unit-python
all pass. Not yet exercised against a live svc-net-tor deployment or
real CI onion-mode run - that's the actual verification this commit
unblocks, per Kevin's note that CI can't confirm the implementation
works while this sits uncommitted.
sys-stk-front-proxy's swarm branch resolves the upstream as
<entity>_<service_key>:<port>, and Docker Swarm assigns service DNS
aliases from the actual compose.yml.j2 service key - a Docker-level
naming rule independent of any Ansible meta/services.yml key. The
dashboard entity's meta/services.yml key is deliberately 'console'
(compose.yml.j2's service_name comment: avoids colliding with the
platform's own unrelated web-app-dashboard tile-integration bond), but
its compose service key stayed 'dashboard' by the same deliberate
design. The swarm-mode front-proxy include was passing 'console' as
webserver_proxy_service_key, producing a syntactically valid but
nonexistent DNS name (wazuh_console) - permanent NXDOMAIN, 502 with
zero variation, confirmed against real CI retry logs (three independent
~650s retry windows, never once succeeding).
The earlier swarm-proxy fix (d2142e8f9) verified resolve_upstream()
produced a well-formed string, but never cross-checked it against what
compose.yml.j2 actually registers with Docker - the one field where
Wazuh's entity-key/compose-key split (unique to this role; bluesky and
other precedents have no such split) actually matters.
meta/volumes.yml's config-mount source: for certs-entrypoint.sh and
indexer-entrypoint.sh resolved via abs_role_path_by_application_id - a
controller-local checkout path. docker stack deploy runs delegate_to:
STACK_HOST (roles/sys-svc-compose/handlers/swarm.yml), so under swarm
mode that path doesn't exist on the remote host, and docker stack
deploy failed with 'no such file or directory' once the earlier
healthcheck himBHsescaping fix let it get that far.
Mirrors the existing 'Copy static Wazuh indexer roles.yml' pattern
already in this file: a new copy task ships both static, non-templated
scripts to WAZUH_INSTANCE_DIR on the actual deploy target, gated on
IS_STACK_HOST, before docker stack deploy/config ever runs. volumes.yml
now points source: at that instance-dir path instead.
Verified on a live swarm cluster (make swarm-zombie app=web-app-wazuh):
the copy task ran and succeeded, and the full stack came up healthy
(manager, indexer, dashboard all Up; certs_generator exited 0 as
expected for a one-shot init container; front proxy served a real
301 redirect through OpenResty).
sys-stk-front-proxy's swarm branch (resolve_upstream(), utils/networks/proxy.py)
derives the upstream port from services.<entity>.ports.internal.<kind>, where
<entity> is the bare holder derived from application_id ('wazuh'). Wazuh's
'wazuh' entity carries no ports (manager/indexer/console split the role), so
swarm mode hard-failed with 'needs services.wazuh.ports.internal.http (or
internal_port=)' - a gap invisible in compose mode, which only reads http_port.
web-app-bluesky hits the identical structural gap and works around it by
passing webserver_proxy_service_key/proxy_internal_port explicitly on every
front-proxy include, pointed at the real sub-entity. Applied the same pattern
here, pointed at 'console' (the entity that owns ports.internal.http: 5601).
Verified directly against utils.networks.proxy.resolve_upstream() with
Wazuh's real port config: the old call site reproduces the exact reported
CI error, the new call site resolves to wazuh_console:5601, and compose mode
is unaffected.
Add single-node Wazuh stack (manager, indexer, dashboard) as a new
Ansible role, integrated with the platform's Keycloak realm via native
OIDC and secondary LDAP authorization, with three-tier RBAC.
- Pins wazuh/wazuh-{manager,indexer,dashboard}:4.14.6 and
wazuh-certs-generator:0.0.4 (one-shot cert bootstrap job)
- No external database: wazuh.indexer (OpenSearch) is self-contained
- Auth: native OIDC against Keycloak, working end-to-end after two
infra fixes (JVM cacerts trust for the indexer's outbound calls to
Keycloak, front-proxy vhost wiring)
- LDAP wired as a secondary, authentication-independent authorization
backend (group-based backend_roles enrichment only)
- RBAC: three roles (administrator, security-analyst, readonly-auditor)
via the platform's standard meta/rbac.yml + rbac_group_path pipeline
- Documents a genuine upstream Wazuh bug: wz-home as the default
landing route throws an uncaught client exception for any
non-all_access role; default route moved to OpenSearch Dashboards'
own /app/home
Addressed two full rounds of review feedback (Kevin, Alejandro):
WEB_PROTOCOL usage, service-account naming, comment cleanup, shared
Keycloak-admin-helper extraction, a real TOCTOU race in RBAC test
setup, a Mermaid auth-flow diagram, meta/services.yml placement for
the certs-generator, CA-trust-path SPOT usage, CSP tightening
(including a genuine worker-src: blob: requirement found via live
testing), and a loud (non-silent) dev-bucket fallback warning.
Rebased onto main after a 3-month gap; brought the role in line with
~30 platform-convention changes introduced in that window (swarm
compose-template rules, Tor/onion contract, Playwright timeout/goto
wrappers, file layout, task numbering, comment policy, and more).
Live-deploy verification (9 iterations) found and fixed 6 further
real bugs invisible to lint/unit tests alone:
- credentials.* / meta/schema.yml -> secrets.credentials.* /
meta/secrets.yml (another platform-drift casualty)
- notify: "compose up" -> "compose-up" (day-one handler-name typo)
- local.subnet collision with web-app-mailu's /24
- missing primary: false alongside tor.exclusive: false, which let
the onion domain shadow the clearnet vhost entirely
- a second front-proxy include for the onion domain, later reverted
(see below)
- shared sys-stk-front-proxy/sys-front-tls TLS-lookup keying bug
(app-id-keyed vs. domain-keyed), which silently applied TLS to
Wazuh's onion vhost
The last two are related: enabling genuine dual-stack (clearnet +
onion) reachability for tor.exclusive: false surfaced a real bug in
two shared platform roles. That fix was verified safe against all 103
apps currently in the repo, but is deliberately NOT included here -
shared-role changes deserve their own PR and review, not to ride in
on a single app's feature branch. Wazuh's second front-proxy include
was reverted accordingly; the resulting onion-reachability gap is
documented in the README as a known, platform-scoped limitation.
make test: 5508 passed, 3 failed (all three trace to untracked local
scratch files - Dockerfile.bak, scripts/lab-*.sh - not present in any
CI checkout).