Interview Prep/Ansible/Ad-hoc Commands, Modules and Idempotency

What can the `file` module do?

BeginnerConceptAd-hoc Commands, Modules and Idempotency
Answer

The file module manages files, directories and links through the state parameter: file (verify permissions), directory (create), absent (delete), touch, link (symlink) and hard.

- ansible.builtin.file:
    path: /opt/app/releases
    state: directory
    owner: app
    group: app
    mode: "0755"
    recurse: false

Always quote mode. state: absent on a directory deletes it recursively, so double check the path variable is not empty.

All Ansible questions Roadmap: Ansible

More on Ad-hoc Commands, Modules and Idempotency