diff options
| author | Egor Tensin <egor@tensin.name> | 2025-11-16 00:01:17 +0100 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2025-11-16 00:01:17 +0100 |
| commit | e912ed873c2ab92fed6bc39e27c350413027f1df (patch) | |
| tree | abc0585fa47723e8f49224a0a928958d64fb958a | |
| parent | use import_tasks where possible (diff) | |
| download | infra-ansible-e912ed873c2ab92fed6bc39e27c350413027f1df.tar.gz infra-ansible-e912ed873c2ab92fed6bc39e27c350413027f1df.zip | |
get rid of the more stupid "handlers"
| -rw-r--r-- | roles/apt/handlers/main.yml | 6 | ||||
| -rw-r--r-- | roles/apt/tasks/main.yml | 9 | ||||
| -rw-r--r-- | roles/nfs/handlers/main.yml | 4 | ||||
| -rw-r--r-- | roles/nfs/tasks/main.yml | 7 | ||||
| -rw-r--r-- | roles/pacman/handlers/main.yml | 11 | ||||
| -rw-r--r-- | roles/pacman/tasks/main.yml | 15 | ||||
| -rw-r--r-- | roles/sshd/handlers/main.yml | 6 | ||||
| -rw-r--r-- | roles/sshd/tasks/main.yml | 10 |
8 files changed, 33 insertions, 35 deletions
diff --git a/roles/apt/handlers/main.yml b/roles/apt/handlers/main.yml deleted file mode 100644 index 354104a..0000000 --- a/roles/apt/handlers/main.yml +++ /dev/null @@ -1,6 +0,0 @@ -- name: Reboot - become: true - ansible.builtin.reboot: - # 3 minutes is plenty. - reboot_timeout: 180 - listen: apt_reboot diff --git a/roles/apt/tasks/main.yml b/roles/apt/tasks/main.yml index 1df67d3..a08130d 100644 --- a/roles/apt/tasks/main.yml +++ b/roles/apt/tasks/main.yml @@ -13,7 +13,14 @@ ansible.builtin.apt: update_cache: true upgrade: dist - notify: apt_reboot + register: apt_result + +- name: Reboot + become: true + ansible.builtin.reboot: + # 3 minutes is plenty. + reboot_timeout: 180 + when: apt_result is changed - name: Get dpkg.log ansible.builtin.shell: | diff --git a/roles/nfs/handlers/main.yml b/roles/nfs/handlers/main.yml deleted file mode 100644 index e92820d..0000000 --- a/roles/nfs/handlers/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -- name: Reload NFS mounts - become: true - ansible.builtin.command: /usr/sbin/exportfs -arv - listen: nfs_configured diff --git a/roles/nfs/tasks/main.yml b/roles/nfs/tasks/main.yml index f8045e3..1f1ae3e 100644 --- a/roles/nfs/tasks/main.yml +++ b/roles/nfs/tasks/main.yml @@ -23,4 +23,9 @@ owner: root group: root mode: '644' - notify: nfs_configured + register: exports_conf + +- name: Reload NFS mounts + become: true + when: exports_conf is changed + ansible.builtin.command: /usr/sbin/exportfs -arv diff --git a/roles/pacman/handlers/main.yml b/roles/pacman/handlers/main.yml deleted file mode 100644 index ca9108b..0000000 --- a/roles/pacman/handlers/main.yml +++ /dev/null @@ -1,11 +0,0 @@ -- name: Show upgraded packages - ansible.builtin.debug: - var: pacman_result.packages - listen: pacman_upgraded - -- name: Reboot - become: true - ansible.builtin.reboot: - # 3 minutes is plenty. - reboot_timeout: 180 - listen: pacman_upgraded diff --git a/roles/pacman/tasks/main.yml b/roles/pacman/tasks/main.yml index 5ace9f8..8a787d7 100644 --- a/roles/pacman/tasks/main.yml +++ b/roles/pacman/tasks/main.yml @@ -13,10 +13,19 @@ # this module now reports 'changed' even if only the cache was updated, with # no upgrades; this is the workaround. changed_when: pacman_result.packages is defined and (pacman_result.packages | length > 0) - notify: pacman_upgraded -- name: Reboot if necessary - ansible.builtin.meta: flush_handlers +- name: Post-upgrade + when: pacman_result is changed + block: + - name: Show upgraded packages + ansible.builtin.debug: + var: pacman_result.packages + + - name: Reboot + become: true + ansible.builtin.reboot: + # 3 minutes is plenty. + reboot_timeout: 180 - name: Get list of unneeded dependencies ansible.builtin.command: pacman -Qqdt diff --git a/roles/sshd/handlers/main.yml b/roles/sshd/handlers/main.yml deleted file mode 100644 index 09355a9..0000000 --- a/roles/sshd/handlers/main.yml +++ /dev/null @@ -1,6 +0,0 @@ -- name: Restart sshd - become: true - ansible.builtin.systemd_service: - name: sshd - state: restarted - listen: sshd_restart diff --git a/roles/sshd/tasks/main.yml b/roles/sshd/tasks/main.yml index 46eb0e1..cae0d86 100644 --- a/roles/sshd/tasks/main.yml +++ b/roles/sshd/tasks/main.yml @@ -7,7 +7,11 @@ group: root mode: '644' validate: /usr/sbin/sshd -t -f %s - notify: sshd_restart + register: sshd_conf -- name: Restart sshd service if necessary - ansible.builtin.meta: flush_handlers +- name: Restart sshd + become: true + when: sshd_conf is changed + ansible.builtin.systemd_service: + name: sshd + state: restarted |
