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:
1 parent
51b38211e7
commit
cf2286b7a7
56 files changed
+202
-35
No files matched your search
@@ -281,6 +281,7 @@
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
register: __cloudflared_unit_file
|
||||
|
||||
- name: Reload systemd daemon
|
||||
ansible.builtin.systemd:
|
||||
@@ -291,6 +292,8 @@
|
||||
name: cloudflared
|
||||
enabled: true
|
||||
state: started
|
||||
# Under --check a new unit is only simulated, so systemd would not find it.
|
||||
when: not ansible_check_mode or __cloudflared_unit_file is not changed
|
||||
|
||||
- name: Check cloudflared service status
|
||||
ansible.builtin.systemd:
|
||||
@@ -301,5 +304,8 @@
|
||||
- name: Fail if cloudflared service is not running
|
||||
ansible.builtin.fail:
|
||||
msg: "cloudflared service is not running"
|
||||
when: __cloudflared_service_status.status.ActiveState != "active"
|
||||
when:
|
||||
- __cloudflared_service_status.status.ActiveState != "active"
|
||||
# The start above is skipped under --check for a new unit.
|
||||
- not ansible_check_mode or __cloudflared_unit_file | default({}) is not changed
|
||||
tags: [cloudflared, configure, health]
|
||||
@@ -4,6 +4,7 @@
|
||||
ansible.builtin.group:
|
||||
name: "{{ cloudflared_group }}"
|
||||
system: true
|
||||
register: __cloudflared_group_account
|
||||
tags: [cloudflared, prereqs, always]
|
||||
|
||||
- name: Create cloudflared user
|
||||
@@ -15,6 +16,7 @@
|
||||
comment: "Cloudflare Tunnel daemon"
|
||||
system: true
|
||||
create_home: false
|
||||
register: __cloudflared_user_account
|
||||
tags: [cloudflared, prereqs, always]
|
||||
|
||||
- name: Create cloudflared config directory
|
||||
@@ -25,6 +27,8 @@
|
||||
owner: "{{ cloudflared_user }}"
|
||||
group: "{{ cloudflared_group }}"
|
||||
mode: "0750"
|
||||
# Under --check a new account is only simulated, so an existing directory cannot be chowned to it.
|
||||
when: not ansible_check_mode or (__cloudflared_group_account is not changed and __cloudflared_user_account is not changed)
|
||||
tags: [cloudflared, prereqs, always]
|
||||
|
||||
- name: Check if cloudflared binary exists
|
||||
|
||||
@@ -80,7 +80,8 @@
|
||||
cloudflared was not stopped and still runs {{ __cloudflared_installed_version }}.
|
||||
tags: [cloudflared, 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 cloudflared binary
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino._binary_update
|
||||
@@ -93,6 +94,7 @@
|
||||
_binary_update_version_command: ["{{ cloudflared_install_dir }}/cloudflared", --version]
|
||||
_binary_update_expected_version: "{{ cloudflared_version }}"
|
||||
_binary_update_version_regex: '([0-9]{4}\.[0-9]+\.[0-9]+)'
|
||||
when: not ansible_check_mode or __cloudflared_unit_file | default({}) is not changed
|
||||
tags: [cloudflared, update]
|
||||
|
||||
always:
|
||||
|
||||
Reference in new issue
Block a user