forked from xialingxiao/andokaelk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.yaml
165 lines (156 loc) · 5.75 KB
/
run.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
---
- name: setup
hosts: all
vars_files:
- vars/common_vars
- vars/common_vault
- vars/vars
- vars/vault
vars:
- project_stage_dir: "{{ stage_dir }}/{{ project_id }}/{{ inventory_hostname }}"
tasks:
- name: setup
debug: msg="gathered info from host"
- name: Get CA
hosts: registry
vars_files:
- vars/vars
- vars/vault
- vars/common_vars
- vars/common_vault
vars:
- project_stage_dir: "{{ stage_dir }}/{{ project_id }}/{{ inventory_hostname }}"
tasks:
- name: sync the CA
synchronize:
src: "{{ ca_dir }}/"
dest: ca/
mode: pull
- name: Propagate CA
hosts: dest
serial: 1
vars_files:
- vars/vars
- vars/vault
- vars/common_vars
- vars/common_vault
vars:
- project_stage_dir: "{{ stage_dir }}/{{ project_id }}/{{ inventory_hostname }}"
tasks:
- name: make sure that ca directory exists
file: path={{ ca_dir }} state=directory
- name: sync the CA
copy: src=ca/ca.pem dest="{{ ca_dir }}/ca.pem"
- name: sync the CA key
copy: src=ca/ca-key.pem dest="{{ ca_dir }}/ca-key.pem"
- name: create folder for trusted ca
file: path=/usr/local/share/ca-certificates/{{ project_id }} state=directory
become: true
become_user: root
- name: transfer the CA certificate
copy: remote_src=True src="{{ ca_dir }}/ca.pem" dest=/usr/local/share/ca-certificates/{{ project_id }}/ca.crt
become: true
become_user: root
- name: Update CA
hosts: dest
serial: 1
vars_files:
- vars/vars
- vars/vault
- vars/common_vars
- vars/common_vault
vars:
- project_stage_dir: "{{ stage_dir }}/{{ project_id }}/{{ inventory_hostname }}"
tasks:
- name: update list of trusted CAs
command: update-ca-certificates
become: true
become_user: root
- name: restart docker
service: name=docker state=restarted
become: true
become_user: root
- name: login to the registry
command: docker login -u {{ registry_user }} -p {{ registry_pass }} -e null https://{{ docker_registry }}
- name: setup nodes
hosts: nodes
vars_files:
- vars/common_vars
- vars/common_vault
- vars/vars
- vars/vault
vars:
- project_stage_dir: "{{ stage_dir }}/{{ project_id }}/{{ inventory_hostname }}"
tasks:
- name: make sure that the project staging directory exists
file: path={{ project_stage_dir }} state=directory
- name: send the docker-compose binary
copy: src="docker-compose" dest={{ project_stage_dir }}/docker-compose
- name: make docker-compose executable
file: path={{ project_stage_dir }}/docker-compose mode=0755
- name: setup the kafka cluster on nodes
hosts: nodes
serial: 1
vars_files:
- vars/common_vars
- vars/common_vault
- vars/vars
- vars/vault
vars:
- project_stage_dir: "{{ stage_dir }}/{{ project_id }}/{{ inventory_hostname }}"
- node_id: "{% for node in groups.nodes %}{% if inventory_hostname==node %}{{ -1 + loop.index }}{% endif %}{% endfor %}"
- compose_command: "up -d"
roles:
- kafka
- name: setup the elasticsearch cluster on nodes
hosts: nodes
vars_files:
- vars/common_vars
- vars/common_vault
- vars/vars
- vars/vault
vars:
- project_stage_dir: "{{ stage_dir }}/{{ project_id }}/{{ inventory_hostname }}"
- node_id: "{% for node in groups.nodes %}{% if inventory_hostname==node %}{{ -1 + loop.index }}{% endif %}{% endfor %}"
- compose_command: "up -d"
roles:
- elasticsearch
- name: setup the logstash connectors on nodes
hosts: nodes
vars_files:
- vars/common_vars
- vars/common_vault
- vars/vars
- vars/vault
vars:
- project_stage_dir: "{{ stage_dir }}/{{ project_id }}/{{ inventory_hostname }}"
- node_id: "{% for node in groups.nodes %}{% if inventory_hostname==node %}{{ -1 + loop.index }}{% endif %}{% endfor %}"
- compose_command: "up -d"
roles:
- { role: logstash, type: "connector", template: "logstash_connector.conf", compose: "docker-compose-connector.yaml" }
- name: setup receiver and auth proxy
hosts: gateway
vars_files:
- vars/common_vars
- vars/common_vault
- vars/vars
- vars/vault
vars:
- project_stage_dir: "{{ stage_dir }}/{{ project_id }}/{{ inventory_hostname }}"
- compose_command: "up -d"
- host_ip: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
- node_id: ""
pre_tasks:
- name: make sure that the staging directory exists
file: path={{ stage_dir }} state=directory
- name: create project folder at staging directory
file: path={{ project_stage_dir }} state=directory
- name: send the docker-compose binary
copy: src="docker-compose" dest={{ project_stage_dir }}/docker-compose
- name: make docker-compose executable
file: path={{ project_stage_dir }}/docker-compose mode=0755
roles:
- kibana
- { role: logstash, type: "receiver", template: "logstash_receiver.conf", compose: "docker-compose-receiver.yaml" }
- { role: auth, role_id: kibana, server_cert: "{{ kibana_cert }}", server_key: "{{ kibana_key }}", access_host: "{{ kibana_access_host }}", access_port: "{{ kibana_access_port }}", redirect_domain: "{{ kibana_domain|default('localhost') }}", upstream_host: "kibana", upstream_port: "{{ kibana_port }}", access_white_list: "kibana_access_white_list" }
- { role: auth, role_id: elasticsearch, server_cert: "{{ elasticsearch_cert }}", server_key: "{{ elasticsearch_key }}", access_host: "{{ elasticsearch_access_host }}", access_port: "{{ elasticsearch_access_port }}", redirect_domain: "{{ elasticsearch_domain|default('localhost') }}", upstream_host: "elasticsearch0", upstream_port: "{{ elasticsearch_port_start }}", access_white_list: "elasticsearch_access_white_list" }