Skip to content

Instantly share code, notes, and snippets.

@a-nldisr
Created July 7, 2020 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a-nldisr/e6fad5df9d31c7f1b8a097e2a9d700db to your computer and use it in GitHub Desktop.
Save a-nldisr/e6fad5df9d31c7f1b8a097e2a9d700db to your computer and use it in GitHub Desktop.
- name: 'Verify if directories already exists'
stat:
path: "{{ playbook_dir }}/roles/{{ new_role_name }}/{{item.dest}}"
register: folder_stats
loop:
- { dest: "tasks" }
- { dest: "templates" }
- { dest: "defaults" }
- { dest: "handlers" }
# Could not find a shorter way to query the path
- name: 'Create top directory level structures'
file:
path: "{{ item.invocation.module_args.path }}"
state: directory
mode: '0755'
when: item.stat.exists == false
with_items:
- "{{ folder_stats.results }}"
tags: create
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment