Give each role's reboot handler its own name
pi_standard_setup, pi_hifiberry_amp and pi_disable_onboard_bluetooth each defined a handler called "Reboot". Handler names are play-global, so a notify ran only the last one defined - pi_disable_onboard_bluetooth's - and with that role's `when:`. On every host where onboard Bluetooth stays on, the handler was skipped and nothing that asked for a reboot ever got one: not a changed dtoverlay, not a hostname change, not the Pi 5 kernel. Seen on musicdolphin, where a new HiFiBerry overlay sat unapplied in config.txt after a clean run. Each role now notifies a handler only it defines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: Reboot
|
# Handler names are play-global: if several roles define the same name, only the
|
||||||
|
# last one defined runs, under *that* role's `when:`. A shared "Reboot" therefore
|
||||||
|
# never fired while pi_disable_onboard_bluetooth (usually switched off) defined one
|
||||||
|
# too. Keep this name unique to the role.
|
||||||
|
- name: Reboot after disabling onboard Bluetooth
|
||||||
ansible.builtin.reboot:
|
ansible.builtin.reboot:
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
path: /boot/firmware/config.txt
|
path: /boot/firmware/config.txt
|
||||||
regexp: "^#?dtoverlay=disable-bt"
|
regexp: "^#?dtoverlay=disable-bt"
|
||||||
line: "dtoverlay=disable-bt"
|
line: "dtoverlay=disable-bt"
|
||||||
notify: Reboot
|
notify: Reboot after disabling onboard Bluetooth
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: Reboot
|
# Handler names are play-global: if several roles define the same name, only the
|
||||||
|
# last one defined runs, under *that* role's `when:`. A shared "Reboot" therefore
|
||||||
|
# never fired while pi_disable_onboard_bluetooth (usually switched off) defined one
|
||||||
|
# too. Keep this name unique to the role.
|
||||||
|
- name: Reboot after HiFiBerry boot config change
|
||||||
ansible.builtin.reboot:
|
ansible.builtin.reboot:
|
||||||
|
|||||||
@@ -4,13 +4,13 @@
|
|||||||
path: /boot/config.txt
|
path: /boot/config.txt
|
||||||
regexp: "^#?dtparam=audio=on"
|
regexp: "^#?dtparam=audio=on"
|
||||||
line: "#dtparam=audio=on"
|
line: "#dtparam=audio=on"
|
||||||
notify: Reboot
|
notify: Reboot after HiFiBerry boot config change
|
||||||
- name: Activate Hifiberry
|
- name: Activate Hifiberry
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /boot/firmware/config.txt
|
path: /boot/firmware/config.txt
|
||||||
regexp: "^#?dtoverlay=hifiberry-amp"
|
regexp: "^#?dtoverlay=hifiberry-amp"
|
||||||
line: "dtoverlay={{ hifiberry_overlay }}"
|
line: "dtoverlay={{ hifiberry_overlay }}"
|
||||||
notify: Reboot
|
notify: Reboot after HiFiBerry boot config change
|
||||||
- name: Lift the Pi 5's USB current cap when the HiFiBerry board powers it
|
- name: Lift the Pi 5's USB current cap when the HiFiBerry board powers it
|
||||||
# A Pi 5 fed over the GPIO header has no USB-C power negotiation, so it assumes a
|
# A Pi 5 fed over the GPIO header has no USB-C power negotiation, so it assumes a
|
||||||
# weak supply and limits USB ports to 600mA. Unknown to a Pi 4, which ignores it.
|
# weak supply and limits USB ports to 600mA. Unknown to a Pi 4, which ignores it.
|
||||||
@@ -20,4 +20,4 @@
|
|||||||
line: "usb_max_current_enable=1"
|
line: "usb_max_current_enable=1"
|
||||||
insertafter: EOF
|
insertafter: EOF
|
||||||
when: hifiberry_powers_pi
|
when: hifiberry_powers_pi
|
||||||
notify: Reboot
|
notify: Reboot after HiFiBerry boot config change
|
||||||
|
|||||||
@@ -3,7 +3,11 @@
|
|||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
name: sshd
|
name: sshd
|
||||||
state: restarted
|
state: restarted
|
||||||
- name: Reboot
|
# Handler names are play-global: if several roles define the same name, only the
|
||||||
|
# last one defined runs, under *that* role's `when:`. A shared "Reboot" therefore
|
||||||
|
# never fired while pi_disable_onboard_bluetooth (usually switched off) defined one
|
||||||
|
# too. Keep this name unique to the role.
|
||||||
|
- name: Reboot after standard setup
|
||||||
ansible.builtin.reboot:
|
ansible.builtin.reboot:
|
||||||
- name: Restart raspi-leds-off
|
- name: Restart raspi-leds-off
|
||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
when: pi_standard_setup_new_hostname | length > 0 and pi_standard_setup_pi_hostname.stdout != pi_standard_setup_new_hostname
|
when: pi_standard_setup_new_hostname | length > 0 and pi_standard_setup_pi_hostname.stdout != pi_standard_setup_new_hostname
|
||||||
register: pi_standard_setup_set_hostname
|
register: pi_standard_setup_set_hostname
|
||||||
changed_when: true
|
changed_when: true
|
||||||
notify: Reboot
|
notify: Reboot after standard setup
|
||||||
- name: Get hostname
|
- name: Get hostname
|
||||||
ansible.builtin.command: "raspi-config nonint get_hostname"
|
ansible.builtin.command: "raspi-config nonint get_hostname"
|
||||||
register: pi_standard_setup_pi_hostname
|
register: pi_standard_setup_pi_hostname
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
cache_valid_time: 7200
|
cache_valid_time: 7200
|
||||||
state: present
|
state: present
|
||||||
when: pi_standard_setup_install_pi5_kernel
|
when: pi_standard_setup_install_pi5_kernel
|
||||||
notify: Reboot
|
notify: Reboot after standard setup
|
||||||
- name: Copy vim config
|
- name: Copy vim config
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: vimrc
|
src: vimrc
|
||||||
|
|||||||
Reference in New Issue
Block a user