-
Notifications
You must be signed in to change notification settings - Fork 30
/
main.yml
80 lines (71 loc) · 1.62 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
# init tasks main
- name: "Create general directories"
file:
path: "{{ project_dir }}/{{ item }}"
state: directory
with_items:
- group_vars
- host_vars
- library
- name: "Create directory structure for roles"
file:
path: "{{ project_dir }}/roles/{{ item[0] }}/{{ item[1] }}"
state: directory
with_nested:
- "{{ roles }}"
- [ 'defaults', 'files', 'handlers', 'meta', 'tasks', 'templates', 'vars' ]
tags:
- roles
- name: "Create main.yml in directory structure for roles"
template:
src: "{{ item[1] }}.j2"
dest: "{{ project_dir }}/roles/{{ item[0] }}/{{ item[1] }}/main.yml"
with_nested:
- "{{ roles }}"
- [ 'handlers', 'tasks' ]
tags:
- roles
- name: "Create group_vars/all"
template:
src: "{{ item }}.j2"
dest: "{{ project_dir }}/group_vars/{{ item }}"
with_items:
- all
tags:
- group_vars
- name: "Create inventory files"
template:
src: inventory.j2
dest: "{{ project_dir }}/{{ item }}"
with_items:
- production
- staging
tags:
- inventory
- name: "Create role playbooks"
template:
src: role.j2
dest: "{{ project_dir }}/{{ item }}.yml"
with_items:
- "{{ roles }}"
tags:
- roles
- name: "Create master playbook"
template:
src: master.j2
dest: "{{ project_dir }}/master.yml"
tags:
- master
- name: "Register all directories"
find:
paths: "{{ project_dir }}"
file_type: directory
recurse: yes
register: project_dirs
- name: "Add .gitkeep to all directories"
copy:
dest: "{{ item.path }}/.gitkeep"
content: ''
with_items:
- "{{ project_dirs.files }}"