目录标题
file模块
# 在testB中创建/testdir目录
[root@server4 testdir]# ansible testB -m file -a "path=/testdir state=directory"
# 在testB中/testdir/目录下创建westos文件
[root@server4 testdir]# ansible testB -m file -a "path=/testdir/westos state=touch"
# 创建软连接
[root@server4 testdir]# ansible testB -m file -a "path=/testdir/linkwestos state=link src=/testdir/westos"
# 创建硬连接
[root@server4 testdir]# ansible testB -m file -a "path=/testdir/hardwestos state=hard src=/testdir/westos"
# 当westos-jy不存在时使用force=yes可以强制创建软连接
[root@server4 testdir]# ansible testB -m file -a "path=/testdir/linkwestos2 state=link src=/testdir/westos-jy force=yes"
# 删除
[root@server4 testdir]# ansible testB -m file -a "path=/testdir/linkwestos2 state=absent"
# 指定拥有者创建,会更新时间戳
[root@server4 testdir]# ansible testB -m file -a "path=/testdir/a state=touch owner=zjy"
# 指定组创建,回更新时间戳
[root@server4 testdir]# ansible testB -m file -a "path=/testdir/a state=touch group=zjy"
# 创建目录并指定权限
[root@server4 testdir]# ansible testB -m file -a "path=/testdir/c state=directory mode=666"
# 修改权限
[root@server4 testdir]# ansible testB -m file -a "path=/testdir/c mode=4700"
# 第归创建目录
[root@server4 testdir]# ansible testB -m file -a "path=/testdir/1/2 state=directory owner=zjy group=zjy recurse=yes"