mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-10-31 06:26:19 -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
|
- name: Update server field in kubelet kubeconfig
|
||||||
lineinfile:
|
lineinfile:
|
||||||
dest: "{{ kube_config_dir }}/kubelet.conf"
|
dest: "{{ kube_config_dir }}/kubelet.conf"
|
||||||
regexp: 'server:'
|
regexp: '^(\s+)server: https.*'
|
||||||
line: ' server: {{ kube_apiserver_endpoint }}'
|
line: '\1server: {{ kube_apiserver_endpoint }}'
|
||||||
|
backrefs: true
|
||||||
backup: true
|
backup: true
|
||||||
when:
|
when:
|
||||||
- kubeadm_config_api_fqdn is not defined
|
- kubeadm_config_api_fqdn is not defined
|
||||||
@@ -115,8 +116,9 @@
|
|||||||
- name: Update server field in kubelet kubeconfig - external lb
|
- name: Update server field in kubelet kubeconfig - external lb
|
||||||
lineinfile:
|
lineinfile:
|
||||||
dest: "{{ kube_config_dir }}/kubelet.conf"
|
dest: "{{ kube_config_dir }}/kubelet.conf"
|
||||||
regexp: '^ server: https'
|
regexp: '^(\s+)server: https.*'
|
||||||
line: ' server: {{ kube_apiserver_endpoint }}'
|
line: '\1server: {{ kube_apiserver_endpoint }}'
|
||||||
|
backrefs: true
|
||||||
backup: true
|
backup: true
|
||||||
when:
|
when:
|
||||||
- ('kube_control_plane' not in group_names)
|
- ('kube_control_plane' not in group_names)
|
||||||
|
|||||||
Reference in New Issue
Block a user