mirror of
https://github.com/k3s-io/k3s-ansible.git
synced 2025-12-25 00:12:37 +01:00
Merge pull request #79 from stafwag/master
Moved Raspberry Pi specifics settings to raspberrypi role
This commit is contained in:
51
roles/raspberrypi/tasks/main.yml
Normal file
51
roles/raspberrypi/tasks/main.yml
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
---
|
||||||
|
- 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_major_version
|
||||||
|
set_fact:
|
||||||
|
detected_distribution_major_version: "{{ ansible_facts.lsb.major_release }}"
|
||||||
|
when:
|
||||||
|
- detected_distribution | default("") == "Raspbian"
|
||||||
|
|
||||||
|
- 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)
|
||||||
8
roles/raspberrypi/tasks/prereq/CentOS.yml
Normal file
8
roles/raspberrypi/tasks/prereq/CentOS.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
- name: Enable cgroup via boot commandline if not already enabled for Centos
|
||||||
|
lineinfile:
|
||||||
|
path: /boot/cmdline.txt
|
||||||
|
backrefs: yes
|
||||||
|
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$'
|
||||||
|
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
|
||||||
|
notify: reboot
|
||||||
@@ -1,13 +1,4 @@
|
|||||||
---
|
---
|
||||||
- name: Test for Raspbian
|
|
||||||
set_fact:
|
|
||||||
raspbian: '{% if
|
|
||||||
( ansible_facts.architecture is search("arm") and
|
|
||||||
ansible_facts.lsb.description is match("[Rr]aspbian.*[Bb]uster") ) or
|
|
||||||
( ansible_facts.architecture is search("aarch64") and
|
|
||||||
ansible_facts.lsb.description is match("Debian.*buster") or
|
|
||||||
ansible_facts.lsb.description is match("[Rr]aspbian.*[Bb]uster") ) %}true{% else %}false{% endif %}'
|
|
||||||
|
|
||||||
- name: Activating cgroup support
|
- name: Activating cgroup support
|
||||||
lineinfile:
|
lineinfile:
|
||||||
path: /boot/cmdline.txt
|
path: /boot/cmdline.txt
|
||||||
@@ -15,13 +6,10 @@
|
|||||||
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
|
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
|
||||||
backrefs: true
|
backrefs: true
|
||||||
notify: reboot
|
notify: reboot
|
||||||
when:
|
|
||||||
- raspbian is true
|
|
||||||
|
|
||||||
- name: Flush iptables before changing to iptables-legacy
|
- name: Flush iptables before changing to iptables-legacy
|
||||||
iptables:
|
iptables:
|
||||||
flush: true
|
flush: true
|
||||||
when: raspbian
|
|
||||||
changed_when: false # iptables flush always returns changed
|
changed_when: false # iptables flush always returns changed
|
||||||
|
|
||||||
- name: Changing to iptables-legacy
|
- name: Changing to iptables-legacy
|
||||||
@@ -29,11 +17,9 @@
|
|||||||
path: /usr/sbin/iptables-legacy
|
path: /usr/sbin/iptables-legacy
|
||||||
name: iptables
|
name: iptables
|
||||||
register: ip4_legacy
|
register: ip4_legacy
|
||||||
when: raspbian
|
|
||||||
|
|
||||||
- name: Changing to ip6tables-legacy
|
- name: Changing to ip6tables-legacy
|
||||||
alternatives:
|
alternatives:
|
||||||
path: /usr/sbin/ip6tables-legacy
|
path: /usr/sbin/ip6tables-legacy
|
||||||
name: ip6tables
|
name: ip6tables
|
||||||
register: ip6_legacy
|
register: ip6_legacy
|
||||||
when: raspbian
|
|
||||||
8
roles/raspberrypi/tasks/prereq/Ubuntu.yml
Normal file
8
roles/raspberrypi/tasks/prereq/Ubuntu.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
- name: Enable cgroup via boot commandline if not already enabled for Ubuntu on a Raspberry Pi
|
||||||
|
lineinfile:
|
||||||
|
path: /boot/firmware/cmdline.txt
|
||||||
|
backrefs: yes
|
||||||
|
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$'
|
||||||
|
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
|
||||||
|
notify: reboot
|
||||||
1
roles/raspberrypi/tasks/prereq/default.yml
Normal file
1
roles/raspberrypi/tasks/prereq/default.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
---
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Enable cgroup via boot commandline if not already enabled for Ubuntu on ARM
|
|
||||||
lineinfile:
|
|
||||||
path: /boot/firmware/cmdline.txt
|
|
||||||
backrefs: yes
|
|
||||||
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$'
|
|
||||||
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
|
|
||||||
when:
|
|
||||||
- ansible_distribution == 'Ubuntu'
|
|
||||||
- ( ansible_facts.architecture is search("arm") or
|
|
||||||
ansible_facts.architecture is search("aarch64") )
|
|
||||||
|
|
||||||
- name: Reboot to enable cgroups for Ubuntu on ARM
|
|
||||||
reboot:
|
|
||||||
when:
|
|
||||||
- ansible_distribution == 'Ubuntu'
|
|
||||||
- ( ansible_facts.architecture is search("arm") or
|
|
||||||
ansible_facts.architecture is search("aarch64") )
|
|
||||||
Reference in New Issue
Block a user