ansible ad-hoc 模块: file
创建普通文件
[root@ansible ~]# ansible backup -m file -a 'path=/root/a.txt state=touch
创建并修改属主属组权限
[root@ansible ~]# ansible backup -m file -a 'path=/root/a.txt state=touch owner=www group=www mode=0600'
创建目录
[root@ansible ~]# ansible backup -m file -a 'path=/root/baimei state=directory'
递归修改属主属组 (默认是递归, recurse 可以不加)
[root@ansible ~]# ansible backup -m file -a 'path=/root/baimei state=directory owner=www group=www recurse=yes'
删除文件或者目录 absent
[root@ansible ~]# ansible backup -m file -a 'path=/root/a.txt state=absent'
创建/backup并修改属主属组
[root@ansible ~]# ansible backup -m file -a 'path=/backup state=directory owner=www group=www'
file:
path: 文件或目录的路径
state: touch 创建文件
directory 创建目录
link 创建软链接
absent 删除
欢迎来撩 : 汇总all