修改前:
[root@c721v194 kubeadm-ansible]# ansible -i inventory all -m shell -a "hostname"
192.168.21.226 | SUCCESS | rc=0 >>
c821v226
192.168.21.194 | SUCCESS | rc=0 >>
c721v194
1.修改 `inventory` 添加 hostname=k8s-master(主机名
格式:`主机ip+ hostname+ 端口port+ 登录用户root+ 登录密码`
[root@c721v194 kubeadm-ansible]# cat inventory
[master]
192.168.21.194 hostname=k8s-master ansible_user=root ansible_ssh_pass=caicloud2017
[node]
192.168.21.226 hostname=k8s-node-1 ansible_user=root ansible_ssh_pass=caicloud2017
[kube-cluster:children]
master
node
2.修改主机名playbook
cat name.yml
[root@c721v194 kubeadm-ansible]# cat name.yml
---
- hosts: kube-cluster
remote_user: root
tasks:
- name: change name