diff --git a/roles/k3s_agent/tasks/main.yml b/roles/k3s_agent/tasks/main.yml index 395c1ac..ab2559a 100644 --- a/roles/k3s_agent/tasks/main.yml +++ b/roles/k3s_agent/tasks/main.yml @@ -1,4 +1,13 @@ --- +- name: Check if system is PXE-booted + command: cat /proc/cmdline + register: boot_cmdline + changed_when: false + +- name: Set fact for PXE-booted system + set_fact: + is_pxe_booted: "{{ 'root=/dev/nfs' in boot_cmdline.stdout }}" + when: boot_cmdline is defined - name: Deploy K3s http_proxy conf include_tasks: http_proxy.yml diff --git a/roles/k3s_agent/templates/k3s.service.j2 b/roles/k3s_agent/templates/k3s.service.j2 index 3be92e3..dac88de 100644 --- a/roles/k3s_agent/templates/k3s.service.j2 +++ b/roles/k3s_agent/templates/k3s.service.j2 @@ -7,11 +7,14 @@ After=network-online.target Type=notify ExecStartPre=-/sbin/modprobe br_netfilter ExecStartPre=-/sbin/modprobe overlay -ExecStart=/usr/local/bin/k3s agent --server https://{{ apiserver_endpoint | ansible.utils.ipwrap }}:6443 --token {{ hostvars[groups[group_name_master | default('master')][0]]['token'] | default(k3s_token) }} {{ extra_agent_args | default("") }} +# Conditional snapshotter based on PXE boot status +ExecStart=/usr/local/bin/k3s agent \ + --server https://{{ apiserver_endpoint | ansible.utils.ipwrap }}:6443 \ + {% if is_pxe_booted | default(false) %}--snapshotter native \ + {% endif %}--token {{ hostvars[groups[group_name_master | default('master')][0]]['token'] | default(k3s_token) }} \ + {{ extra_agent_args | default("") }} KillMode=process Delegate=yes -# Having non-zero Limit*s causes performance problems due to accounting overhead -# in the kernel. We recommend using cgroups to do container-local accounting. LimitNOFILE=1048576 LimitNPROC=infinity LimitCORE=infinity