一、Ansible工具简介
ansible
是新出现的自动化运维工具,基于Python
开发,集合了众多运维工具(puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置
、批量程序部署
、批量运行命令
等功能。
二、Ansible的安装
1、因为是对Ansible的简单测试,所以使用三
台CentOS 7.4
服务器进行一系列协同操作。

2、首先新增epel-release
第三方套件来源
yum install -y epel-release

3、使用yum
安装Ansible
yum install -y ansible

三、Ansible的配置
1、在所有节点上安装YUM
、SSH
、python
yum install -y openssh-server python
管理端安装配置

被管理端1安装配置

被管理端2安装配置

2、在管理界面上执行:ssh-keygen
,一路按回车
即可
ssh-keygen

3、在管理节点上执行,替换为你自己的IP
地址
ssh-copy-id 192.168.139.133
ssh-copy-id 192.168.139.134

4、修改配置文件ansible.cfg
vi /etc/ansible/ansible.cfg
添加以下内容:
inventory = /etc/ansible/hosts
forks = 5
become = root
remote_port = 22
host_key_checking = False
timeout = 10
log_path = /var/log/ansible.log
private_key_file = /root/.ssh/id_ras
5、最后查看结果
cat /etc/ansible/hosts
网友评论