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 k3s_service_exec_start_pre_vars for the k3s service #226

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ k3s_service_env_vars: {}
# the target as this role will not populate this file.
k3s_service_env_file: false

# Additional ExecStartPre commands for the k3s service in systemd
# This dictionary can be used to specify additional ExecStartPre commands
# for the k3s service. These commands will be executed before the main
# service starts. For example, the command below removes the
# cpu_manager_state file if it exists.
#
# Usage example:
# k3s_service_exec_start_pre_vars:
# - "-/usr/bin/rm -f /var/lib/kubelet/cpu_manager_state"
#
# Note: The "-" prefix before the command ensures that systemd ignores
# any errors that occur when executing the command.
k3s_service_exec_start_pre_vars: {}

##
# Server Configuration
Expand Down
5 changes: 5 additions & 0 deletions templates/k3s.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ EnvironmentFile={{ k3s_service_env_file }}
ExecStartPre=/bin/sh -xc '! /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service'
ExecStartPre=-/sbin/modprobe br_netfilter
ExecStartPre=-/sbin/modprobe overlay
{% if k3s_service_exec_start_pre_vars is defined and k3s_service_exec_start_pre_vars is iterable %}
{% for exec_start_pre_var in k3s_service_exec_start_pre_vars %}
ExecStartPre={{ exec_start_pre_var }}
{% endfor %}
{% endif %}
{% filter regex_replace('\s+', ' ') %}
{% filter replace('\n', ' ') %}
ExecStart={{ k3s_install_dir }}/k3s
Expand Down