puppet ruby开发
salt python开发,有客户端,使用Rabbitmq消息队列,支持并发,在机器数量很多时效果比ansible好。
ansible python开发, 没有客户端,基于ssh,同时只能建立一个隧道,不支持并发,适于维护数量不是很多的机器。
-m 指定模块
command 只支持单条命令
shell 支持管道符等
1.安装
pip install ansible
ansible --version
2.创建配置文件
mkdir /etc/ansible
vim /etc/ansible/hosts
172.16.100.100
3.拷贝公钥
ssh-keygen -t rsa
ssh-copy-id -i id_rsa.pub -p 22 root@172.16.100.100
4.测试执行
[09:51:40] [root@ansible-server ~]# ansible all -m ping
172.16.100.100 | SUCCESS => {
"changed": false,
"failed": false,
"ping": "pong"
}
默认使用command模块,只能运行一条命令。
-m 使用shell模块,-a指定模块参数,支持多条命令。
[09:57:13] [root@ansible-server ~]# ansible all -m shell -a "ls -l && ls -l /"
172.16.100.100 | SUCCESS | rc=0 >>
总用量 150056
5.分组 inventory
[10:02:26] [root@ansible-server ~]# vim /etc/ansible/hosts
[vpsgroup]
172.16.100.100
[10:03:28] [root@ansible-server ~]# ansible vpsgroup -m shell -a "ls"
[10:07:47] [root@ansible-server ~]# ansible 172.16.100.100 -m shell -a "ls"
requests库
1.安装
pip install requests
yum install python-devel
pip install gunicorn httpbin
gunicorn httpbin:app -b 172.17.52.88:8000