Skip to content

Commit

Permalink
set hostname in task 'prepare'
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmzj committed May 22, 2024
1 parent 7acb1e0 commit 054a6c1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion example/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ K8S_VER: "__k8s_ver__"
K8S_NODENAME: "{%- if k8s_nodename != '' -%} \
{{ k8s_nodename|replace('_', '-')|lower }} \
{%- else -%} \
{{ inventory_hostname }} \
{{ inventory_hostname|replace('.', '-') }} \
{%- endif -%}"

# use 'K8S_NODENAME' to set hostname
ENABLE_SETTING_HOSTNAME: true


############################
# role:etcd
############################
Expand Down
1 change: 1 addition & 0 deletions ezdown
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ available OSes:
ubuntu_18 to download package of Ubuntu 18.04
ubuntu_20 to download package of Ubuntu 20.04
ubuntu_22 to download package of Ubuntu 22.04
ubuntu_24 to download package of Ubuntu 24.04
examples:
./ezdown -P ubuntu_22
EOF
Expand Down
7 changes: 7 additions & 0 deletions roles/prepare/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
regexp: 'easzlab.io.local'
line: "{{ ansible_env.SSH_CLIENT.split(' ')[0] }} easzlab.io.local"

# 设置节点hostname,calico 网络组件要求每个节点不一样的hostname
- name: 设置节点 hostname
hostname:
name: "{{ K8S_NODENAME }}"
use: systemd
when: "ENABLE_SETTING_HOSTNAME|bool"

# 设置节点名称{{ K8S_NODENAME }} /etc/hosts 解析
# 1.先确保第一个主节点做好解析
- name: 设置 k8s_nodename 在 master[0] 节点 /etc/hosts 地址解析
Expand Down

0 comments on commit 054a6c1

Please sign in to comment.