mirror of
https://github.com/k3s-io/k3s-ansible.git
synced 2025-12-25 00:12:37 +01:00
Remove agent jinja template
* Remove opt_tls_san for agents, it is not a valid agent argument Signed-off-by: Derek Nola <derek.nola@suse.com>
This commit is contained in:
@@ -41,28 +41,6 @@
|
|||||||
}) }}
|
}) }}
|
||||||
changed_when: true
|
changed_when: true
|
||||||
|
|
||||||
- name: Compute final agent arguments
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
_api_endpoint_in_agent_config: >-
|
|
||||||
{% if agent_config_yaml is defined and api_endpoint is defined and agent_config_yaml | regex_search('tls-san:.*' + api_endpoint | regex_escape(), ignorecase=True) %}
|
|
||||||
true
|
|
||||||
{% else %}
|
|
||||||
false
|
|
||||||
{% endif %}
|
|
||||||
_api_endpoint_in_agent_args: >-
|
|
||||||
{% if api_endpoint is defined and extra_agent_args | regex_search('--tls-san[=\s]+' + api_endpoint | regex_escape(), ignorecase=True) %}
|
|
||||||
true
|
|
||||||
{% else %}
|
|
||||||
false
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
- name: Add TLS SAN to agent arguments if needed
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
opt_tls_san: >-
|
|
||||||
{% if api_endpoint is defined and api_endpoint != ansible_hostname and _api_endpoint_in_agent_config | bool == false and _api_endpoint_in_agent_args | bool == false %}
|
|
||||||
--tls-san={{ api_endpoint }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
- name: Setup optional config file
|
- name: Setup optional config file
|
||||||
when: agent_config_yaml is defined
|
when: agent_config_yaml is defined
|
||||||
block:
|
block:
|
||||||
@@ -103,16 +81,18 @@
|
|||||||
with_items:
|
with_items:
|
||||||
- "K3S_TOKEN={{ token }}"
|
- "K3S_TOKEN={{ token }}"
|
||||||
|
|
||||||
- name: Copy K3s service file
|
- name: Modify ExecStart in k3s-agent.service to include API endpoint and extra args
|
||||||
register: k3s_agent_service
|
register: k3s_agent_service
|
||||||
ansible.builtin.template:
|
ansible.builtin.replace:
|
||||||
src: "k3s-agent.service.j2"
|
path: "{{ systemd_dir }}/k3s-agent.service"
|
||||||
dest: "{{ systemd_dir }}/k3s-agent.service"
|
regexp: '^ExecStart=\/usr\/local\/bin\/k3s \\\n\s*agent.*'
|
||||||
owner: root
|
replace: |
|
||||||
group: root
|
ExecStart=/usr/local/bin/k3s \
|
||||||
mode: "u=rw,g=r,o=r"
|
agent \
|
||||||
|
--server https://{{ api_endpoint }}:{{ api_port }} \
|
||||||
|
{{ extra_agent_args }}
|
||||||
|
|
||||||
- name: Enable and check K3s service
|
- name: Enable and check K3s agent service
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: k3s-agent
|
name: k3s-agent
|
||||||
daemon_reload: "{{ true if k3s_agent_service.changed else false }}"
|
daemon_reload: "{{ true if k3s_agent_service.changed else false }}"
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Lightweight Kubernetes
|
|
||||||
Documentation=https://k3s.io
|
|
||||||
Wants=network-online.target
|
|
||||||
After=network-online.target
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=notify
|
|
||||||
EnvironmentFile=-/etc/default/%N
|
|
||||||
EnvironmentFile=-/etc/sysconfig/%N
|
|
||||||
EnvironmentFile=-/etc/systemd/system/k3s-agent.service.env
|
|
||||||
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
|
|
||||||
TasksMax=infinity
|
|
||||||
TimeoutStartSec=0
|
|
||||||
Restart=always
|
|
||||||
RestartSec=5s
|
|
||||||
ExecStartPre=/bin/sh -xc '! /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service'
|
|
||||||
ExecStartPre=-/sbin/modprobe br_netfilter
|
|
||||||
ExecStartPre=-/sbin/modprobe overlay
|
|
||||||
ExecStart=/usr/local/bin/k3s agent --data-dir {{ k3s_server_location }} --server https://{{ api_endpoint }}:{{ api_port }} {{ opt_tls_san }} {{ extra_agent_args }}
|
|
||||||
Reference in New Issue
Block a user