forked from palladiumkenya/openmrs-module-afyastat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_afyastat.yml
executable file
·319 lines (268 loc) · 9.16 KB
/
install_afyastat.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
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
---
- hosts: localhost
become_method: sudo
become: true
tasks:
- name: Create Folder opt/afyastat/medic
file:
path: /opt/afyastat/
owner: root
group: root
mode: 0777
recurse: yes
state: directory
- name: Copy installation Package
shell: "cp -r medic /opt/afyastat"
- name: Create Folder etc/pihole
file:
path: /etc/piholesss/
owner: root
group: root
mode: 0777
recurse: yes
state: directory
- name: Copy installation Package
shell: "cp -r medic /opt/afyastat"
- name: Assign rights to directoty
shell: "chmod -R 0777 /opt/afyastat/medic"
- name: install curl
apt:
name: curl
state: present
- name: Free port 53
shell: sed -r -i.orig 's/#?DNSStubListener=yes/DNSStubListener=no/g' /etc/systemd/resolved.conf
shell: sh -c 'rm /etc/resolv.conf && ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf'
shell: systemctl restart systemd-resolved
- debug: var=ansible_enp0s3.ipv4.address
- debug: var=ansible_all_ipv4_addresses
- debug: var=ansible_default_ipv4.address
- name: Update the /etc/hosts file with dns.hmislocal.org name
tags: etchostsupdate
become: yes
become_user: root
lineinfile:
path: "/etc/hosts"
line: "{{ ansible_default_ipv4.address }}\tdns.hmislocal.org"
state: present
backup: yes
register: etchostsupdate
- name: Update the /etc/hosts file with cht.hmislocal.org name
tags: etchostsupdate
become: yes
become_user: root
lineinfile:
path: "/etc/hosts"
line: "{{ ansible_default_ipv4.address }}\tcht.hmislocal.org"
state: present
backup: yes
register: etchostsupdate
- name: Set DOCKER_COUCHDB_ADMIN_PASSWORD=cb6f4d4b-73cc-4c42-97cb-0db5a631190a
tags: etchostsupdate
become: yes
become_user: root
lineinfile:
path: "/etc/environment"
line: "DOCKER_COUCHDB_ADMIN_PASSWORD=cb6f4d4b-73cc-4c42-97cb-0db5a631190a"
state: present
backup: yes
register: etchostsupdate
- name: Set COUCH_URL=http://medic:cb6f4d4b-73cc-4c42-97cb-0db5a631190a@localhost:5988/medic
tags: etchostsupdate
become: yes
become_user: root
lineinfile:
path: "/etc/environment"
line: "COUCH_URL=http://medic:cb6f4d4b-73cc-4c42-97cb-0db5a631190a@localhost:5988/medic"
state: present
backup: yes
register: etchostsupdate
- name: Set COUCH_NODE_NAME=onode@nohost
tags: etchostsupdate
become: yes
become_user: root
lineinfile:
path: "/etc/environment"
line: "COUCH_NODE_NAME=onode@nohost"
state: present
backup: yes
register: etchostsupdate
#- name: Refresh /etc/enviomenyt Sources
#shell: source /etc/environment
#----------------------------------------------------------------------------------------
- name: Concatenating Keys to be used
shell:
cmd: cat hmislocal.key hmislocal.crt > lighttpd.key.and.pem.pem
chdir: /opt/afyastat/medic/tls-certs
- name: Concatenating Keys to be used
shell:
cmd: cat hmislocal.crt bundle.crt > server.chained.pem
chdir: /opt/afyastat/medic/tls-certs
- name: Assign rights to directoty
shell: "chmod -R 0777 /opt/afyastat/medic/tls-certs"
- name: Copy installation Package
shell: "cp -r medic/tls-certs /etc"
- name: Assign rights to directoty
shell: "chmod -R 0777 /etc/tls-certs"
# --------------------------------------------------------------------------------------
- name: apt update
apt:
update-cache: yes
- name: apt-get install apt-transport-https ca-certificates curl software-properties-common
apt:
- name: Install docker packages
remote_user: ubuntu
apt:
name: "{{ item }}"
state: present
update_cache: yes
with_items:
- apt-transport-https
- ca-certificates
- curl
- software-properties-common
tags:
- docker
- name: Add Docker s official GPG key
remote_user: ubuntu
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
tags:
- docker
- name: Verify that we have the key with the fingerprint
remote_user: ubuntu
apt_key:
id: 0EBFCD88
state: present
tags:
- docker
- name: Set up the stable repository
remote_user: ubuntu
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
state: present
update_cache: yes
tags:
- docker
- name: Update apt packages
remote_user: ubuntu
apt:
update_cache: yes
tags:
- docker
- name: Install docker
remote_user: ubuntu
apt:
name: docker-ce
state: present
update_cache: yes
#notify: Start docker on boot
tags:
- docker
- name: Add remote "ubuntu" user to "docker" group
remote_user: ubuntu
user:
name: "ubuntu"
group: "docker"
append: yes
tags:
- docker
- name: Install docker-compose
remote_user: ubuntu
get_url:
url : https://github.com/docker/compose/releases/download/1.25.1-rc1/docker-compose-Linux-x86_64
dest: /usr/local/bin/docker-compose
mode: 'u+x,g+x'
- name: Installing Pi-Hole
become: true
shell:
cmd: "docker-compose -f pi-hole-docker-compose.yml up --detach"
chdir: /opt/afyastat/medic
####################################################################################
- name: hostname was used instead of path. replace
replace:
path: /opt/afyastat/medic/etc-pihole/setupVars.conf
regexp: 'DHCP_START=192.168.2.58'
replace: 'DHCP_START={{ ansible_default_ipv4.address }}'
backup: yes
- name: configure Pi Hole DNS & DHCP - DHCP_ROUTER
replace:
path: /opt/afyastat/medic/etc-pihole/setupVars.conf
regexp: 'DHCP_ROUTER=192.168.2.1'
replace: 'DHCP_ROUTER={{ ansible_default_ipv4.gateway }}'
backup: yes
- name: configure Pi Hole DNS & DHCP - DHCP_ROUTER
replace:
path: /opt/afyastat/medic/etc-pihole/setupVars.conf
regexp: 'BLOCKING_ENABLED=true'
replace: 'BLOCKING_ENABLED=false'
backup: yes
###########################################################################################
- name: configure Pi Hole static ip on dns
tags: etchostsupdate
become: yes
become_user: root
lineinfile:
path: "/opt/afyastat/medic/etc-pihole/custom.list"
line: "cht.hmislocal.org {{ ansible_default_ipv4.address }}"
state: present
backup: yes
register: etchostsupdate
- name: configure Pi Hole static ip on dns
tags: etchostsupdate
become: yes
become_user: root
lineinfile:
path: "/opt/afyastat/medic/etc-pihole/custom.list"
line: "dns.hmislocal.org {{ ansible_default_ipv4.address }}"
state: present
backup: yes
register: etchostsupdate
- name: Copy pihole to etc/pihole
shell: "mv --force /opt/afyastat/medic/etc-pihole/ /etc/pihole"
#Rename the directory from etc-pihle to etc
- name: Assign rights to directoty
shell: "chmod -R 0777 /etc/pihole"
########################################################################################
- name: Installing Medic-OS
become: true
shell:
cmd: "docker-compose -f cht-docker-compose-local-host.yml up --detach"
chdir: /opt/afyastat/medic
- name: Getting Ready, Please to not Turn off or Press any key on the Keyboard, Relax it can take 60 seconds
ansible.builtin.pause:
minutes: 1
#- name: Copy nginx File to Medic-os Container, Relax it can take 60 seconds
#shell: docker cp /opt/afyastat/medic/nginx.conf medic-os:/srv/settings/medic-core/nginx/nginx.conf
- name: Get all containers for restart
command: docker ps -a
register: docker_images
- name: Restarting Medic-os container
shell: docker restart medic-os
- name: apt update
apt:
update-cache: yes
- name: installing nodejs
shell: apt -y install nodejs
- name: installing NPM
shell: apt -y install npm
- name: Uploading AfyaStat Forms
shell: npm install -g medic-conf@3.6.0
- name: Installing pip AfyaStat Forms
shell: apt-get install -y python3-pip
- name: Uploading AfyaStat Forms
shell: python3 -m pip install git+https://github.com/medic/pyxform.git@medic-conf-1.17#egg=pyxform-medic
- name: Waiting for AfyaStat to Start. Please Wait !!!
uri:
url: "http://localhost:5988"
status_code: [200,301]
register: result
until: result.status == 200
retries: 20
delay: 30
- name: Uploading AfyaStat Forms
command: medic-conf --url=http://medic:cb6f4d4b-73cc-4c42-97cb-0db5a631190a@localhost:5988 upload-app-settings delete-all-forms upload-app-forms upload-contact-forms upload-resources upload-custom-translations --accept-self-signed-certs
args:
chdir: /opt/afyastat/medic/AfyaStatForms
- name: "Show Network Interfaces"
command: hostname -I