How do you create a directory www
at /srv
on a Debian-based system using an Ansible playbook?
If you want to create directory in windows:
- name: Create directory structure
win_file:
path: C:\Temp\folder\subfolder>
state: directory
you can create using:
- name: Create Folder
file:
path: /srv/www/
owner: user
group: user
mode: 0755
state: directory
- name: Create Folder
file:
path=/srv/www/
owner=user
group=user
mode=0755
state=directory
Refer - http://docs.ansible.com/ansible/file_module.html
You can create a directory. using
# create a directory if it doesn't exist
- file: path=/src/www state=directory mode=0755
You can also consult http://docs.ansible.com/ansible/file_module.html for further details regaridng directory and file system.
- file:
path: /etc/some_directory
state: directory
mode: 0755
owner: someone
group: somegroup
That's the way you can actually also set the permissions, the owner and the group. The last three parameters are not obligatory.
Easiest way to make a directory in Ansible.
OR
You want to give sudo privileges to that directory.
We have modules available to create directory , file in ansible
Example
- name: Creates directory
file:
path: /src/www
state: directory