# file模块
### [file模块](http://docs.ansible.com/ansible/file_module.html)
用于设定或修改文件的属性信息
```
group:默认为空
owner:默认为空
path:默认为空,别名:'dest', `name'
recurse:yes, no 默认为no
src:创建连接文件时有用
```
```
state:file, link, directory, hard, touch, absent
file 默认属性,如果文件不存在则不创建,并且报错,用于修改已存在文件的属性
directory 如果目录不存在,则创建目录和子目录
absent 递归删除文件或目录
link 在创建软链接是有用
hard 创建硬链接
```
### 示例
```
---
- name: file
hosts: local
tasks:
- name: file
file:
src: '/tmp/{{ item.src }}'
dest: '{{ item.dest }}'
state: link
with_items:
- { src: 'x', dest: 'y' }
- { src: 'z', dest: 'k' }
```
- 目录
- ansible基础
- ansible简介
- ansible安装和测试
- ansible配置文件
- yaml在ansible中的用法
- inventory
- 变量与facts
- when语句
- handler模块
- 大杂烩
- ansible模块
- copy模块
- cron模块
- debug模块
- django_manage模块
- file模块
- git模块
- hostname模块
- lineinfile模块
- mysql_user模块
- mysql_db模块
- pip模块
- selinux
- setup模块
- shell 和 command模块
- stat模块
- supervisorctl
- systemd
- timezone
- unarchive模块
- user模块
- wait_for
- yum和service模块
- 其他模块或者方法
- 其他
- 报错处理
- playbooks
- 复杂的playbook
- 循环
- roles