|
1 | 1 | ---
|
2 | 2 | - name: Test for raspberry pi /proc/cpuinfo
|
3 | 3 | ansible.builtin.command: grep -E "Raspberry Pi|BCM2708|BCM2709|BCM2835|BCM2836" /proc/cpuinfo
|
4 |
| - register: grep_cpuinfo_raspberrypi |
| 4 | + register: raspberrypi_grep_cpuinfo |
5 | 5 | failed_when: false
|
6 | 6 | changed_when: false
|
7 | 7 |
|
8 | 8 | - name: Test for raspberry pi /proc/device-tree/model
|
9 | 9 | ansible.builtin.command: grep -E "Raspberry Pi" /proc/device-tree/model
|
10 |
| - register: grep_device_tree_model_raspberrypi |
| 10 | + register: raspberrypi_grep_device_tree_model |
11 | 11 | failed_when: false
|
12 | 12 | changed_when: false
|
13 | 13 |
|
14 |
| -- name: Set raspberry_pi fact to true |
15 |
| - ansible.builtin.set_fact: |
16 |
| - raspberry_pi: true |
| 14 | +- name: Run Raspberry Pi-specific tasks |
17 | 15 | when:
|
18 |
| - grep_cpuinfo_raspberrypi.rc == 0 or grep_device_tree_model_raspberrypi.rc == 0 |
| 16 | + - raspberrypi_grep_cpuinfo.rc == 0 or raspberrypi_grep_device_tree_model.rc == 0 |
| 17 | + block: |
| 18 | + - name: Set detected_distribution to Raspbian |
| 19 | + # noqa var-naming[no-role-prefix] |
| 20 | + ansible.builtin.set_fact: |
| 21 | + detected_distribution: Raspbian |
| 22 | + when: > |
| 23 | + ansible_facts.lsb.id|default("") == "Raspbian" or |
| 24 | + ansible_facts.lsb.description|default("") is match("[Rr]aspbian.*") |
19 | 25 |
|
20 |
| -- name: Set detected_distribution to Raspbian |
21 |
| - ansible.builtin.set_fact: |
22 |
| - detected_distribution: Raspbian |
23 |
| - when: > |
24 |
| - raspberry_pi|default(false) and |
25 |
| - ( ansible_facts.lsb.id|default("") == "Raspbian" or |
26 |
| - ansible_facts.lsb.description|default("") is match("[Rr]aspbian.*") ) |
| 26 | + - name: Set detected_distribution to Debian |
| 27 | + # noqa var-naming[no-role-prefix] |
| 28 | + ansible.builtin.set_fact: |
| 29 | + detected_distribution: Debian |
| 30 | + when: > |
| 31 | + ansible_facts.lsb.id|default("") == "Debian" or |
| 32 | + ansible_facts.lsb.description|default("") is match("Debian") |
27 | 33 |
|
28 |
| -- name: Set detected_distribution to Debian |
29 |
| - ansible.builtin.set_fact: |
30 |
| - detected_distribution: Debian |
31 |
| - when: > |
32 |
| - raspberry_pi|default(false) and |
33 |
| - ( ansible_facts.lsb.id|default("") == "Debian" or |
34 |
| - ansible_facts.lsb.description|default("") is match("Debian") ) |
| 34 | + - name: Set detected_distribution to ArchLinux (ARM64) |
| 35 | + # noqa var-naming[no-role-prefix] |
| 36 | + ansible.builtin.set_fact: |
| 37 | + detected_distribution: Archlinux |
| 38 | + when: |
| 39 | + - ansible_facts.architecture is search("aarch64") |
| 40 | + - ansible_facts.os_family is match("Archlinux") |
35 | 41 |
|
36 |
| -- name: Set detected_distribution to ArchLinux (ARM64) |
37 |
| - ansible.builtin.set_fact: |
38 |
| - detected_distribution: Archlinux |
39 |
| - when: |
40 |
| - - ansible_facts.architecture is search("aarch64") |
41 |
| - - raspberry_pi|default(false) |
42 |
| - - ansible_facts.os_family is match("Archlinux") |
43 |
| - |
44 |
| -- name: Execute OS related tasks on the Raspberry Pi |
45 |
| - ansible.builtin.include_tasks: "{{ item }}" |
46 |
| - with_first_found: |
47 |
| - - "prereq/{{ detected_distribution }}.yml" |
48 |
| - - "prereq/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml" |
49 |
| - - "prereq/{{ ansible_distribution }}.yml" |
50 |
| - - "prereq/default.yml" |
51 |
| - when: |
52 |
| - - raspberry_pi|default(false) |
| 42 | + - name: Execute OS related tasks on the Raspberry Pi |
| 43 | + ansible.builtin.include_tasks: "{{ item }}" |
| 44 | + with_first_found: |
| 45 | + - "prereq/{{ detected_distribution }}.yml" |
| 46 | + - "prereq/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml" |
| 47 | + - "prereq/{{ ansible_distribution }}.yml" |
| 48 | + - "prereq/default.yml" |
0 commit comments