mirror of
https://github.com/geerlingguy/ansible-role-kubernetes.git
synced 2024-11-23 19:06:33 +01:00
35 lines
1.2 KiB
YAML
35 lines
1.2 KiB
YAML
---
|
|
- name: Check for existence of kubelet environment file.
|
|
stat:
|
|
path: '{{ kubelet_environment_file_path }}'
|
|
register: kubelet_environment_file
|
|
|
|
- name: Set facts for KUBELET_EXTRA_ARGS task if environment file exists.
|
|
set_fact:
|
|
kubelet_args_path: '{{ kubelet_environment_file_path }}'
|
|
kubelet_args_line: "{{ 'KUBELET_EXTRA_ARGS=' + kubernetes_kubelet_extra_args }}"
|
|
kubelet_args_regexp: '^KUBELET_EXTRA_ARGS='
|
|
when: kubelet_environment_file.stat.exists
|
|
|
|
- name: Set facts for KUBELET_EXTRA_ARGS task if environment file doesn't exist.
|
|
set_fact:
|
|
kubelet_args_path: '/etc/systemd/system/kubelet.service.d/10-kubeadm.conf'
|
|
kubelet_args_line: "{{ 'Environment=\"KUBELET_EXTRA_ARGS=' + kubernetes_kubelet_extra_args + '\"' }}"
|
|
kubelet_args_regexp: '^Environment='
|
|
when: not kubelet_environment_file.stat.exists
|
|
|
|
- name: Configure KUBELET_EXTRA_ARGS.
|
|
lineinfile:
|
|
path: '{{ kubelet_args_path }}'
|
|
line: '{{ kubelet_args_line }}'
|
|
regexp: '{{ kubelet_args_regexp }}'
|
|
state: present
|
|
register: kubelet_config_file
|
|
|
|
- name: Reload systemd unit if args were changed.
|
|
systemd:
|
|
state: restarted
|
|
daemon_reload: true
|
|
name: kubelet
|
|
when: kubelet_config_file is changed
|