Skip to content

Instantly share code, notes, and snippets.

@nicenemo
Created November 28, 2021 20:35
Show Gist options
  • Save nicenemo/d596f113e431d4a459ee50dae602dc1a to your computer and use it in GitHub Desktop.
Save nicenemo/d596f113e431d4a459ee50dae602dc1a to your computer and use it in GitHub Desktop.
Customize a Raspberry pi image for K3S use
#!ansible-playbook
---
- name: Configure Raspberry Pi image.
hosts: localhost
become: false
connection: local
vars:
mount_point: /mnt/d
cmd_line_path: "{{ mount_point }}/cmdline.txt"
ssh_txt: "{{ mount_point }}/ssh.txt"
cmd_line_parameters: 'cgroup_memory=1 cgroup_enable=memory '
tasks:
- name: Configure cgroup boot parameters in cmdline.txt for k3s usage.
# ensure that the changed line no longer matches so that multiple runs have no effect
replace:
path: "{{ cmd_line_path }}"
regexp: 'quiet init='
replace: "quiet {{ cmd_line_parameters }} init="
backup: yes
- name: Enable ssh service.
# use copy module because file with touch will also touch the file if it is already present
copy:
content: ''
dest: "{{ ssh_txt }}"
force: no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment