当前位置:网站首页>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 moduleThe 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/'边栏推荐
猜你喜欢
随机推荐
1,C#的基本结构
电气规则
FastDFS快速使用及介绍
进程和计划任务管理
地理空间分析库turf.js的学习
Quantitative Genetics Heritability Calculation 1: Parent-Child Regression Method
Address Book (File Version) (C Language) (VS)
Open the threshold of the digital age, Metaverse NFT mall develops solutions
CSDN使用方法
Spark源码-任务提交流程-8-DAGScheduler任务切分
STM32定时器输入捕获频率(cube)
Docker部署MySQL
STM32之vl53l0x读取距离
力扣242-有效的字母异位词——哈希表法
软件测试工程师简历要怎么写,才能让HR看到
10.LoadRunner2022社区版安装
The development trend of software testing
三剑客进阶
deploy发布的jar包中文乱码
如何一键进行Win11系统的重装?









