# TBD # Add fan control config for rasp 4 --- - name: Check if Raspi5 lineinfile: path: /proc/cpuinfo regexp: "Raspberry Pi 5" state: absent register: is_raspi5 check_mode: yes changed_when: false - name: Check if Raspi4 lineinfile: path: /proc/cpuinfo regexp: "Raspberry Pi 4" state: absent register: is_raspi4 check_mode: yes changed_when: false - name: Check if PAGESIZE has been set lineinfile: path: /boot/firmware/config.txt regexp: "kernel=kernel8.img" state: absent register: has_pagesize check_mode: yes changed_when: false - name: Set PAGESIZE to 4k blockinfile: dest: /boot/firmware/config.txt marker: "# {mark} ANSIBLE MANAGED BLOCK - PAGESIZE" content: | # Change PAGESIZE to 4k kernel=kernel8.img when: is_raspi5.found and not has_pagesize.found register: pagesize - name: Check if manual fan control is enabled lineinfile: path: /boot/firmware/config.txt regexp: "dtparam=pwm_fan_temp0=255" state: absent register: has_manual_fan_control5 check_mode: yes changed_when: false - name: Enable manual fan control blockinfile: dest: /boot/firmware/config.txt marker: "# {mark} ANSIBLE MANAGED BLOCK - PWM FAN CONTROL" content: | # Enable manual fan control dtparam=pwm_fan_temp0=255 when: is_raspi5.found and not has_manual_fan_control5.found register: fan_control - name: Check if fan control is enabled lineinfile: path: /boot/firmware/config.txt regexp: "dtoverlay=pwm,pin=18,func=2" state: absent register: has_manual_fan_control4 check_mode: yes changed_when: false - name: Enable fan control blockinfile: dest: /boot/firmware/config.txt content: | # Enable fan control dtoverlay=pwm,pin=18,func=2 when: is_raspi4.found and not has_manual_fan_control4.found register: fan_control - name: Reboot to apply changes ansible.builtin.reboot: when: fan_control.changed or (pagesize and pagesize.changed)