file

Collection: builtin

Full Name: parallax.builtin.file

Aliases: ansible.builtin.file, file

Synopsis

Manage the state, ownership and permissions of files and directories

Parameters

NameTypeRequiredDefaultDescription
pathstringyesPath to the file or directory
statestringfileState of the file (absent, directory, touch)
modestringThe permission mode of the file or directory
ownerstringName of the user that should own the file
groupstringName of the group that should own the file

Example

- name: Ensure the application directory exists
  file:
    path: /srv/app
    state: directory
    owner: app
    group: app
    mode: "0750"

- name: Remove a stale lock file
  file:
    path: /var/run/app.lock
    state: absent