Creating a directory is a recurrent operation. This requires when working like installing the application, taking backup and restoration, managing the user’s home directory, allocate a portion to a folder for a specific purpose. You can create a directory using Ansible's built-in file module.
Here's an example playbook that creates a directory:
- name: Create directory
hosts: your_host
tasks:
- name: Create directory
file:
path: /path/to/directory
state: directory
In this playbook, the file module is used to create a directory. The path parameter specifies the path of the directory to be created, and the state parameter is set to directory to indicate that a directory should be created.
You can run this playbook using the ansible-playbook command, like this:
ansible-playbook create_directory.yaml
Replace create_directory.yaml with the name of your playbook file.
Comments (0)