当前位置:网站首页>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/'
边栏推荐
猜你喜欢
数字化时代,企业为什么需要商业智能BI
C Advanced - Program Compilation (Preprocessing) + Linking
matlab simulink球杆控制系统的模糊PID控制设计
还不了解什么是商业智能(BI)?看完这篇文章就懂了
Software testing method is introduced in detail
JDBC_PreparedStatement预编译对象
TASSEL software imports plink format file error
站点到站点的流量监控
2022-08-08 顾宇佳 学习笔记
如何让Win11两个屏幕任务栏都显示时间?
随机推荐
22-08-08 西安 尚医通(04)MongoDB命令、MongoTemplate、MongoRepository
顺 序 表
Hhhhgffsb
RT201 国产PA射频功率放大器 兼容RFX2401C
UI框架布局
想要精准营销,从学习搭建一套对的标签体系开始丨DTVision分析洞察篇
Storage System Architecture Evolution
STM32学习笔记(PWM输出)
面向6G的欠采样相移键控可见光调制方案
STM32系列单片机使用心得
什么是ReFi?
9.jenkins安装
【Harmony OS】【ARK UI】Custom popup
程序设计6大原则
[Daily Training--Tencent Featured 50] 7. Integer Reversal
JVM:(七)运行时数据区之堆
在快手工作是一种什么体验
2022-08-08 第四小组 修身课 学习笔记(every day)
通讯录(文件版)(C语言)(VS)
面向6G的大规模MIMO通信感知一体化:现状与展望