file模块:修改文件属性、生成链接文件、创建空文件、创建空目录、删除目录文件
1、修改文件属性, ansible all -m file -a "path=/root/test.sh owner=test group=test mode=0644"
![](https://img.haomeiwen.com/i9967595/b4205d469bfe8677.png)
2、生成链接文件:ansible all -m file -a "src=/root/test.sh dest=/root/testlink.sh owner=root group=root state=link"
![](https://img.haomeiwen.com/i9967595/53d10b4539b66c9d.png)
3、创建空文件:ansible all -m file -a "path=/root/testtouch.sh state=touch mode=0644"
![](https://img.haomeiwen.com/i9967595/6bf65d429ddd4c9f.png)
4、创建空目录: ansible all -m file -a "path=/root/testdirectory state=directory mode=0644"
![](https://img.haomeiwen.com/i9967595/a0f5250d3857a28b.png)
5、删除目录或文件,强制执行:ansible all -m file -a "path=/root/testdirectory state=absent force=yes"
![](https://img.haomeiwen.com/i9967595/1e752bf7e27be745.png)
网友评论