当前位置:网站首页>Functions and differences of command, shell, raw, script modules, application of file, copy, fetch, synchronize
Functions and differences of command, shell, raw, script modules, application of file, copy, fetch, synchronize
2022-08-09 05:24:00 【m0_59138290】
Article table of contents
The role and difference of command, shell, raw, script modules
Use of command module: to execute a script file command.sh, the function of command.sh file is echo "I am command module"
[[email protected] .ansible]# vim command.sh[[email protected] .ansible]# chmod +x command.sh[[email protected] .ansible]# ./command.shI am command module
The shell module executes the command ls /root | grep txt
[[email protected] .ansible]# ansible all -m shell -a "ls/root | grep txt"
The raw module executes the pwd command
[[email protected] .ansible]# ansible test -m raw -a "pwd"
The script module executes the script.sh file, and the content of the file is echo "I am script module"
[[email protected] ~]# ansible node -m script -a "script.sh chdir=/root"
file module:
Create a file and specify a user, the user group is student, and the permission is 600
[[email protected] ~]# ansible node1 -m file -a "path=/testdir/testdir state=absent" state=touch owner=student group=student mode=600"
Create a directory and specify a user, the user group is student, and the permission is 755
[[email protected] ~]# ansible node1 -m file -a "path=/home/testfile state=touch owner=student group=student mode=755"
Create linked file
[[email protected] ~]# ansible node1 -m file -a "path=/testdir/linkfile state=link src=/testdir/testfile"
Delete the first created file
[[email protected] ~]# ansible test70 -m file -a "ansible test70 -m file -a "path=/testdir/testdir state=absent"
copy
Copy file
[[email protected] ~]# ansible node1 -m copy -a "src=/etc/passwd dest=/tmp/passwd owner=root group=root mode=0644"
Copy directory
[[email protected] ~]# ansible node1 -m copy -a "src=/etc/ansible dest=/tmp owner=root group=root mode=0755"
fetch
Fetch files from the controlled host
[[email protected] ~]# ansible node1 -m fetch -a 'src=/etc/hosts dest=/opt'
synchronize
pull: pull a directory from the controlled host
ansible -i /tmp/hosts backup -m synchronize -a 'mode=pull src=/tmp/backup/ dest=/tmp/backup/'
push: push the directory to the controlled host
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/'
边栏推荐
猜你喜欢
随机推荐
快速上手Shell,看这一篇就够了
matlab simulink球杆控制系统的模糊PID控制设计
RT201 国产PA射频功率放大器 兼容RFX2401C
STM32的Cube学习笔记(ADC)
The request was rejected because the URL contained a potentially malicious String “//“
【LeetCode】1283. 使结果不超过阈值的最小除数
剑指Offer - 链表翻转及其变体题目总结
Eureka-Server------单节和集群的搭建
数据库事务&锁机制
Spark源码-任务提交流程-8-DAGScheduler任务切分
关于光电门的使用
【日常训练--腾讯精选50】7. 整数反转
deploy上传到私服配置注意事项(踩坑经验)
【ManageEngine】网络性能监控工具
中断系统结构及中断控制详解
Docker部署MySQL
Transaction rolled back because it has been marked as rollback-only
Software testing method is introduced in detail
站点到站点的流量监控
算法---优美的排列(Kotlin)