From b3b6bb4347ef8ae2c4c54a9bf4044173edcf6e3a Mon Sep 17 00:00:00 2001 From: wrype <719147488@qq.com> Date: Thu, 8 Jun 2023 16:15:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=A4=9A=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E9=83=A8=E7=BD=B2=E6=97=B6node=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E8=AE=BE=E7=BD=AEhosts=E5=AF=BC=E8=87=B4=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roles/kube-node/tasks/main.yml | 12 ------------ roles/prepare/tasks/main.yml | 10 ++++++++++ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/roles/kube-node/tasks/main.yml b/roles/kube-node/tasks/main.yml index 7d60886..1f61e62 100644 --- a/roles/kube-node/tasks/main.yml +++ b/roles/kube-node/tasks/main.yml @@ -92,18 +92,6 @@ shell: systemctl daemon-reload && systemctl restart kube-proxy tags: reload-kube-proxy, upgrade_k8s, restart_node, force_change_certs -# 设置k8s_nodename 在/etc/hosts 地址解析 -- name: 设置k8s_nodename 在/etc/hosts 地址解析 - lineinfile: - dest: /etc/hosts - state: present - regexp: "{{ K8S_NODENAME }}" - line: "{{ inventory_hostname }} {{ K8S_NODENAME }}" - delegate_to: "{{ item }}" - with_items: "{{ groups.kube_master }}" - when: "inventory_hostname != K8S_NODENAME" - - # 轮询等待kube-proxy启动完成 - name: 轮询等待kube-proxy启动 shell: "systemctl is-active kube-proxy.service" diff --git a/roles/prepare/tasks/main.yml b/roles/prepare/tasks/main.yml index 4ddfc28..39d5497 100644 --- a/roles/prepare/tasks/main.yml +++ b/roles/prepare/tasks/main.yml @@ -41,3 +41,13 @@ state: present regexp: 'easzlab.io.local' line: "{{ ansible_env.SSH_CLIENT.split(' ')[0] }} easzlab.io.local" + +- name: 设置 k8s_nodename 在 master、node 节点 /etc/hosts 地址解析 + lineinfile: + dest: /etc/hosts + state: present + regexp: "{{ K8S_NODENAME }}" + line: "{{ inventory_hostname }} {{ K8S_NODENAME }}" + delegate_to: "{{ item }}" + with_items: ["{{ groups.kube_master }}", "{{ groups.kube_node }}"] + when: "inventory_hostname != K8S_NODENAME" \ No newline at end of file