-
Notifications
You must be signed in to change notification settings - Fork 0
/
vault.yaml
173 lines (154 loc) · 3.69 KB
/
vault.yaml
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
---
- name: Install Vault Server
hosts: all
become: true
gather_facts: false
tasks:
- name: Update APT
apt:
upgrade: dist
update_cache: yes
tags:
- core
- name: Install prerequisites
apt:
name: "{{ item }}"
update_cache: yes
loop:
- jq
- awscli
tags:
- core
- name: Create group vault
group:
name: vault
state: present
tags:
- core
- name: Create user vault
user:
name: vault
group: vault
state: present
createhome: yes
home: /home/vault
shell: /bin/bash
tags:
- render
- core
- name: Create directories
become: true
file:
dest: "{{ item }}"
state: directory
owner: "{{ user }}"
group: "{{ group }}"
mode: "{{ mode }}"
with_items:
- "{{ vault_home }}"
- "{{ vault_bin_home }}"
- "{{ vault_policy_home }}"
- "{{ vault_config_home }}"
- "{{ vault_log_home }}"
tags:
- render
- core
- name: Render template file
template:
src: "templates/{{ item }}"
dest: "{{ vault_bin_home }}/{{ item }}"
owner: "{{ user }}"
group: "{{ group }}"
mode: "700"
with_items:
- vault_install.sh
- vault_initialization.sh
- vault_create_policies.sh
- vault_setup_kv_engine.sh
- vault_create_orphan_token.sh
- vault_create_consul_keygen.sh
- vault_create_nomad_keygen.sh
tags:
- render
- core
- name: Copy Vault policies
copy:
src: "policies/{{ item }}"
dest: "{{ vault_policy_home }}/{{ item }}"
owner: "{{ user }}"
group: "{{ group }}"
mode: "700"
with_items:
- vault-admin.hcl
tags:
- render
- core
- name: Copy main configuration
template:
src: "templates/vault_config.hcl"
dest: "{{ vault_config_home }}/vault_config.hcl"
owner: "{{ user }}"
group: "{{ group }}"
mode: "{{ mode }}"
tags:
- render
- core
- name: Install Vault
command: "{{ vault_bin_home }}/vault_install.sh"
tags:
- render
- core
- name: Set systemd vault.service
template:
src: "templates/vault.service"
dest: "/usr/lib/systemd/system/vault.service"
mode: "{{ mode }}"
tags:
- render
- name: Start and enable Vault
systemd:
name: vault
state: restarted
daemon_reload: yes
enabled: yes
run_once: true
- name: Initialization Vault server
command: "{{ vault_bin_home }}/vault_initialization.sh"
- name: Create policies
command: "{{ vault_bin_home }}/vault_create_policies.sh"
tags:
- policies
- name: Enable KV2 engine
command: "{{ vault_bin_home }}/vault_setup_kv_engine.sh"
tags:
- kv2
- name: Create Vault token for CICD
command: "{{ vault_bin_home }}/vault_create_orphan_token.sh"
tags:
- cicd-token
- name: Install consul bin
unarchive:
src: "{{ item }}"
dest: "/tmp"
remote_src: yes
owner: "{{ user }}"
group: "{{ group }}"
with_items:
- "https://releases.hashicorp.com/consul/1.16.0/consul_1.16.0_linux_amd64.zip"
- name: Create and save Consul keygen
command: "{{ vault_bin_home }}/vault_create_consul_keygen.sh"
tags:
- consul-keygen
- name: Install nomad bin
unarchive:
src: "{{ item }}"
dest: "/tmp"
remote_src: yes
owner: "{{ user }}"
group: "{{ group }}"
with_items:
- "https://releases.hashicorp.com/nomad/1.6.0/nomad_1.6.0_linux_amd64.zip"
- name: Create and save Nomad keygen
command: "{{ vault_bin_home }}/vault_create_nomad_keygen.sh"
tags:
- nomad-keygen