file模块:修改文件属性、生成链接文件、创建空文件、创建空目录、删除目录文件
1、修改文件属性, ansible all -m file -a "path=/root/test.sh owner=test group=test mode=0644"
![img_1b3b18f6bfd2ffcec95b93654ce5479b.png](https://yqfile.alicdn.com/img_1b3b18f6bfd2ffcec95b93654ce5479b.png)
image.png
2、生成链接文件:ansible all -m file -a "src=/root/test.sh dest=/root/testlink.sh owner=root group=root state=link"
![img_1e9ba9c4a37d54b430914a0c3ef60d60.png](https://yqfile.alicdn.com/img_1e9ba9c4a37d54b430914a0c3ef60d60.png)
image.png
3、创建空文件:ansible all -m file -a "path=/root/testtouch.sh state=touch mode=0644"
![img_e09156dde7b76f2673f7e9cdf158d03c.png](https://yqfile.alicdn.com/img_e09156dde7b76f2673f7e9cdf158d03c.png)
image.png
4、创建空目录: ansible all -m file -a "path=/root/testdirectory state=directory mode=0644"
![img_19d6886fd0b5b8ce8471c16c67d05b9c.png](https://yqfile.alicdn.com/img_19d6886fd0b5b8ce8471c16c67d05b9c.png)
image.png
5、删除目录或文件,强制执行:ansible all -m file -a "path=/root/testdirectory state=absent force=yes"
![img_faa311b26ffe312822845d8b46f50c12.png](https://yqfile.alicdn.com/img_faa311b26ffe312822845d8b46f50c12.png)
image.png