Linux安装Ansible管理工具

条件情况说明
准备4台机器,是单master集群安装

192.168.186.128 ansible
192.168.186.129 node1
192.168.186.130 node2
192.168.186.131 node3

#永久修改主机名
hostnamectl set-hostname ansible  && bash   #在ansible上操作
hostnamectl set-hostname node1   && bash   #在node1上操作
hostnamectl set-hostname node2   && bash   #在node2上操作
hostnamectl set-hostname node3   && bash   #node3上操作

1. ansible机器与部署k8s集群都做免密钥

cat >> /etc/hosts << EOF
192.168.186.128    ansible
192.168.186.129    node1
192.168.186.130    node2
192.168.186.131    node3  
EOF

#所有机器上都操作
ssh-keygen -t rsa #一路回车,不输入密码
###把本地的ssh公钥文件安装到远程主机对应的账户
for i in ansible node1 node2 node3 ;do ssh-copy-id -i .ssh/id_rsa.pub $i ;done

2. ansible安装

#Ansible服务器安装
yum install epel-release git -y
yum install ansible -y
[root@ansible ~]# ansible --version
ansible 2.9.27
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Oct 14 2020, 14:45:30) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
[root@ansible ~]# 

你可能感兴趣的:(linux,linux,ansible,运维)