3.4-ansible远程执行脚本
2016-04-06 20:35
176 查看
Ansible远程执行脚本
* 首先创建一个shell脚本
vim /tmp/test.sh //加入内容
#!/bin/bash
echo `date` > /tmp/ansible_test.txt
* 然后把该脚本分发到各个机器上
ansible testhost -m copy -a "src=/tmp/test.sh dest=/tmp/test.sh mode=0755"
* 最后是批量执行该shell脚本
ansible testhost -m shell -a "/tmp/test.sh"
* shell模块,还支持远程执行命令并且带管道
ansible testhost -m shell -a "cat /etc/passwd|wc -l "
说明:如果test.sh没有执行权限,可以用ansible testhost -m shell -a "/bin/sh /tmp/test.sh"来实现脚本的执行。
* 首先创建一个shell脚本
vim /tmp/test.sh //加入内容
#!/bin/bash
echo `date` > /tmp/ansible_test.txt
* 然后把该脚本分发到各个机器上
ansible testhost -m copy -a "src=/tmp/test.sh dest=/tmp/test.sh mode=0755"
* 最后是批量执行该shell脚本
ansible testhost -m shell -a "/tmp/test.sh"
* shell模块,还支持远程执行命令并且带管道
ansible testhost -m shell -a "cat /etc/passwd|wc -l "
说明:如果test.sh没有执行权限,可以用ansible testhost -m shell -a "/bin/sh /tmp/test.sh"来实现脚本的执行。
相关文章推荐
- 如何判断两个数字的奇偶性是否相同。
- 3.3-ansible拷贝目录或者文件
- linux 2.6 中断,异常
- 神经网络
- hashmap
- 观察者模式
- HWOJ 字符串最后一个单词长度
- 复利计算-结对
- JavaScript 定时器
- 3.2-ansible远程执行命令
- 3.1-ansible安装以及配置认证
- 如何判断一个数字能否同时被两个数整除;
- HDU 2084 数塔
- 使用facl和mount实现某用户对某个目录的访问控制
- JAVA编程练习题(1--10)
- BZOJ4402: Claris的剑
- 结对编写四则运算
- SpringMVC-2016-04-06
- Windows下使用winpcap-2.1ARP探测局域网活动主机(发送ARP请求)
- swift 数组