ansible的一些命令 案例
1.调用测试
ansible hkweb -m command -a 'uptime'
2.查看配置
ansible hkweb -m setup
3.ping 命令
ansible hkweb -m ping
10.46.93.177 | SUCCESS => {
"changed": false,
"ping": "pong"
}
10.46.93.174 | SUCCESS => {
"changed": false,
"ping": "pong"
}
4.目录递归传递
/home/tomcat/ansible
publish.sh src
#publish.sh
#!/bin/bash
SrcPath="/home/tomcat/ansible"
DstPath="/home/tomcat/ansible"
for i in `ls src`;
do
echo $PWD"/"$i;
ansible hkweb -m copy -a "src=${SrcPath}/src/${i} dest=/home/tomcat/ansible"
done
5.copy模块太慢
使用:synchronize模块
#!/bin/bash
SrcPath="/home/tomcat/ansible"
DstPath="/home/tomcat/ansible"
for i in `ls src`;
do
echo $PWD"/"$i;
ansible hkweb -m synchronize -a "src=${SrcPath}/src/${i} dest=/home/tomcat/ansible" >>log.txt
#ansible hkweb -m copy -a "src=${SrcPath}/src/${i} dest=/home/tomcat/ansible" >>log.txt
done
标签:src,tomcat,命令,hkweb,案例,ansible,SrcPath,home From: https://blog.csdn.net/lisanmengmeng/article/details/143476020