Skip to content

Commit

Permalink
Merge pull request #226 from longns1/main
Browse files Browse the repository at this point in the history
add k3s_service_exec_start_pre_vars for the k3s service
  • Loading branch information
ayr-ton authored Oct 15, 2024
2 parents 19c24bd + 9e07d97 commit 6ff6780
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
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

0 comments on commit 6ff6780

Please sign in to comment.