Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new Ansible tag for Pi-related steps #2052

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 49 additions & 23 deletions ansible/roles/system/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,73 +1,88 @@
---
- name: Create a config_path variable
ansible.builtin.set_fact:
config_path: "{{ '/boot/config.txt' if ansible_distribution_major_version|int <= 11 else '/boot/firmware/config.txt' }}"
cmdline_path: "{{ '/boot/cmdline.txt' if ansible_distribution_major_version|int <= 11 else '/boot/firmware/cmdline.txt' }}"
config_path: "{{ '/boot/config.txt' if ansible_distribution_major_version | int <= 11 else '/boot/firmware/config.txt' }}"
cmdline_path: "{{ '/boot/cmdline.txt' if ansible_distribution_major_version | int <= 11 else '/boot/firmware/cmdline.txt' }}"

- name: Check NOOBS
ansible.builtin.command: cat {{ config_path }}
register: config_txt
changed_when: false
tags:
- touches_boot_partition
- touches-boot-partition
- raspberry-pi

- name: Make sure we have proper framebuffer depth
ansible.builtin.lineinfile:
dest: "{{ config_path }}"
regexp: ^framebuffer_depth=
line: framebuffer_depth=32
tags:
- touches_boot_partition
- touches-boot-partition
- raspberry-pi

- name: Fix framebuffer bug
ansible.builtin.lineinfile:
dest: "{{ config_path }}"
regexp: ^framebuffer_ignore_alpha=
line: framebuffer_ignore_alpha=1
tags:
- touches_boot_partition
- touches-boot-partition
- raspberry-pi

- name: Add gpu_mem_256 in config.txt if it doesn't exist
ansible.builtin.lineinfile:
path: "{{ config_path }}"
line: gpu_mem_256=96
when: config_txt.stdout.find('gpu_mem_256') == -1
tags:
- touches_boot_partition
- touches-boot-partition
- raspberry-pi

- name: Add gpu_mem_512 in config.txt if it doesn't exist
ansible.builtin.lineinfile:
path: "{{ config_path }}"
line: gpu_mem_512=128
when: config_txt.stdout.find('gpu_mem_512') == -1
tags:
- touches_boot_partition
- touches-boot-partition
- raspberry-pi

- name: Add gpu_mem_1024 in config.txt if it doesn't exist
ansible.builtin.lineinfile:
path: "{{ config_path }}"
line: gpu_mem_1024=196
when: config_txt.stdout.find('gpu_mem_1024') == -1
tags:
- touches_boot_partition
- touches-boot-partition
- raspberry-pi

- name: Add pi4 section in config.txt if it doesn't exist
ansible.builtin.lineinfile:
path: "{{ config_path }}"
line: "\n[pi4]"
when: config_txt.stdout.find('[pi4]') == -1
tags:
- touches-boot-partition
- raspberry-pi

- name: Uncomment out the original dtoverlay config.
ansible.builtin.replace:
dest: "{{ config_path }}"
regexp: '^#\s*(dtoverlay=vc4-kms-v3d)'
replace: '\1'
tags:
- touches-boot-partition
- raspberry-pi

- name: Remove the FKMS config for all devices.
ansible.builtin.lineinfile:
path: "{{ config_path }}"
state: absent
regexp: "^dtoverlay=vc4-fkms-v3d$"
tags:
- touches-boot-partition
- raspberry-pi

- name: Backup kernel boot args
ansible.builtin.copy:
Expand All @@ -78,7 +93,8 @@
mode: "0755"
force: false
tags:
- touches_boot_partition
- touches-boot-partition
- raspberry-pi

- name: Notice for cmdline.txt.orig file
ansible.builtin.debug:
Expand All @@ -94,66 +110,76 @@
force: true
when: config_txt.stdout.find('NOOBS') == -1
tags:
- touches_boot_partition
- touches-boot-partition
- raspberry-pi

- name: For splash screen using Plymouth
ansible.builtin.replace:
dest: "{{ cmdline_path }}"
regexp: (^(?!$)((?!splash).)*$)
replace: \1 splash
when: ansible_distribution_major_version|int >= 7
when: ansible_distribution_major_version | int >= 7
tags:
- touches-boot-partition
- raspberry-pi

- name: Remove blinking cursor
ansible.builtin.replace:
dest: "{{ cmdline_path }}"
regexp: (^(?!$)((?!vt.global_cursor_default=0).)*$)
replace: \1 vt.global_cursor_default=0
when: ansible_distribution_major_version|int >= 7
when: ansible_distribution_major_version | int >= 7
tags:
- touches_boot_partition
- touches-boot-partition
- raspberry-pi

- name: Plymouth ignore serial consoles
ansible.builtin.replace:
dest: "{{ cmdline_path }}"
regexp: (^(?!$)((?!plymouth.ignore-serial-consoles).)*$)
replace: \1 plymouth.ignore-serial-consoles
when: ansible_distribution_major_version|int >= 7
when: ansible_distribution_major_version | int >= 7
tags:
- touches_boot_partition
- touches-boot-partition
- raspberry-pi

- name: Use Systemd as init and quiet boot process
ansible.builtin.replace:
dest: "{{ cmdline_path }}"
regexp: (^(?!$)((?!quiet init=/lib/systemd/systemd).)*$)
replace: \1 quiet init=/lib/systemd/systemd
tags:
- touches_boot_partition
- touches-boot-partition
- raspberry-pi

- name: Set ethN/wlanN names for interfaces
ansible.builtin.replace:
dest: "{{ cmdline_path }}"
regexp: (^(?!$)((?!net\.ifnames=0).)*$)
replace: \1 net.ifnames=0
tags:
- touches_boot_partition
- touches-boot-partition
- raspberry-pi

- name: Set cgroup_enable required by containerd for OOM
ansible.builtin.replace:
dest: "{{ cmdline_path }}"
regexp: (^(?!$)((?!cgroup_enable=memory).)*$)
replace: \1 cgroup_enable=memory
when: ansible_distribution_major_version|int >= 7
when: ansible_distribution_major_version | int >= 7
tags:
- touches_boot_partition
- touches-boot-partition
- raspberry-pi

- name: Set cgroup_memory required by containerd for OOM
ansible.builtin.replace:
dest: "{{ cmdline_path }}"
regexp: (^(?!$)((?!cgroup_memory=1).)*$)
replace: \1 cgroup_memory=1
when: ansible_distribution_major_version|int >= 7
when: ansible_distribution_major_version | int >= 7
tags:
- touches_boot_partition
- touches-boot-partition
- raspberry-pi

# Sometimes in some packages there are no necessary files.
# They are required to install pip dependencies.
Expand Down Expand Up @@ -280,15 +306,15 @@
name: supervisor
state: absent
when:
- ansible_distribution_major_version|int <= 11
- ansible_distribution_major_version | int <= 11

- name: Remove deprecated pip dependencies (>= Debian 12)
ansible.builtin.pip:
name: supervisor
executable: /home/{{ lookup('env', 'USER') }}/installer_venv/bin/pip
state: absent
when:
- ansible_distribution_major_version|int >= 12
- ansible_distribution_major_version | int >= 12

- name: Copy in rc.local
ansible.builtin.copy:
Expand Down
Loading