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

目录

一、部署ansible

[1.1 安装](#1.1 安装)

[1.2 测试连接](#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

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博客

相关推荐
淼淼爱喝水19 小时前
ansible 自动化部署多主机差异化服务(httpd + vsftpd)
自动化运维
遇见火星20 小时前
从0到1掌握Ansible:让自动化运维不再是梦想
运维·自动化·ansible
遇见火星21 小时前
Jenkins + Ansible 集成实战:把配置管理焊进流水线里
运维·ansible·jenkins
Bigger2 天前
实战:搭建 AI Code Review 自动化流水线
前端·ci/cd·自动化运维
江华森2 天前
Ansible 自动化运维:从入门到实战
运维·自动化·ansible
JackSparrow4144 天前
使用Ansible批量管理+更新产品环境服务器配置
运维·服务器·ci/cd·kubernetes·自动化·ansible·sre
Cat_Rocky6 天前
Linux-ansible之Playbook简单应用
linux·网络·ansible
淼淼爱喝水8 天前
Ansible 入门实战:四种变量优先级比较实验
ansible·变量
淼淼爱喝水8 天前
ansible实战:「磁盘空间 ≥ 2G 时自动创建文件」
前端·ansible·自动创建
红茶要加冰9 天前
四、ansible的templates
linux·运维·服务器·ansible