How do you create a directory www
at /srv
on a Debian-based system using an Ansible playbook?
To create a directory using the file module, you need to set two parameters. Path(alias – name, dest) – This is the absolute path of the directory. State – You should give this as 'directory. ' By default, the value is 'file.
You can use the file module. To create a directory, you need to specify the option state=directory.
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.
You want the file module. To create a directory, you need to specify the option state=directory
:
- name: Creates directory file: path: /src/www state: directory
You can see other options at https://docs.ansible.com/ansible/latest/collections/ansible/builtin/file_module.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With