mirror of
https://github.com/techno-tim/k3s-ansible.git
synced 2025-12-25 18:23:05 +01:00
71 lines
2.5 KiB
YAML
71 lines
2.5 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 Raspbian (ARM64 on Debian Buster)
|
|
set_fact:
|
|
detected_distribution: Raspbian
|
|
when:
|
|
- ansible_facts.architecture is search("aarch64")
|
|
- raspberry_pi|default(false)
|
|
- ansible_facts.lsb.description|default("") is match("Debian.*buster")
|
|
|
|
- name: Set detected_distribution to Raspbian (ARM64 on Debian Bookworm)
|
|
set_fact:
|
|
detected_distribution: Raspbian
|
|
when:
|
|
- ansible_facts.architecture is search("aarch64")
|
|
- raspberry_pi|default(false)
|
|
- ansible_facts.lsb.description|default("") is match("Debian.*bookworm")
|
|
|
|
- name: Set detected_distribution_major_version
|
|
set_fact:
|
|
detected_distribution_major_version: "{{ ansible_facts.lsb.major_release }}"
|
|
when:
|
|
- detected_distribution | default("") == "Raspbian"
|
|
|
|
- name: Set detected_distribution to Raspbian (ARM64 on Debian Bullseye)
|
|
set_fact:
|
|
detected_distribution: Raspbian
|
|
when:
|
|
- ansible_facts.architecture is search("aarch64")
|
|
- raspberry_pi|default(false)
|
|
- ansible_facts.lsb.description|default("") is match("Debian.*bullseye")
|
|
|
|
- name: Execute OS related tasks on the Raspberry Pi - {{ action_ }}
|
|
include_tasks: "{{ item }}"
|
|
with_first_found:
|
|
- "{{ action_ }}/{{ detected_distribution }}-{{ detected_distribution_major_version }}.yml"
|
|
- "{{ action_ }}/{{ detected_distribution }}.yml"
|
|
- "{{ action_ }}/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
|
|
- "{{ action_ }}/{{ ansible_distribution }}.yml"
|
|
- "{{ action_ }}/default.yml"
|
|
vars:
|
|
action_: >-
|
|
{% if state == "present" %}setup{% else %}teardown{% endif %}
|
|
when:
|
|
- raspberry_pi|default(false)
|