Skip to content

Fix virtualhost creation being skipped on first playbook run - #130

Open
bidi47 wants to merge 1 commit into
alma-linux-10from
docs/fix-virtualhost-first-run-gate
Open

bidi47 wants to merge 1 commit into
alma-linux-10from
docs/fix-virtualhost-first-run-gate

Conversation

@bidi47

@bidi47 bidi47 commented Sep 24, 2026

Copy link
Copy Markdown
Member
  • Removes the when: sites_enabled_check.stdout == "1" condition gating the
    "Create virtualhosts" task in wsl/roles/virtualhost/tasks/main.yml.
  • On a fresh system, this condition previously evaluated false on the very
    run that added the IncludeOptional sites-enabled/*.conf line, so any
    config.virtualhosts entries were silently skipped until a second
    install.yml run.
  • The underlying create.yml tasks (template + symlink) are already
    idempotent, so removing the gate is safe to run on every invocation.
  • Resolves audit finding test ansible recipe on Windows 10 #2 ("Virtualhosts aren't created on the first run").

The "Create virtualhosts" task was gated on sites_enabled_check.stdout
== "1", but a fresh system's grep returns "0" on the very run that adds
the IncludeOptional line, so configured virtualhosts were silently
skipped until a second run. The underlying create.yml tasks (template +
symlink) are already idempotent, so running them unconditionally is safe.
@bidi47
bidi47 requested a review from arhimede September 24, 2026 15:49
@arhimede

Copy link
Copy Markdown
Member

we need to test and confirm this with @alexmerlin

include_role:
name: virtualhost
tasks_from: create
when: sites_enabled_check.stdout == "1"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TLDR: This checks stops the recipe from attempting to create a virtualhost even when it already exists.


Please explain why do we need to remove this, and more specifically, why only here?
Because, if you look closely, there's another check involving this variable on L19.

The variable is registered on L12 as a result of checking whether "sites-enabled config files are already added to Apache config" (see L10). And, based on its value, certain things happen L14/L24.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants