set hostname in task 'prepare'

pull/1381/head
gjmzj 2024-05-22 19:28:40 +08:00
parent 7acb1e0237
commit 054a6c140f
3 changed files with 13 additions and 1 deletions

View File

@ -34,9 +34,13 @@ K8S_VER: "__k8s_ver__"
K8S_NODENAME: "{%- if k8s_nodename != '' -%} \ K8S_NODENAME: "{%- if k8s_nodename != '' -%} \
{{ k8s_nodename|replace('_', '-')|lower }} \ {{ k8s_nodename|replace('_', '-')|lower }} \
{%- else -%} \ {%- else -%} \
{{ inventory_hostname }} \ {{ inventory_hostname|replace('.', '-') }} \
{%- endif -%}" {%- endif -%}"
# use 'K8S_NODENAME' to set hostname
ENABLE_SETTING_HOSTNAME: true
############################ ############################
# role:etcd # role:etcd
############################ ############################

1
ezdown
View File

@ -93,6 +93,7 @@ available OSes:
ubuntu_18 to download package of Ubuntu 18.04 ubuntu_18 to download package of Ubuntu 18.04
ubuntu_20 to download package of Ubuntu 20.04 ubuntu_20 to download package of Ubuntu 20.04
ubuntu_22 to download package of Ubuntu 22.04 ubuntu_22 to download package of Ubuntu 22.04
ubuntu_24 to download package of Ubuntu 24.04
examples: examples:
./ezdown -P ubuntu_22 ./ezdown -P ubuntu_22
EOF EOF

View File

@ -42,6 +42,13 @@
regexp: 'easzlab.io.local' regexp: 'easzlab.io.local'
line: "{{ ansible_env.SSH_CLIENT.split(' ')[0] }} easzlab.io.local" line: "{{ ansible_env.SSH_CLIENT.split(' ')[0] }} easzlab.io.local"
# 设置节点hostnamecalico 网络组件要求每个节点不一样的hostname
- name: 设置节点 hostname
hostname:
name: "{{ K8S_NODENAME }}"
use: systemd
when: "ENABLE_SETTING_HOSTNAME|bool"
# 设置节点名称{{ K8S_NODENAME }} /etc/hosts 解析 # 设置节点名称{{ K8S_NODENAME }} /etc/hosts 解析
# 1.先确保第一个主节点做好解析 # 1.先确保第一个主节点做好解析
- name: 设置 k8s_nodename 在 master[0] 节点 /etc/hosts 地址解析 - name: 设置 k8s_nodename 在 master[0] 节点 /etc/hosts 地址解析