ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
### [file模块][1] 用于设定或修改文件的属性信息 ~~~ 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' } ~~~ [1]:http://docs.ansible.com/ansible/file_module.html