test(roles): run molecule's check step before and after converge

Every role scenario with a converge now runs check right before it (a
fresh host) and right after it (a configured host), and a script test
fails a scenario without both. pihole and pve_lxc move their second
check from after idempotence to after converge to match.

The roles that failed under --check on a fresh host get the two allowed
guards: cloudflared, docker, gitea, gitea_runner, traefik and
user_management. ufw and fail2ban preview only a host where their
package is installed, as their READMEs now say.

Closes #134

Assisted-by: Claude Code
This commit is contained in:
Defame1297 committed 2026-11-26 10:11:54 +00:00
1 parent 51b38211e7
commit cf2286b7a7
56 files changed
+202 -35

No files matched your search

+10 -1
View File
@@ -92,6 +92,8 @@
changed_when: false
# Read-only: the script is only generated to be written by the next task, so it must also run in --check.
check_mode: false
# Under --check on a fresh host there is no binary to run.
when: not ansible_check_mode or gitea_installed
tags: [gitea, configure]
- name: Write bash completion to system directory
@@ -102,6 +104,7 @@
owner: root
group: root
mode: "0644"
when: not ansible_check_mode or gitea_installed
tags: [gitea, configure]
- name: Create systemd service file for Gitea
@@ -127,6 +130,7 @@
owner: root
group: root
mode: "0644"
register: __gitea_unit_file
tags: [gitea, configure]
- name: Reload systemd daemon
@@ -164,6 +168,8 @@
name: gitea
enabled: true
state: started
# Under --check a new unit is only simulated, so systemd would not find it.
when: not ansible_check_mode or __gitea_unit_file is not changed
tags: [gitea, configure]
- name: Check Gitea service status
@@ -176,7 +182,10 @@
- name: Fail if Gitea service is not running
ansible.builtin.fail:
msg: "Gitea service is not running"
when: gitea_service_status.status.ActiveState != "active"
when:
- gitea_service_status.status.ActiveState != "active"
# The start above is skipped under --check for a new unit.
- not ansible_check_mode or __gitea_unit_file | default({}) is not changed
tags: [gitea, configure, health]
# The token is minted by the opt-in mint entry point, never here. This sits after the
+2
View File
@@ -39,4 +39,6 @@
that:
- gitea_binary.stat.exists
fail_msg: "Gitea binary not found after download"
# Nothing is downloaded under --check.
when: not ansible_check_mode
tags: [gitea, install, health, update]
+3 -1
View File
@@ -64,7 +64,8 @@
Gitea was not stopped and still runs {{ gitea_installed_version }}.
tags: [gitea, update]
# An include does not pass its tags on to the included tasks, hence apply.
# An include does not pass its tags on to the included tasks, hence apply. Under --check a
# new unit is only simulated, so the stop and start of the swap would not find it.
- name: Swap in the staged Gitea binary
ansible.builtin.include_role:
name: mortis.kamino._binary_update
@@ -76,6 +77,7 @@
_binary_update_staged_path: "{{ gitea_staging_dir }}/gitea"
_binary_update_version_command: ["{{ gitea_install_dir }}/gitea", --version]
_binary_update_expected_version: "{{ gitea_version }}"
when: not ansible_check_mode or __gitea_unit_file | default({}) is not changed
tags: [gitea, update]
always: