ansible安装

ansible安装

一、安装步骤

1、实验准备

管理端: 192. 168. 150.136
被管理端: 192. 168. 150.137
被管理端: 192. 168. 150.138

2、安装工具包

yum install -y epel- release //安装epel 源

yum install ansible -y

ansible --version //查看ansible版本

yum install tree -y

3、查看配置文件结构

tree /etc/ansible/ //树状结构 展示文件夹

ansible. cfg #ansible的配置文件
hosts #ansible的主仓库,用于存储需要管理的远程
roles #角色文件

cd /etc/ansible

vi hosts

//配置主机清单
[webserver]
192.168.150.137
[mysql]
192.168.150.138

4、创建密钥并复制给被管理者

ssh-keygen -t rsa

ssh-copy-id root@192.168.150.157

ssh-copy-id root@192.168.150.158

5、免交互代理

ssh-agent bash

ssh-add

6、查询使用

ansible webserver -m command -a ‘date’

ansible 192.168.150.157 -m command -a ‘date’

ansible mysql -m command -a ‘date’


版权声明:本文为weixin_39608791原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。