ansible实用例子

寻找/etc/ 名为"hosts" 递归查找

ansible webserver -m find -a ' path=/etc/ file_type=any recurse=yes  pattern="hosts"'

/etc/下包含xiaowei的文件

ansible webserver -m find -a ' path=/etc/ contains='.*xiaowei.*' recurse=yes '

查询haproxy日志

clouder@server2-47:~/cbin/ansible> assh big_haproxy "cat /var/log/localmessages |grep 'yespmp'|grep ' 504 '"    #“”“” 双引号里面包含单引号 中很重要

经典例子:装包--修改配置-起服务-重启服务

http://www.ywnds.com/?p=6064

原文地址:https://www.cnblogs.com/hixiaowei/p/9203053.html