-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.yml
More file actions
120 lines (107 loc) · 4.11 KB
/
Copy pathmain.yml
File metadata and controls
120 lines (107 loc) · 4.11 KB
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
- name: Get info on docker host
community.docker.docker_host_info:
register: DOCKER_INFO
- name: Gather all devices for this server
block:
- set_fact:
ALLOWED_DEVICE_ID: []
- set_fact: ALLOWED_DEVICE_ID="{{ ALLOWED_DEVICE_ID|default([]) + (compute_devices[group_id]| default([])) }}"
with_items: "{{ compute_devices.keys() | list | default([]) }}"
loop_control: {loop_var: group_id}
- set_fact: ALLOWED_DEVICE_ID="{{ ALLOWED_DEVICE_ID|default([])| unique }}"
when: compute_devices is defined and compute_devices is not none
- set_fact:
DEVICE_REQUESTS:
driver: 'nvidia'
device_ids: "{{ ALLOWED_DEVICE_ID if compute_devices is defined else []}}"
count: "{{ 0 if compute_devices is defined else -1}}"
capabilities:
- ['gpu']
options: "{{ dict() }}"
## make sure to skip device_requests if Docker API does not support it (i.e. Docker server version above 19.03 is OK)
#when: "DOCKER_INFO.host_info['ServerVersion'] is version('19.03', '>=') and compute_devices is defined and compute_devices is not none"
- name: Deploy container for local Patroller node
community.docker.docker_container:
name: "claims"
state: "{{ 'started' if patroller_enabled|default(False)|bool else 'absent' }}"
image: "{{patroller_image_version}}"
env:
PATROLLER_USER_LABELS: "ccc-user.email"
PATROLLER_USER_INFO_LABELS: "ccc-user.name,ccc-user.mentor"
PATROLLER_LEASE: "{{patroller_lease|string}}"
labels:
frp.enabled: "true"
frp.80: "http"
frp.80.health_check: "false"
frp.80.http.subdomain: "{{ inventory_hostname }}-monitor"
frp.80.http.username: "{{ patroller_secure.user }}"
frp.80.http.password: "{{ patroller_secure.pass }}"
exposed_ports: 80
networks:
- name: "{{patroller_network}}"
aliases: ["claims", "reservation"]
- name: "bridge"
- name: "{{patroller_proxy_network}}"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
device_requests:
- "{{ DEVICE_REQUESTS | default(omit) }}"
pid_mode: host
privileged: True
purge_networks: yes
restart_policy: always
pull: yes
log_driver: json-file
log_options:
max-size: 10m
max-file: 5
compress: True
#- name: Setup config file for WebUI
# block:
# - name: Ensures /etc/patroller dir exists
# file: path=/etc/patroller state=directory
#
# - name: Write variables to json config file
# copy:
# content: "{{ patroller_webui_config | to_nice_json }}"
# dest: /etc/patroller/web-ui.json
# when: patroller_webui|default(False)|bool
- name: Setup storage folder for WebUI
block:
- name: Ensures storage folder exists
file: path="{{ patroller_webui_storage_path}}" state=directory
- name: Ensures parquete storage file exists
file: path="{{ patroller_webui_storage_path}}/occupancy_data.parquet" state=touch
- name: Write variables to json config file
copy:
content: "{{ patroller_webui_config | to_nice_json }}"
dest: "{{ patroller_webui_storage_path }}/web-ui.json"
when: patroller_webui|default(False)|bool
- name: Deploy container for WebUI Patroller node
docker_container:
name: "patroller-webui"
state: "{{ 'started' if patroller_webui|default(False)|bool else 'absent' }}"
image: "{{patroller_webui_image_version}}"
env:
STREAMLIT_SERVER_PORT: "80"
labels:
frp.enabled: "true"
frp.80: "http"
frp.80.health_check: "false"
frp.80.http.subdomain: "patroller"
frp.80.http.username: "{{ patroller_secure.user }}"
frp.80.http.password: "{{ patroller_secure.pass }}"
exposed_ports: 80
networks:
- name: "{{patroller_proxy_network}}"
volumes:
- "{{ patroller_webui_storage_path }}/occupancy_data.parquet:/code/occupancy_data.parquet"
- "{{ patroller_webui_storage_path }}/web-ui.json:/etc/patroller/web-ui.json"
purge_networks: yes
restart_policy: always
pull: yes
log_driver: json-file
log_options:
max-size: 10m
max-file: 5
compress: True