mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-10-30 14:15:38 -02:30
Fix kubelet.conf server line indentation (#13284)
The lineinfile tasks that rewrite the server field in kubelet.conf replaced the whole line with a hard-coded indentation, corrupting the file when the existing entry was indented differently. Capture the original leading whitespace with a group regexp and restore it via backrefs so the rewrite preserves the surrounding YAML structure. Signed-off-by: longyuxiang <longyuxiang@kylinos.cn>
This commit is contained in:
@@ -103,8 +103,9 @@
|
||||
- name: Update server field in kubelet kubeconfig
|
||||
lineinfile:
|
||||
dest: "{{ kube_config_dir }}/kubelet.conf"
|
||||
regexp: 'server:'
|
||||
line: ' server: {{ kube_apiserver_endpoint }}'
|
||||
regexp: '^(\s+)server: https.*'
|
||||
line: '\1server: {{ kube_apiserver_endpoint }}'
|
||||
backrefs: true
|
||||
backup: true
|
||||
when:
|
||||
- kubeadm_config_api_fqdn is not defined
|
||||
@@ -115,8 +116,9 @@
|
||||
- name: Update server field in kubelet kubeconfig - external lb
|
||||
lineinfile:
|
||||
dest: "{{ kube_config_dir }}/kubelet.conf"
|
||||
regexp: '^ server: https'
|
||||
line: ' server: {{ kube_apiserver_endpoint }}'
|
||||
regexp: '^(\s+)server: https.*'
|
||||
line: '\1server: {{ kube_apiserver_endpoint }}'
|
||||
backrefs: true
|
||||
backup: true
|
||||
when:
|
||||
- ('kube_control_plane' not in group_names)
|
||||
|
||||
Reference in New Issue
Block a user