Role tweaks (#268)

* Limited boolean values to true/false;

Signed-off-by: Jon S. Stumpf <jon.stumpf@gmail.com>

* Moved ArchLinux prereq task to be a handler;

Signed-off-by: Jon S. Stumpf <jon.stumpf@gmail.com>

* Standardized task name for adding cgroup support;

Signed-off-by: Jon S. Stumpf <jon.stumpf@gmail.com>

* Have backrefs: follow path:;

Signed-off-by: Jon S. Stumpf <jon.stumpf@gmail.com>

* Addressed ansible-lint errors;

Signed-off-by: Jon S. Stumpf <jon.stumpf@gmail.com>

* Fixed #264, task 7: Copy K3s service file;

Signed-off-by: Jon S. Stumpf <jon.stumpf@gmail.com>

---------

Signed-off-by: Jon S. Stumpf <jon.stumpf@gmail.com>
This commit is contained in:
Jon S. Stumpf 2023-12-04 12:46:45 -05:00 committed by GitHub
parent b4237ef24d
commit 4d6e60281e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 29 additions and 24 deletions

View File

@ -6,4 +6,4 @@ rules:
max: 120
level: warning
truthy:
allowed-values: ['true', 'false', 'yes', 'no']
allowed-values: ['true', 'false']

View File

@ -21,16 +21,17 @@
changed_when: true
- name: Copy K3s service file
register: k3s_agent_service
ansible.builtin.template:
src: "k3s-agent.service.j2"
dest: "{{ systemd_dir }}/k3s-agent.service"
owner: root
group: root
mode: 0755
mode: "u=rw,g=r,o=r"
- name: Enable and check K3s service
ansible.builtin.systemd:
name: k3s-agent
daemon_reload: true
state: started
daemon_reload: "{{ true if k3s_agent_service.changed else false }}"
state: "{{ 'restarted' if k3s_agent_service.changed else 'started' }}"
enabled: true

View File

@ -3,7 +3,7 @@
when: ansible_distribution in ['Ubuntu']
ansible.builtin.apt:
name: policycoreutils # Used by install script to restore SELinux context
update_cache: yes
update_cache: true
- name: Enable IPv4 forwarding
ansible.posix.sysctl:

View File

@ -1,3 +1,12 @@
---
- name: Reboot Pi
ansible.builtin.reboot:
post_reboot_delay: 10
reboot_timeout: 60
- name: Regenerate bootloader image
ansible.builtin.command: ./mkscr
args:
chdir: /boot
notify: Reboot Pi
changed_when: true

View File

@ -1,15 +1,9 @@
---
- name: Enable cgroup via boot commandline if not already enabled for Archlinux
- name: Enable cgroup via boot commandline if not already enabled
ansible.builtin.lineinfile:
path: /boot/boot.txt
# yamllint disable-line rule:line-length
search_string: setenv bootargs console=ttyS1,115200 console=tty0 root=PARTUUID=${uuid} rw rootwait smsc95xx.macaddr="${usbethaddr}"
# yamllint disable-line rule:line-length
line: setenv bootargs console=ttyS1,115200 console=tty0 root=PARTUUID=${uuid} rw rootwait smsc95xx.macaddr="${usbethaddr}" cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory
register: kernel_cmdline_cgroup
- name: Create
ansible.builtin.command: ./mkscr
args:
chdir: /boot
notify: Reboot Pi
changed_when: false
when: kernel_cmdline_cgroup.changed # noqa: no-handler
notify: Regenerate bootloader image

View File

@ -1,8 +1,8 @@
---
- name: Enable cgroup via boot commandline if not already enabled for Centos
- name: Enable cgroup via boot commandline if not already enabled
ansible.builtin.lineinfile:
path: /boot/cmdline.txt
backrefs: yes
backrefs: true
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$'
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
notify: Reboot Pi

View File

@ -4,12 +4,12 @@
path: /boot/firmware/cmdline.txt
register: boot_firmware_cmdline_txt
- name: Activating cgroup support
- name: Enable cgroup via boot commandline if not already enabled
ansible.builtin.lineinfile:
path: "{{ (boot_firmware_cmdline_txt.stat.exists) | ternary('/boot/firmware/cmdline.txt', '/boot/cmdline.txt') }}"
backrefs: true
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$'
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
backrefs: true
notify: Reboot Pi
- name: Gather the package facts

View File

@ -1,10 +1,10 @@
---
- name: Activating cgroup support
- name: Enable cgroup via boot commandline if not already enabled
ansible.builtin.lineinfile:
path: /boot/cmdline.txt
backrefs: true
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$'
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
backrefs: true
notify: Reboot Pi
- name: Gather the package facts

View File

@ -1,16 +1,17 @@
---
- name: Enable cgroup via boot commandline if not already enabled for Ubuntu on a Raspberry Pi
- name: Enable cgroup via boot commandline if not already enabled
ansible.builtin.lineinfile:
path: /boot/firmware/cmdline.txt
backrefs: yes
backrefs: true
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$'
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
notify: Reboot Pi
- name: Install Ubuntu Raspi Extra Packages
ansible.builtin.apt:
# Fixes issues in newer Ubuntu where VXLan isn't setup right.
# See: https://github.com/k3s-io/k3s/issues/4234
name: linux-modules-extra-raspi
update_cache: yes
update_cache: true
state: present
when: "ansible_distribution_version is version('20.10', '>=')"