From 07e3c2797edc2aeb1b7e0e87e7f84950e5d3e8fc Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Sat, 19 Sep 2026 16:22:50 +0200 Subject: [PATCH] Fix pi_standard_setup under --check Skipped command tasks return stdout: "" rather than being undefined, so "src: motd/{{ ...stdout }}" collapsed to "motd/" - a directory - and copy switched to recursive mode, failing with "/etc/motd/: Not a directory". The empty boot-target stdout likewise never equals "multi-user.target", so "Set boot mode to CLI" always reported changed. Run the three read-only commands in check mode. They are all changed_when: false already, so this is safe. Co-Authored-By: Claude Opus 5 --- roles/pi_standard_setup/tasks/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/roles/pi_standard_setup/tasks/main.yml b/roles/pi_standard_setup/tasks/main.yml index 54dba69..8b6b6e4 100644 --- a/roles/pi_standard_setup/tasks/main.yml +++ b/roles/pi_standard_setup/tasks/main.yml @@ -36,6 +36,7 @@ ansible.builtin.command: "raspi-config nonint get_hostname" register: pi_standard_setup_pi_hostname changed_when: false + check_mode: false # read-only; must run in --check so .stdout isn't empty - name: Change hostname {{ pi_standard_setup_new_hostname }} ansible.builtin.command: "raspi-config nonint do_hostname {{ 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 @@ -46,10 +47,12 @@ ansible.builtin.command: "raspi-config nonint get_hostname" register: pi_standard_setup_pi_hostname changed_when: false + check_mode: false # read-only; must run in --check so .stdout isn't empty - name: Get current boot target ansible.builtin.command: "systemctl get-default" register: pi_standard_setup_boot_target changed_when: false + check_mode: false # read-only; must run in --check so .stdout isn't empty - name: Set boot mode to CLI ansible.builtin.command: "raspi-config nonint do_boot_behaviour B1" when: pi_standard_setup_boot_target.stdout != "multi-user.target"