8月3日作业

1.command,shell,raw,script模块的作用和区别

command模块 [执行远程命令]
script模块 [在远程主机执行主控端的shell/python脚本]
shell模块 [执行远程主机的shell/python脚本]
raw模块 [类似于command模块、支持管道传递]

ansible基础配置

vim /etc/ansible/ansible.cfg

 

command 模块的使用: 去执行一个脚本文件command.sh, command.sh文件的功能是echo "I am command module"


shell模块执行命令 ls /root | grep txt


raw模块执行pwd命令


script模块执行 script.sh文件,文件的内容为 echo "I am script module"

  


2.file模块:
创建文件,并指定用户,用户组为student,且权限为600

[root@server ~]# ansible test70 -m file -a "path=.testdir/abc state=touch mode=0600 
owner=student"
[root@server ~]# ansible test70 -m file -a "path=/testdir/abc owner=student"
[root@server ~]# ansible test70 -m file -a "path=/testdir/abc state=directory owner=student"
[root@server ~]# ansible test70 -m file -a "path=/testdir/abc group=student"

创建目录,并指定用户,用户组为student,且权限为755

[root@server ~]# ansible test70 -m file -a "path=/testdir/abd state=directory mode= 0755
owner=student group=student recurse=yes"

创建链接文件

[root@server ~]# ansible test70 -m file -a "path=/testdir/hardfile state=hard src=/testdir/testfile"

删除第一个创建的文件

[root@server ~]# ansible test70 -m file -a "path=/testdir/testdir state=absent"

3.copy
复制文件
复制目录

[root@server ~]# ansible test70 -m copy -a "src=/testdir/copytest dest=/opt/ force=no"

4.fetch

从被控制主机上取文件


5.synchronize
pull: 从被控制主机上拉取目录

[root@server ansible_dir]# ansible node1.example.com -m synchronzie -a 'src=/etc/hosts dest=/tmp mode=pull'

push:往被控制主机上推送目录

[root@server ansible_dir]# ansible node1.example.com -m synchronzie -a 'src=/etc/hosts dest=/tmp mode=push'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值