freehck.mkdir
freehck.mkdir
Create Multiple Directories
Description
This role creates multiple directories. It's useful to include as a requirement for other roles.
Role Variables
mkdir_directories
: list of directories to create, default is []
.
You can list directories in two ways: as strings like /path/to/dir
, or as a list of details like this:
- path: <path>
owner: <owner>
group: <group>
state: [present|absent]
recurse: [true|false]
The only required field is path
; you can skip the others, and the default settings will apply.
Default values for the parameters:
mkdir_default_owner
: root
mkdir_default_group
: root
mkdir_default_mode
: 0755
mkdir_default_state
: present
mkdir_default_recurse
: true
If you want to create several directories with the same owner or group, you can change the mkdir_default_*
settings.
Example
- role: freehck.mkdir
mkdir_directories:
- path: /data/dir1
owner: root
group: root
state: present
recurse: true
- path: /data/dir2
- /data/dir3
Install
To install this role, use Ansible Galaxy:
ansible-galaxy install freehck.mkdir
Known Issues
- Having
recurse: true
(which is the default) means the job status will always show aschanged
: https://github.com/ansible/ansible/issues/32636
License
MIT
Author Information
Dmitrii Kashin, freehck@freehck.ru
ansible-galaxy install freehck.mkdir