Ansible(二)安装与配置
Ansible服务器192.168.0.113
主机1192.168.0.104
主机2192.168.0.105
主机3192.168.0.106
1.安装(依赖于epel源,版本2.0.1.0-2.el7)
1
~]# yum install ansible
配置文件:/etc/ansible/ansible.cfg
Invertory:/etc/ansible/hosts
2.编辑Invertory(编辑前备份默认hosts文件)
1
~]# /etc/ansible/hosts
注:支持定义单个主机和主机组
1
2
3
4
5
192.168.0.104
192.168.0.105
192.168.0.106
3.基于密钥进行认证(Ansible服务器生成密钥)
1
2
3
~]# ssh-keygen -t rsa
~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.0.104
#拷贝至客户端,访问不再需要口令
1
2
~]# ssh 'root@192.168.0.104'
#使用ssh验证登录是否通过密钥认证,exit登出
4.同步时间(默认CentOS7未安装ntp)
1
2
3
4
~]# yum -y install ntp
~]# systemctl start ntpd.service
~]# iptables -F
~]# ssh root@192.168.0.106 'ntpdate 192.168.0.113'
页:
[1]