Skip to content

Commit d0e3bf2

Browse files
author
Istemi Ekin Akkus
committed
update and cleanup ansible installation scripts and readme
1 parent c04b7d0 commit d0e3bf2

File tree

7 files changed

+138
-168
lines changed

7 files changed

+138
-168
lines changed

ManagementService/management_init.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,6 @@ def printUsage():
403403
f.write("docker run -d --ulimit nofile=262144:262144 --name Management --env-file .env --log-opt max-size=500m --log-opt max-file=5 -P -p " + str(MANAGEMENT_SERVICE_EXPOSED_PORT) + ":8080 microfn/sandbox\n")
404404
os.chmod("start_management.sh", 0o0775)
405405

406-
print("Please run: start_management.sh to start the Management container")
407-
408406
DLCLIENT.shutdown()
409407
DLCLIENT_MANAGEMENT.shutdown()
410408
elif action == "print":

deploy/ansible/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ GUI_SRC:=../../GUI
101101
GUIFILES:=$(shell find $(GUI_SRC) | grep -v "knix_gui_deployment_package.tar.gz")
102102
../../GUI/knix_gui_deployment_package.tar.gz: $(GUIFILES)
103103
touch $@
104+
cd ../../GUI; make; cd -
104105
tar --exclude=knix_gui_deployment_package.tar.gz -czf $@ -C $(GUI_SRC) .
105106

106107
nginx.yaml: ../../GUI/knix_gui_deployment_package.tar.gz

deploy/ansible/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# KNIX ansible installation
1818

19-
To setup KNIX on localhost, or a single remote host, or a cluster of hosts
19+
To setup KNIX on localhost, or a single remote host, or a cluster of hosts
2020
(Tested on: Ubuntu 18.04 and Debian 9 as target machines)
2121

2222
## Prerequisites: on host machine
@@ -27,6 +27,11 @@ To setup KNIX on localhost, or a single remote host, or a cluster of hosts
2727

2828
## Prerequisites: on target machines
2929

30+
Note: The following steps should be handled by the init_once.yaml during the installation process.
31+
If you find something wrong or missing, please consider opening an issue on [GitHub](https://github.com/knix-microfunctions/knix)
32+
and/or letting us know in our [Slack workspace](https://knix.slack.com).
33+
Thank you!
34+
3035
1. You can ssh into the target machines/VMs without a password. If not then run (on host machine):
3136

3237
```bash
@@ -38,7 +43,7 @@ To setup KNIX on localhost, or a single remote host, or a cluster of hosts
3843

3944
3. Appropriate proxies (/etc/profile, /etc/bash.bashrc, and /etc/apt/apt.conf) are set on target machines
4045

41-
4. `python`, `python-dev`, `python-pip` are installed on each of the target machines
46+
4. `python3`, `python3-dev`, `python3-pip` are installed on each of the target machines
4247

4348
```bash
4449
sudo apt-get update

deploy/ansible/init_once.yaml

Lines changed: 126 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
https_proxy: "{{ https_proxy.stdout }}"
3434

3535
- debug:
36-
msg:
36+
msg:
3737
- inventory_hostname = {{ inventory_hostname }}
3838
- ansible_default_ipv4.address = {{ ansible_default_ipv4.address }}
3939
- mfn_server_installation_folder = {{ mfn_server_installation_folder }}
@@ -52,56 +52,150 @@
5252
- python3-pip
5353
- netcat
5454
- rsync
55-
- python-dev
56-
- libffi-dev
57-
- libssl-dev
58-
- libxml2-dev
55+
- python3-dev
56+
- libffi-dev
57+
- libssl-dev
58+
- libxml2-dev
5959
- libxslt1-dev
6060
- zlib1g-dev
6161
state: latest
6262

6363
- name: pip install pyOpenSSL
6464
pip:
65-
name: pyOpenSSL
65+
name: pyOpenSSL
6666
executable: pip3
6767
environment:
6868
http_proxy: "{{ http_proxy }}"
6969
https_proxy: "{{ https_proxy }}"
7070

71-
- name: Ensure mfn root folder exists
71+
- name: configure /etc/hosts - disable 127.0.1.1
72+
lineinfile:
73+
path: "/etc/hosts"
74+
regexp: "^127.0.1.1"
75+
line: "#127.0.1.1 {{ inventory_hostname }}"
76+
77+
- name: configure /etc/hosts - add ip address hostname mapping
78+
lineinfile:
79+
path: "/etc/hosts"
80+
insertafter: EOF
81+
line: "{{ ansible_default_ipv4.address }} {{ inventory_hostname }} {{ inventory_hostname }}"
82+
83+
- name: ensure docker is at the latest version
84+
apt: name=docker-ce update_cache=yes
85+
register: dockerupdate
86+
ignore_errors: True
87+
88+
- name: Remove old docker
89+
apt:
90+
name:
91+
- docker
92+
- docker-engine
93+
- docker.io
94+
- runc
95+
state: absent
96+
when: dockerupdate.failed
97+
98+
- name: get docker key
99+
get_url:
100+
url: https://download.docker.com/linux/ubuntu/gpg
101+
dest: /etc/apt/docker.gpg.key
102+
environment:
103+
http_proxy: "{{ http_proxy }}"
104+
https_proxy: "{{ https_proxy }}"
105+
when: dockerupdate.failed
106+
107+
- name: install docker key
108+
shell: "apt-key add /etc/apt/docker.gpg.key"
109+
when: dockerupdate.failed
110+
111+
- name: add docker repo
112+
apt_repository:
113+
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable"
114+
state: present
115+
when: dockerupdate.failed
116+
117+
- name: ensure docker is at the latest version
118+
apt: name=docker-ce update_cache=yes
119+
when: dockerupdate.failed
120+
121+
# The below approach risks when updating the docker using regular software updates.
122+
# a better way probably is just to override the configuration with a new file
123+
#- name: fix docker service command line
124+
# lineinfile:
125+
# path: /lib/systemd/system/docker.service
126+
# backrefs: yes
127+
# regex: "^ExecStart=(.*)-H fd://(.*)$"
128+
# line: "ExecStart=\\1\\2"
129+
# when: dockerupdate.failed
130+
131+
#- name: configure docker daemon
132+
# copy:
133+
# dest: /etc/docker/daemon.json
134+
# content: |
135+
# {
136+
# "hosts": ["fd://","unix:///var/run/docker.sock","tcp://0.0.0.0"]
137+
# }
138+
#################
139+
140+
# see the following links why this approach might be better
141+
# https://stackoverflow.com/questions/44052054/unable-to-start-docker-after-configuring-hosts-in-daemon-json
142+
# https://success.docker.com/article/how-do-i-enable-the-remote-api-for-dockerd
143+
- name: docker service configuration directory
72144
file:
73-
path: "{{ mfn_server_installation_folder }}"
145+
path: /etc/systemd/system/docker.service.d
74146
state: directory
75-
mode: '775'
147+
148+
- name: add override configuration for docker start
149+
copy:
150+
dest: /etc/systemd/system/docker.service.d/startup_options.conf
151+
content: |
152+
[Service]
153+
ExecStart=
154+
ExecStart=/usr/bin/dockerd -H unix:// -H tcp://0.0.0.0:2375
155+
156+
- name: override configuration for docker daemon to disable tls
157+
copy:
158+
dest: /etc/docker/daemon.json
159+
content: |
160+
{
161+
"tls": false
162+
}
163+
164+
- name: configure docker proxy
165+
copy:
166+
dest: /etc/systemd/system/docker.service.d/proxy.conf
167+
content: |
168+
[Service]
169+
Environment=HTTP_PROXY={{ http_proxy }}
170+
Environment=HTTPS_PROXY={{ https_proxy }}
171+
Environment=NO_PROXY={{ no_proxy }}
172+
when: http_proxy != "" and dockerupdate.failed
173+
174+
- name: systemd restart docker
175+
systemd:
176+
daemon_reload: yes
177+
name: docker
178+
enabled: true
179+
state: restarted
180+
when: dockerupdate.failed
76181

77182
- name: ensure java is at the latest version
78-
apt:
183+
apt:
79184
name: openjdk-8-jre-headless
80185
state: latest
81186
update_cache: yes
82187

83-
- name: get http_proxy
84-
shell: "su - -c 'echo $http_proxy'"
85-
register: http_proxy
86-
87-
- name: get https_proxy
88-
shell: "su - -c 'echo $https_proxy'"
89-
register: https_proxy
90-
91-
- set_fact:
92-
http_proxy: "{{ http_proxy.stdout }}"
93-
https_proxy: "{{ https_proxy.stdout }}"
94-
95-
- debug:
96-
msg:
97-
- http_proxy = {{ http_proxy }}
98-
- https_proxy = {{ https_proxy }}
188+
- name: Ensure knix mfn root folder exists
189+
file:
190+
path: "{{ mfn_server_installation_folder }}"
191+
state: directory
192+
mode: '775'
99193

100194
- name: Copy start-all.sh script
101195
copy:
102196
mode: '775'
103197
src: "./scripts/start-all.sh"
104-
dest: "{{ mfn_server_installation_folder }}/"
198+
dest: "{{ mfn_server_installation_folder }}/"
105199

106200
- name: Copy stop-all.sh script
107201
copy:
@@ -110,25 +204,25 @@
110204
dest: "{{ mfn_server_installation_folder }}/"
111205

112206
- name: copy wait-for-it.sh script
113-
copy:
207+
copy:
114208
mode: '775'
115209
src: "./scripts/wait-for-it.sh"
116210
dest: "{{ mfn_server_installation_folder }}/"
117211

118212
- name: copy tail-service-logs.sh script
119-
copy:
213+
copy:
120214
mode: '775'
121215
src: "./scripts/tail-service-logs.sh"
122216
dest: "{{ mfn_server_installation_folder }}/"
123217

124218
- name: copy purge-riak.sh script
125-
copy:
219+
copy:
126220
mode: '775'
127221
src: "./scripts/purge-riak.sh"
128222
dest: "{{ mfn_server_installation_folder }}/"
129223

130224
#https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html
131-
- name: configure /etc/sysctl.conf vm.max_map_count=262144
132-
sysctl:
225+
- name: configure /etc/sysctl.conf vm.max_map_count=262144
226+
sysctl:
133227
name: "vm.max_map_count"
134228
value: "262144"

deploy/ansible/management.yaml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
install_dir: "{{ mfn_server_installation_folder }}/management"
2626
datalayer_connect: "{{ ansible_default_ipv4.address }}:4998" # same host
27-
riak_connect: "{{ hostvars[groups['riak'][0]].ansible_default_ipv4.address }}:8087"
2827
elasticsearch_connect: "{{ hostvars[groups['elasticsearch'][0]].ansible_default_ipv4.address }}:9200"
2928
nginx_http_listen_port: "{{ nginx_http_listen_port }}"
3029
nginx_connect: "{{ hostvars[groups['nginx'][0]].ansible_default_ipv4.address }}:{{ nginx_http_listen_port }}"
@@ -57,28 +56,13 @@
5756
- management_archive_filename = {{ management_archive_filename }}
5857
- install_dir = {{ install_dir }}
5958
- datalayer connect string = {{ datalayer_connect }}
60-
- riak_connect = {{ riak_connect }}
6159
- elasticsearch_connect = {{ elasticsearch_connect }}
6260
- nginx_connect = {{ nginx_connect }}
6361
- http_proxy = {{ http_proxy }}
6462
- https_proxy = {{ https_proxy }}
6563
- no_proxy = {{ no_proxy }}
6664

6765

68-
# Prerequisites to run the management init script
69-
- name: pip install docker
70-
pip:
71-
name:
72-
- docker
73-
- riak
74-
executable: pip3
75-
environment:
76-
http_proxy: "{{ http_proxy }}"
77-
https_proxy: "{{ https_proxy }}"
78-
no_proxy: "{{ no_proxy }}"
79-
HTTP_PROXY: "{{ http_proxy }}"
80-
HTTPS_PROXY: "{{ https_proxy }}"
81-
8266
- name: remove old management folder
8367
file:
8468
state: absent
@@ -137,6 +121,7 @@
137121
set -x
138122
cat <<END >>dockerrun.sh
139123
set -x
124+
pip3 install --upgrade pip
140125
pip3 install docker thrift
141126
python3 management_init.py start
142127
END
@@ -175,7 +160,6 @@
175160
environment:
176161
MFN_HOSTNAME: "{{ inventory_hostname }}"
177162
DATALAYER_CONNECT: "{{ datalayer_connect }}"
178-
RIAK_CONNECT: "{{ riak_connect }}"
179163
ELASTICSEARCH_CONNECT: "{{ elasticsearch_connect }}"
180164
NGINX_CONNECT: "{{ nginx_connect }}"
181165
http_proxy: "{{ http_proxy }}"

deploy/ansible/riak.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,13 @@
277277
regexp: "^bitcask.max_file_size = "
278278
line: "bitcask.max_file_size = 500MB"
279279

280-
- name: configure /etc/security/limits.conf riak soft nofile 65536
280+
- name: configure /etc/security/limits.conf riak soft nofile 65536
281281
lineinfile:
282282
path: "/etc/security/limits.conf"
283283
regexp: "^riak soft nofile"
284284
line: "riak soft nofile 65536"
285285

286-
- name: configure /etc/security/limits.conf riak hard nofile 200000
286+
- name: configure /etc/security/limits.conf riak hard nofile 200000
287287
lineinfile:
288288
path: "/etc/security/limits.conf"
289289
regexp: "^riak hard nofile"

0 commit comments

Comments
 (0)