Author: | Michael DeHaan |
---|
Sets attributes of files, symlinks, and directories, or removes files/symlinks/directories. Many other modules support the same options as the file module - including copy, template, and assemble.
parameter | required | default | choices | comments |
---|---|---|---|---|
force | no | no |
|
force the creation of the symlinks in two cases: the source file does not exist (but will appear later); the destination exists and is a file (so, we need to unlink the "path" file and create symlink to the "src" file in place of it). |
group | no | name of the group that should own the file/directory, as would be fed to chown | ||
mode | no | mode the file or directory should be, such as 0644 as would be fed to chmod | ||
owner | no | name of the user that should own the file/directory, as would be fed to chown | ||
path | yes | path to the file being managed. Aliases: dest, name | ||
recurse | no | no |
|
recursively set the specified file attributes (applies only to state=directory) (added in Ansible 1.1) |
selevel | no | s0 | level part of the SELinux file context. This is the MLS/MCS attribute, sometimes known as the range . _default feature works as for seuser. |
|
serole | no | role part of SELinux file context, _default feature works as for seuser. |
||
setype | no | type part of SELinux file context, _default feature works as for seuser. |
||
seuser | no | user part of SELinux file context. Will default to system policy, if applicable. If set to _default , it will use the user portion of the policy if available |
||
src | no | path of the file to link to (applies only to state=link ). Will accept absolute, relative and nonexisting paths. Relative paths are not expanded. |
||
state | no | file |
|
If directory , all immediate subdirectories will be created if they do not exist, since 1.7 they will be created with the supplied permissions. If file , the file will NOT be created if it does not exist, see the copy or template module if you want that behavior. If link , the symbolic link will be created or changed. Use hard for hardlinks. If absent , directories will be recursively deleted, and files or symlinks will be unlinked. If touch (new in 1.4), an empty file will be created if the c(path) does not exist, while an existing file or directory will receive updated file access and modification times (similar to the way `touch` works from the command line). |
- file: path=/etc/foo.conf owner=foo group=foo mode=0644
- file: src=/file/to/link/to dest=/path/to/symlink owner=foo group=foo state=link
- file: src=/tmp/{{ item.path }} dest={{ item.dest }} state=link
with_items:
- { path: 'x', dest: 'y' }
- { path: 'z', dest: 'k' }
Note
See also copy, template, assemble