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.
More on Ad-hoc Commands, Modules and Idempotency
What is an ad-hoc command and what is its syntax?BeginnerWhat does `ansible all -m ping` actually test?BeginnerGive practical use cases for ad-hoc commands.IntermediateWhat is the difference between the `command` and `shell` modules?BeginnerCompare `raw`, `command`, `shell` and `script`.IntermediateWhy prefer a dedicated module over `shell`/`command`?Beginner