Quantcast
Channel: DevOps tips & tricks
Viewing all articles
Browse latest Browse all 181

Ansible - create multiple directories

$
0
0

HOWTO

 

GitHub repo

 


 Create role

- name: Create /app/dave  dir
become: true
file:
path: /app/dave
state: directory
owner: dave
group: dave
recurse: yes
mode: '0755'

- name: Create /app/dave/ appl dirs
file:
path: "{{ item }}"
owner: dave
group: dave
recurse: yes
with_items:
- /app/dave/opt/jboss
- /app/dave/data/

Dir structure
[dave@dave devops-ansible]$ find create-dev-env/
create-dev-env/
create-dev-env/tasks
create-dev-env/tasks/main.yml

 

Call role 

Create file local.yml

---
- name: Configure local dev env
hosts: localhost
connection: local
gather_facts: no
roles:
- dave-dev-env

 

Run playbook

ansible-playbook local.yml




Viewing all articles
Browse latest Browse all 181

Trending Articles