Replace block/rescue with ignore_errors/register

Users are always getting triggered by the failed
`systemctl reload-or-restart` command. To potentially reduce confusion,
let's replace block/rescue back to `ignore_errors`, as in this case
Ansible at least printing out `...ignoring` for the raised error,
instead of silently proceeding further, which might help out
to see that the failure is non-critical.

Change-Id: I264e23598dd211c5ddef971d2cc3702f4f2af3b6
This commit is contained in:
Dmitriy Rabotyagov
2025-04-14 17:36:28 +02:00
parent 7fcdd1ddae
commit d497a37e79

View File

@@ -83,18 +83,20 @@
# the task will be rescued and the regular
# systemd module will be attempted before
# failing the task run.
- name: Mount state block
block:
- name: Set the state of the mount # noqa: command-instead-of-module
ansible.builtin.command: "systemctl {{ systemd_mount_states[item.state] }} {{ mount_service_name.stdout }}"
changed_when: false
when:
- item.state is defined
rescue:
- name: Set the state of the mount (fallback)
ansible.builtin.systemd:
name: "{{ mount_service_name.stdout }}"
state: "{{ item.state }}"
- name: Set the state of the mount # noqa: command-instead-of-module
ansible.builtin.command: "systemctl {{ systemd_mount_states[item.state] }} {{ mount_service_name.stdout }}"
changed_when: false
ignore_errors: true
register: set_mount_state_command
when:
- item.state is defined
- name: Set the state of the mount (fallback)
ansible.builtin.systemd:
name: "{{ mount_service_name.stdout }}"
state: "{{ item.state }}"
when:
- set_mount_state_command is failed
- name: Unload mount(s)
ansible.builtin.systemd: