当前位置:网站首页>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/'
边栏推荐
猜你喜欢
随机推荐
The request was rejected because the URL contained a potentially malicious String “//“
【Harmony OS】【ARK UI】Custom popup
STM32的Cube学习笔记(ADC)
Hhhhgffsb
[MLT] Analysis of MLT Multimedia Framework Production and Consumption Architecture (2)
2022-08-08 第四小组 修身课 学习笔记(every day)
Docker部署MySQL
使用Redis zset做消息队列
数据库事务&锁机制
算法---优美的排列(Kotlin)
【日常训练--腾讯精选50】7. 整数反转
顺 序 表
The development trend of software testing
shell正则表达式
机器人大赛总结
MySQL---performance schema
还不了解什么是商业智能(BI)?看完这篇文章就懂了
UI框架布局
IDEA05:线程管理
面向6G的欠采样相移键控可见光调制方案









