-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathopsfile.yml
More file actions
219 lines (207 loc) · 7.34 KB
/
opsfile.yml
File metadata and controls
219 lines (207 loc) · 7.34 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
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
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
version: '3'
vars:
D: ""
RUN: '{{if eq .D ""}}{{else}}echo{{end}}'
CAT: '{{if eq .D ""}}true{{else}}cat{{end}}'
OS: '{{OS}}'
ARCH: '{{ARCH}}'
tasks:
check-ports:
desc: "Check if an array of TCP/UDP ports is free and fail if any are in use"
silent: true
vars:
PORTS: "{{ .PORTS | default \"\" }}"
cmds:
- |
{{if eq OS "windows"}}
$ports = "{{ .PORTS }}".Split(" ")
foreach ($entry in $ports) {
$parts = $entry -split "/"
$port = $parts[0]
$protocol = $parts[1].ToLower()
if ($protocol -eq "tcp" -and (Get-NetTCPConnection -LocalPort $port -ErrorAction SilentlyContinue)) {
Write-Host "TCP Port $port is in use!" -ForegroundColor Red
exit 1
}
if ($protocol -eq "udp" -and (Get-NetUDPEndpoint -LocalPort $port -ErrorAction SilentlyContinue)) {
Write-Host "UDP Port $port is in use!" -ForegroundColor Red
exit 1
}
}
{{else if eq OS "darwin"}}
for entry in {{ .PORTS }}; do
port="${entry%/*}"
protocol="${entry#*/}"
if [[ "$protocol" == "tcp" ]] && lsof -i TCP:$port -sTCP:LISTEN -t > /dev/null 2>&1; then
echo "TCP Port $port is in use!" >&2
exit 1
fi
if [[ "$protocol" == "udp" ]] && lsof -i UDP:$port -t > /dev/null 2>&1; then
echo "UDP Port $port is in use!" >&2
exit 1
fi
done
{{else}}
for entry in {{ .PORTS }}; do
port="${entry%/*}"
protocol="${entry#*/}"
if [[ "$protocol" == "tcp" ]] && ss -tuln | rg -q ":(^| )$port "; then
echo "TCP Port $port is in use!" >&2
exit 1
fi
if [[ "$protocol" == "udp" ]] && ss -uln | rg -q ":(^| )$port "; then
echo "UDP Port $port is in use!" >&2
exit 1
fi
done
{{end}}
prereq:
silent: true
cmds:
- exit 0
mini:
silent: false
desc: install miniops
cmds:
- docker -v || die "Docker is not installed. Please install Docker Desktop first."
- docker info 2>/dev/null >/dev/null || die "Docker is not running. Please start Docker Desktop first."
- |
if test -z {{.__skip_check_cluster}}
then
if curl -sL http://miniops.me >/dev/null 2>/dev/null
then
if curl -sL http://miniops.me/api/info 2>/dev/null | jq -r .description | rg OpenWhisk >/dev/null 2>/dev/null
then
echo "*** Apache OpenServerless mini is already installed."
echo "*** Login with: ops ide login devel http://miniops.me"
echo "*** You can find the password in .ops/devel.password in your home directory"
echo "*** You can can uninstall and restart with: ops setup docker delete"
exit 1
else
if ! kind get clusters | rg nuvolaris
then echo "*** Something is already running as a local webserver, please remove it before installing miniops."
exit 1
fi
fi
fi
fi
- $OPS setup docker check-space
- $OPS config slim
- $OPS config apihost miniops.me --protocol=http
- $OPS setup devcluster
- $OPS setup nuvolaris streamer deploy
- $OPS setup nuvolaris add-user
devcluster:
vars:
PORTS: '9010/tcp 9080/tcp 30379/tcp 32817/tcp 3232/tcp 3233/tcp 9644/tcp 7896/tcp 5984/tcp 9092/tcp 9000/tcp 9090/tcp 19530/tcp 9091/tcp, 27017/tcp 80/tcp 443/tcp 57817/tcp'
silent: false
cmds:
- |
if {{.__status}}
then {{.RUN}} $OPS setup docker status
elif {{.__uninstall}}
then {{.RUN}} $OPS setup docker delete
else
# to be verified
#if test -z {{.__skip_check_ports}}
#then $OPS setup check-ports PORTS="{{ .PORTS }}"
#fi
{{.RUN}} $OPS setup docker create
if test -z {{.__skip_preload_images}}
then
{{.RUN}} $OPS setup docker preload
fi
{{.RUN}} $OPS setup kubernetes create
{{.RUN}} $OPS setup nuvolaris login
config STATUS_LAST=devcluster
fi
cluster:
silent: true
cmds:
- |
if {{.__status}}
then {{.RUN}} $OPS setup kubernetes status CONTEXT="{{._context_}}"
elif {{.__uninstall}}
then {{.RUN}} $OPS setup kubernetes delete CONTEXT="{{._context_}}"
else
{{.RUN}} $OPS setup kubernetes create CONTEXT="{{._context_}}"
{{.RUN}} $OPS setup nuvolaris login
config STATUS_LAST=cluster
if test -n "{{._context_}}"
then config STATUS_CONTEXT="{{._context_}}"
fi
fi
server:
silent: true
cmds:
- |
if {{.__status}}
then {{.RUN}} $OPS cloud k3s status {{._server_}} {{._user_}}
elif {{.__uninstall}}
then {{.RUN}} $OPS cloud k3s delete {{._server_}} {{._user_}}
else
{{.RUN}} $OPS cloud k3s create {{._server_}} {{._user_}}
{{.RUN}} $OPS setup kubernetes create
{{.RUN}} $OPS setup nuvolaris login
config STATUS_LAST=server STATUS_SERVER="{{._server_}}"
if test -n "{{._user_}}"
then config STATUS_USERNAME="{{._user_}}"
fi
fi
status:
silent: true
cmds:
- |
case "$STATUS_LAST" in
(devcluster) {{.RUN}} $OPS setup devcluster --status ;;
(cluster) {{.RUN}} $OPS setup cluster "$STATUS_CONTEXT" --status ;;
(server) {{.RUN}} $OPS setup server "$STATUS_SERVER" "$STATUS_USERNAME" --status ;;
(*) echo nothing installed yet
esac
uninstall:
silent: true
cmds:
- |
case "$STATUS_LAST" in
(devcluster)
{{.RUN}} $OPS setup devcluster --uninstall
config -r STATUS_LAST
;;
(cluster)
if test -n "$STATUS_CONTEXT"
then
{{.RUN}} $OPS setup cluster "$STATUS_CONTEXT" --uninstall
config -r STATUS_CONTEXT
else
{{.RUN}} $OPS setup cluster --uninstall
fi
config -r STATUS_LAST
;;
(server)
if test -z "$STATUS_USERNAME"
then
{{.RUN}} $OPS setup server "$STATUS_SERVER" --uninstall
else
{{.RUN}} $OPS setup server "$STATUS_SERVER" "$STATUS_USERNAME" --uninstall
config -r STATUS_USERNAME
fi
config -r STATUS_LAST STATUS_SERVER
;;
(*) echo nothing installed yet
esac