-
Notifications
You must be signed in to change notification settings - Fork 0
/
p_install_processing_server.yml
134 lines (126 loc) · 4.08 KB
/
p_install_processing_server.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
---
#
# Purpose of this playbook is to prepare running ocrd processing server with
# ocrd-webapi-implementation to the VM. It can be logically divided into 3 parts:
# 1. Generall tasks like installing needed software, add ssh-keys for developers and uploading
# scripts for maintanance
# 2. Preparing to run processing server and webapi: copy files and scripts, create folder for
# volume-mount
# 3. Installing ocrd and processors to a venv: The processing server runs in Docker and deploys
# the processors to the host system. Therefore a venv is used wich is installed via ocrd_all
#
- hosts: ocrd-dev
vars:
core_repo_path: /home/cloud/repos/core
venv_path: /home/cloud/repos/ocrd_all/venv
webapiuser: "{{ ( lookup('file', 'vars-ocrd.yml') | from_yaml).webapiuser }}"
webapipass: "{{ ( lookup('file', 'vars-ocrd.yml') | from_yaml).webapipass }}"
tasks:
#
# General tasks: install depedencies, maintanance
#
- name: Install dependencies with a apt
become: true
apt:
pkg:
- make
- python3-pip
- name: Add ssh keys for coworkers to log into vm
authorized_key:
user: cloud
state: present
key: "{{ lookup('file', item) }}"
with_fileglob:
- files/ocrd-processing-server/ssh-pub-keys/*.pub
- name: Create tools dir
file:
path: $HOME/tools
state: directory
mode: '0755'
- name: Copy script for updating the venv regarding core
copy:
src: files/ocrd-processing-server/update-core-in-venv.sh
dest: /home/cloud/tools/update-core-in-venv.sh
mode: '0755'
# roles:
# - role: install_mongosh
#
# Prepare running the processing-server
#
- name: Copy script for depoloying the service
copy:
src: files/ocrd-processing-server/start-docker.py
dest: /home/cloud/start.py
mode: '0755'
- name: Install stuff with pip needed to run the startup-script
pip:
name:
- click
- sh
- name: Upload config-file for processing-server
copy:
src: '{{ item }}'
dest: $HOME/tools
loop:
- files/ocrd-processing-server/ocrd-ps-config.yml
# the workers are run as user cloud, volume folder should have cloud as owner to be writeable
# properly
- name: Create volume folder for workspaces
file:
path: /tmp/ocrd-webapi-data
state: directory
mode: '0755'
- name: Upload docker-compose
template:
src: files/ocrd-processing-server/docker-compose.yml
dest: $HOME/tools
#
# Install ocrd-processors to venv to make running workers on host possible
#
- name: Clone ocrd_all
git:
repo: https://github.com/OCR-D/ocrd_all
dest: "$HOME/repos/ocrd_all"
update: false
recursive: false
- name: install dependencies for ocrd_all
command: make deps-ubuntu
become: true
args:
chdir: /home/cloud/repos/ocrd_all
creates: /home/cloud/repos/ocrd_all/venv
- name: create venv with ocrd_all (takes about 35 Minutes)
command: make all
args:
chdir: /home/cloud/repos/ocrd_all
creates: /home/cloud/repos/ocrd_all/venv
- name: Add venv to PATH
blockinfile:
marker: "# {mark} ANSIBLE MANAGED BLOCK Add venv to PATH"
path: '/home/cloud/.profile'
block: |
if [ -d '{{ venv_path }}/bin' ] && [[ ":$PATH:" != *":{{ venv_path }}/bin:"* ]]; then
PATH={{ venv_path }}/bin:$PATH
fi
- name: Create ssh-key for self login
openssh_keypair:
path: "~/.ssh/ocrd-self-login.key"
type: rsa
force: no
- name: Read ssh-key for next task
command: "cat $HOME/.ssh/ocrd-self-login.key.pub"
register: myownpubkey
- name: Add ssh-key for self login
authorized_key:
user: cloud
state: present
key: "{{ myownpubkey.stdout }}"
- name: Upload script to download ocrd-models
copy:
src: files/ocrd-processing-server/download-ocrd-resources.sh
dest: $HOME/tools/download-ocrd-resources.sh
mode: '0755'
- name: call ocrd-models-download-script
command:
cmd: bash tools/download-ocrd-resources.sh
creates: /home/cloud/.local/share/ocrd-resources