当前位置:网站首页>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/'
边栏推荐
猜你喜欢
随机推荐
2022-08-08 顾宇佳 学习笔记
RNN-T
Nacos源码安装
unity urp 实现遮挡显示角色轮廓
P8462 「REOI-1」奶油蛋糕
UI框架布局
打开数字时代的门槛,元宇宙NFT商城开发解决方案
Hhhhgffsb
Still don't know what business intelligence (BI) is?After reading this article, you will understand
feof它可不简单。
STM32学习笔记(PWM输出)
【mysql数据库】mysql数据库的使用
STM32之vl53l0x读取距离
C Advanced-C Language File Operation
多字段关联校验
浅谈单片机Boot的几种自刷新方式
Oracle01-安装与卸载
[Daily Training--Tencent Featured 50] 7. Integer Reversal
剑指Offer - 链表翻转及其变体题目总结
5G对物流行业的积极影响