HOWTO
- https://docs.ansible.com/ansible/latest/collections/ansible/builtin/file_module.html
- https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html
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