This repository has been archived by the owner on Dec 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
create_inventory.yml
69 lines (62 loc) · 1.82 KB
/
create_inventory.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
- name: Setup
hosts: all
gather_facts: false
vars:
ansible_python_interpreter: "{{ ansible_playbook_python }}"
env_directories:
- "group_vars"
- "host_vars"
- "handlers"
- "tasks"
- "templates"
- "templates/common"
- "vhosts"
inventory_dir: "environments/local"
tasks:
- name: Create directory for new environment
file:
state: directory
path: "{{ inventory_dir }}"
delegate_to: localhost
- name: Create secrets
vault_random:
password_file: "{{ inventory_dir }}/vault-password"
vartree:
db:
root_password: null
app_password: null
readonly_password: null
delegate_to: localhost
- name: Create directories
file:
state: directory
path: "{{ inventory_dir }}/{{ item }}"
with_items: "{{ env_directories }}"
delegate_to: localhost
- name: Copy files
copy:
src: "{{ item }}"
dest: "{{ inventory_dir }}/{{ item | relpath('environments/template') }}"
with_fileglob:
- "environments/template/templates/common/*.j2"
- "environments/template/tasks/*.yml"
- "environments/template/vhosts/*.yml"
delegate_to: localhost
- name: Generate vars file for all groups
template:
src: "environments/template/group_vars/{{ item }}.yml"
dest: "{{ inventory_dir }}/group_vars/{{ item }}.yml"
force: no
with_items:
- all
- postfix
- sympa
delegate_to: localhost
- name: Create symlink for inventory file
file:
state: link
src: "../../.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory"
dest: "{{ inventory_dir }}/inventory"
force: yes
follow: no
delegate_to: localhost