ansible(1)-- 部署ansible连接被控端

目录

一、部署ansible

1.1 安装

1.2 测试连接


192.168.136.55

ansible

192.168.136.56 被控端

一、部署ansible

1.1 安装

zabbix-s只是主机名,不用在意,更好该主机也安装了zabbix,不好更改。

下载阿里云epel源

#安装阿里云的epel源,不建议直接用玉yum install epel-release,不然安装完后还要修改源地址
[root@zabbix-s /]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum install ansible

ansible --version

ansible(1)-- 部署ansible连接被控端_第1张图片

1.2 测试连接

vi /etc/ansible/hosts

[test]
192.168.136.56
ssh-keygen   #生成秘钥,三次回车

ssh-copy-id 192.168.136.56   #将本地主机的公钥复制到远程主机的authorized_keys文件上,会提示让你输入yes,随后输入被控主机的密码

ansible test -m command -a 'echo "hello world"'   #测试能不能成功使用命令

#测试成功
#####
192.168.136.56 | CHANGED | rc=0 >>
hello world
#####

 

被控端192.168.136.56生成的文件

cat /root/.ssh/authorized_keys

ansible 自动安装,无需经过密码确认,ubantun、centos:

生产中使用ssh-copy-id复制公钥到多台服务器_临江仙我亦是行人的博客-CSDN博客

Shell 脚本实现ansible免密认证 expect批量导入ssh公钥_wx5bcd2f496a1cf的技术博客_51CTO博客

你可能感兴趣的:(ansible,ansible,自动化运维)