-
Notifications
You must be signed in to change notification settings - Fork 0
/
vault-ha.yml
85 lines (72 loc) · 2.11 KB
/
vault-ha.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
81
82
83
84
85
---
- hosts: vault
roles:
- keepalived
- hosts: vault-1
tasks:
- include_role:
name: easy-rsa
- name: fetch ca.crt
fetch:
src: /usr/share/easy-rsa/pki/ca.crt
dest: .
- hosts: vault
tasks:
- name: copy ca.crt
copy:
src: vault-1/usr/share/easy-rsa/pki/ca.crt
dest: /usr/local/share/ca-certificates/Easy-RSA-CA.crt
- name: update-ca-certificates
shell: |
update-ca-certificates
- name: create key
shell: |
openssl genrsa -out {{ inventory_hostname }}.key
args:
chdir: /root
creates: "{{ inventory_hostname }}.key"
- name: create req
shell: |
openssl req -new -key {{ inventory_hostname }}.key -out {{ inventory_hostname }}.req -subj "/C=NZ/ST=Wellington/L=Wellington/O=pdericson/OU=pdericson/CN={{ inventory_hostname }}" -addext "subjectAltName = IP:127.0.0.1, IP:{{ ansible_eth1.ipv4.address }}"
args:
chdir: /root
creates: "{{ inventory_hostname }}.req"
- name: fetch req
fetch:
src: /root/{{ inventory_hostname }}.req
dest: .
- hosts: vault-1
tasks:
- name: copy req
copy:
src: "{{ item }}/root/{{ item }}.req"
dest: /root/{{ item }}.req
with_items: "{{ groups['vault'] }}"
- name: easyrsa import-req
shell: |
./easyrsa import-req /root/{{ item }}.req {{ item }}
args:
chdir: /usr/share/easy-rsa
creates: pki/reqs/{{ item }}.req
with_items: "{{ groups['vault'] }}"
- name: easyrsa sign-req
shell: |
./easyrsa --batch sign-req server {{ item }}
args:
chdir: /usr/share/easy-rsa
creates: pki/issued/{{ item }}.crt
with_items: "{{ groups['vault'] }}"
- name: fetch crt
fetch:
src: /usr/share/easy-rsa/pki/issued/{{ item }}.crt
dest: .
with_items: "{{ groups['vault'] }}"
- hosts: vault
tasks:
- name: copy crt
copy:
src: vault-1/usr/share/easy-rsa/pki/issued/{{ inventory_hostname }}.crt
dest: /root/{{ inventory_hostname }}.crt
- hosts: vault
roles:
- vault-ha