当前位置:网站首页>command,shell,raw,script模块的作用和区别,file、copy、fetch、synchronize的应用
command,shell,raw,script模块的作用和区别,file、copy、fetch、synchronize的应用
2022-08-09 05:19:00 【m0_59138290】
command,shell,raw,script模块的作用和区别
command 模块的使用: 去执行一个脚本文件command.sh, command.sh文件的功能是echo “I am command module”
[[email protected] .ansible]# vim command.sh
[[email protected] .ansible]# chmod +x command.sh
[[email protected] .ansible]# ./command.sh
I am command module
shell模块执行命令 ls /root | grep txt
[[email protected] .ansible]# ansible all -m shell -a "ls/root | grep txt"
raw模块执行pwd命令
[[email protected] .ansible]# ansible test -m raw -a "pwd"
script模块执行 script.sh文件,文件的内容为 echo “I am script module”
[[email protected] ~]# ansible node -m script -a "script.sh chdir=/root"
file模块:
创建文件,并指定用户,用户组为student, 且权限为600
[[email protected] ~]# ansible node1 -m file -a "path=/testdir/testdir state=absent" state=touch owner=student group=student mode=600"
创建目录,并指定用户,用户组为student, 且权限为755
[[email protected] ~]# ansible node1 -m file -a "path=/home/testfile state=touch owner=student group=student mode=755"
创建链接文件
[[email protected] ~]# ansible node1 -m file -a "path=/testdir/linkfile state=link src=/testdir/testfile"
删除第一个创建的文件
[[email protected] ~]# ansible test70 -m file -a "ansible test70 -m file -a "path=/testdir/testdir state=absent"
copy
复制文件
[[email protected] ~]# ansible node1 -m copy -a "src=/etc/passwd dest=/tmp/passwd owner=root group=root mode=0644"
复制目录
[[email protected] ~]# ansible node1 -m copy -a "src=/etc/ansible dest=/tmp owner=root group=root mode=0755"
fetch
从被控制主机上取文件
[[email protected] ~]# ansible node1 -m fetch -a 'src=/etc/hosts dest=/opt'
synchronize
pull: 从被控制主机上拉取目录
ansible -i /tmp/hosts backup -m synchronize -a 'mode=pull src=/tmp/backup/ dest=/tmp/backup/'
push:往被控制主机上推送目录
ansible -i /tmp/hosts backup -m synchronize -a 'src=/tmp/backup/ dest=/tmp/backup/'
ansible -i /tmp/hosts backup -m synchronize -a 'mode=push src=/tmp/backup/ dest=/tmp/backup/'
边栏推荐
猜你喜欢
随机推荐
22-08-08 西安 尚医通(04)MongoDB命令、MongoTemplate、MongoRepository
地理空间分析库turf.js的学习
shell正则表达式
剑指Offer-二维动态规划问题题目总结
Address book (dynamic version) (C language) (VS)
el与data的
2022-08-08 第四小组 修身课 学习笔记(every day)
剑指Offer-双指针类型题目总结
想要精准营销,从学习搭建一套对的标签体系开始丨DTVision分析洞察篇
What is it like to work at Kuaishou?
Eureka-Server------单节和集群的搭建
【计算机网络-哈工大】---学习笔记(下)---(一)网络安全、密码学基础、对称、公钥、身份认证、数字签名、KDC\CA
Webgis地图框架的对比
数据库事务&锁机制
[Daily Training--Tencent Featured 50] 7. Integer Reversal
保存Simulink仿真模型为图片或者PDF的方法
文件的随意读写
3.3V控制输出5V的方法
数据库设计---三范式和反范式设计
【luogu U142356】Suffix of the Brave (SA) (Chairman Tree) (2 points)






![不能提取结果集,SQL [n / a]; org.hibernate.exception.SQLGrammarExcept是嵌套的异常](/img/00/328e4c296c00929140c9aff3bb896e.png)

