ansible-role-k3s/templates/k3s.openrc.j2

48 lines
1.3 KiB
Django/Jinja

#!/sbin/openrc-run
depend() {
after network-online
want cgroups
}
start_pre() {
rm -f /tmp/k3s.*
}
supervisor=supervise-daemon
name="k3s"
command="{{ k3s_install_dir }}/k3s"
command_args="{% filter regex_replace('\s+', ' ') %}
{% filter replace('\n', ' ') %}
{% if k3s_debug is defined and k3s_debug %}
--debug
{% endif %}
{% if k3s_control_node %}
server
{% if (k3s_etcd_datastore is defined and k3s_etcd_datastore) and (k3s_primary_control_node is not defined or not k3s_primary_control_node) and k3s_controller_list | length > 1 %}
--server https://{{ k3s_registration_address }}:{{ k3s_control_plane_port | default(6443) | string }}
{% endif %}
{% if k3s_server is defined %}
--config {{ k3s_config_file }}
{% endif %}
{% if k3s_control_node and not k3s_primary_control_node %}
--token-file {{ k3s_token_location }}
{% endif %}
{% else %}
agent
--server https://{{ k3s_registration_address }}:{{ k3s_control_plane_port | default(6443) | string }}
--token-file {{ k3s_token_location }}
{% if k3s_agent is defined %}
--config {{ k3s_config_file }}
{% endif %}
{% endif %} >>/var/log/k3s.log 2>&1"
{% endfilter %}
{% endfilter %}
output_log="/var/log/k3s.log"
error_log="/var/log/k3s.log"
pidfile="/var/run/k3s.pid"
respawn_delay=5
respawn_max=0