Ansible的安装
1.安装源
yum search ansible
yum -y install centos-release-ansible-29
2.安装ansible、
yum -y install ansible
3.添加被管理服务器IP到清单
vim /etc/ansible/hosts
#[webservers]
#192.168.50.162
#192.168.50.164
4.配置免密
ssh-keygen #一直按回车
ssh-copy-id root@192.168.50.162
ssh-copy-id root@192.168.50.164
5.测试被管理主机是否可达
ansible webservers -m ping
常用的模块
#批量安装httpd
ansible webservers -m yum -a 'name=httpd state=installed'
#批量启动所有主机的httpd
ansible webservers -m systemd -a 'name=httpd state=started enabled=true'
#查看被管理节点的80端口是否被监听
ansible webservers -m shell -a 'ss -ntl | grep 80'
#创建一个httpd的测试页面
ansible webservers -m shell -a 'echo test > /var/www/html/index.html'
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)