Container ansible disguises local ansible 【容器 ansible 伪装本地 ansible】
2024-01-09 17:40:59
预备条件:
kubespray 包含 ansible、ansible-playbook命令以及通过kubespray项目安装kubernetes集群的介质。
nerdctl pull quay.io/kubespray/kubespray:v2.23.1
nerdctl save -o quay.io_kubespray_kubespray_v2.23.1.tar quay.io/kubespray/kubespray:v2.23.1
nerdctl load -i quay.io_kubespray_kubespray_v2.23.1.tar
nerdctl run --name ansible --network=host -it -v "$(pwd)"/ansible-playbook:/ansible-playbook -v "${HOME}"/.ssh:/root/.ssh -v /etc/hosts:/etc/hosts quay.io/kubespray/kubespray:v2.23.1 bash
编排 inventory.ini
$ nerdctl exec -ti ansible vim /ansible-playbook/inventory.ini
[all]
kube-master01 ansible_host=10.70.0.71
kube-master02 ansible_host=10.70.0.72
kube-master03 ansible_host=10.70.0.73
kube-node01 ansible_host=10.70.0.74
kube-node02 ansible_host=10.70.0.75
kube-node03 ansible_host=10.70.0.76
[bastion]
bastion01 ansible_host=10.70.0.78 ansible_user=root
[kube_control_plane]
kube-master01
kube-master02
kube-master03
[etcd]
kube-master01
kube-master02
kube-master03
[kube_node]
kube-node01
kube-node02
kube-node03
[calico_rr]
[k8s_cluster:children]
kube_control_plane
kube_node
calico_rr
$ nerdctl exec -ti ansible ansible -i /ansible-playbook/inventory.ini all -m ping
$ vim /root/.bashrc
alias ansible='nerdctl exec -ti ansible ansible -i /ansible-playbook/inventory.ini'
...
$ source /root/.bashrc
$ ansible all -m ping
文章来源:https://blog.csdn.net/xixihahalelehehe/article/details/135484717
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!