k3s-ansible/roles/raspberrypi/tasks/main.yml
kcir b65b610023
Fix Raspberry tasks for Debian (#151)
* Fix Raspberry tasks for Debian

Signed-off-by: Rick <r.wagenaar@icloud.com>
Signed-off-by: Rick <rick@kcir.nl>

* Move debian yaml files

Signed-off-by: Rick <r.wagenaar@icloud.com>
Signed-off-by: Rick <rick@kcir.nl>

* Add task for Debian to install iptables

Signed-off-by: Rick <rick@kcir.nl>

* Add check for cmdline.txt path for Debian

Signed-off-by: Rick <rick@kcir.nl>

* Remove Debian11 tasks file

Signed-off-by: Rick <rick@kcir.nl>

---------

Signed-off-by: Rick <r.wagenaar@icloud.com>
Signed-off-by: Rick <rick@kcir.nl>
Co-authored-by: Rick <r.wagenaar@icloud.com>
Co-authored-by: Rick <rick@kcir.nl>
2023-11-07 09:53:59 -08:00

53 lines
1.8 KiB
YAML

---
- name: Test for raspberry pi /proc/cpuinfo
command: grep -E "Raspberry Pi|BCM2708|BCM2709|BCM2835|BCM2836" /proc/cpuinfo
register: grep_cpuinfo_raspberrypi
failed_when: false
changed_when: false
- name: Test for raspberry pi /proc/device-tree/model
command: grep -E "Raspberry Pi" /proc/device-tree/model
register: grep_device_tree_model_raspberrypi
failed_when: false
changed_when: false
- name: Set raspberry_pi fact to true
set_fact:
raspberry_pi: true
when:
grep_cpuinfo_raspberrypi.rc == 0 or grep_device_tree_model_raspberrypi.rc == 0
- name: Set detected_distribution to Raspbian
set_fact:
detected_distribution: Raspbian
when: >
raspberry_pi|default(false) and
( ansible_facts.lsb.id|default("") == "Raspbian" or
ansible_facts.lsb.description|default("") is match("[Rr]aspbian.*") )
- name: Set detected_distribution to Debian
set_fact:
detected_distribution: Debian
when: >
raspberry_pi|default(false) and
( ansible_facts.lsb.id|default("") == "Debian" or
ansible_facts.lsb.description|default("") is match("Debian") )
- name: Set detected_distribution_major_version
set_fact:
detected_distribution_major_version: "{{ ansible_facts.lsb.major_release }}"
when: >
( detected_distribution | default("") == "Raspbian" or
detected_distribution | default("") == "Debian" )
- name: execute OS related tasks on the Raspberry Pi
include_tasks: "{{ item }}"
with_first_found:
- "prereq/{{ detected_distribution }}-{{ detected_distribution_major_version }}.yml"
- "prereq/{{ detected_distribution }}.yml"
- "prereq/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
- "prereq/{{ ansible_distribution }}.yml"
- "prereq/default.yml"
when:
- raspberry_pi|default(false)