-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjustfile
More file actions
209 lines (178 loc) · 5.91 KB
/
justfile
File metadata and controls
209 lines (178 loc) · 5.91 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
# Lists all targets
[private]
default:
@just --list
# Run ansible-lint with the configured profile
[group('lint')]
ansible-lint:
@ansible-lint --offline
# Syncs the argocd application.
[group('argocd')]
argocd-argocd:
#!/usr/bin/env bash
set -eou pipefail
current_context=$(kubectl config view -o jsonpath='{.contexts[?(@.name == "default")].context.namespace}')
kubectl config set-context --current --namespace argocd
argocd --core app sync argocd --prune
kubectl config set-context --current --namespace ${current_context}
# Login to argocd cli.
[group('argocd')]
argocd-login:
#!/usr/bin/env bash
set -eou pipefail
argocd login argo-cd.hogs.tswn.us --sso --grpc-web --sso-launch-browser=false
# Syncs the traefik application.
[group('argocd')]
argocd-traefik:
#!/usr/bin/env bash
set -eou pipefail
current_context=$(kubectl config view -o jsonpath='{.contexts[?(@.name == "default")].context.namespace}')
kubectl config set-context --current --namespace argocd
argocd --core app sync traefik --prune
kubectl config set-context --current --namespace ${current_context}
# Builds the images/loki container for the Raspberry Pi.
[group('images')]
build-loki-image:
#!/usr/bin/env bash
set -eou pipefail
mkdir -p output-loki
# This must be built rootful...
sudo podman build \
images/loki \
--build-arg PARENT=ghcr.io/sdwilsh/mack:latest-arm64 \
--platform=linux/arm64 \
-t loki
# ...so it can be done rootful here.
sudo podman run \
--rm \
-it \
--privileged \
--pull=newer \
--security-opt label=type:unconfined_t \
-v ./config.toml:/config.toml:ro \
-v ./output-loki:/output \
-v /var/lib/containers/storage:/var/lib/containers/storage \
quay.io/centos-bootc/bootc-image-builder:latest \
--rootfs ext4 \
--target-arch=aarch64 \
--type raw \
localhost/loki:latest
sudo rm -rf output-loki/image/disk.raw.xz
sudo xz -z -k -v output-loki/image/disk.raw
echo "Complete! Now you can run this to install it:"
echo "sudo arm-image-installer \
--image=$(pwd)/output-loki/image/disk.raw.xz \
--target=rpi4 \
--resizefs \
--media=/dev/sdXXX"
# Builds the images/mack container.
[group('images')]
build-mack:
#!/usr/bin/env bash
set -eou pipefail
podman build \
images/mack \
-t mack
# Builds the images/mack container as a virtual machine.
[group('images')]
build-mack-vm:
#!/usr/bin/env bash
set -eou pipefail
mkdir -p output-mack
# This must be built rootful...
sudo podman build \
images/mack \
-t mack
# ...so it can be done rootful here.
sudo podman run \
--rm \
-it \
--privileged \
--pull=newer \
--security-opt label=type:unconfined_t \
-v ./config.toml:/config.toml:ro \
-v ./output-mack:/output \
-v /var/lib/containers/storage:/var/lib/containers/storage \
quay.io/centos-bootc/bootc-image-builder:latest \
--rootfs ext4 \
--type qcow2 \
localhost/mack:latest
# List decisions from crowdsec. Useful when debugging access problems.
[group('crowdsec')]
crowdsec-list-decisions:
kubectl exec -n crowdsec -it deployments/crowdsec-deployment -c crowdsec -- /usr/bin/env cscli decisions list
# Generates/updates resources for Argo CD applications
[group('codegen')]
generate-argo-cd-applications:
ansible-playbook plays/codegen/argo-cd-applications.yml --extra-vars overlay=prod
# Check `just` syntax
[group('just')]
justcheck:
#!/usr/bin/env bash
set -eou pipefail
find . -type f -name "justfile" -not -path "./external_*" | while read -r file; do
echo -n "Running \`just --fmt --check\` on ${file}..."
just --unstable --fmt --check -f ${file}
echo "{{ BOLD + GREEN }}OK{{ NORMAL }}"
done
# Fixes `just` syntax
[group('just')]
justfix:
#!/usr/bin/env bash
set -eou pipefail
find . -type f -name "justfile" -not -path "./external_*" | while read -r file; do
echo "Running \`just --fmt\` on ${file}..."
just --unstable --fmt -f ${file}
done
# Run `hadolint` on all `Dockerfile`s
[group('lint')]
hadolint:
#!/usr/bin/env bash
set -eou pipefail
find . -type f -name "Containerfile*" -not -path "./external_*" | while read -r file; do
echo -n "Running \`hadolint\` on ${file}..."
hadolint ${file}
echo "{{ BOLD + GREEN }}OK{{ NORMAL }}"
done
# Build production overlay with `kustomize`
[group('lint')]
kustomize-build:
#!/usr/bin/env bash
set -eou pipefail
find kustomization/overlays/prod -mindepth 1 -maxdepth 1 -type d | while read -r file; do
echo -n "Running \`kustomize build --enable-helm\` on ${file}..."
kustomize build --enable-helm ${file} > /dev/null
echo "{{ BOLD + GREEN }}OK{{ NORMAL }}"
done
# Validate `renovate.json` file
[group('lint')]
renovate-validate:
renovate-config-validator
# Runs the images/mack container in a virtual machine.
[group('images')]
run-mack: build-mack-vm
#!/usr/bin/env bash
set -eou pipefail
qemu-system-x86_64 \
-M accel=kvm \
-cpu host \
-smp 2 \
-m 4096 \
-bios /usr/share/OVMF/OVMF_CODE.fd \
-serial stdio \
-snapshot output-mack/qcow2/disk.qcow2
# Run `shellcheck` on all shell files
[group('lint')]
shellcheck:
#!/usr/bin/env bash
set -eou pipefail
find . -type f -name "*.sh" -not -path "./external_*" -not -path "*/charts/*" | while read -r file; do
echo -n "Running \`shellcheck -x\` on ${file}..."
shellcheck -x ${file}
echo "{{ BOLD + GREEN }}OK{{ NORMAL }}"
done
[group('longhorn')]
longhorn-allow-trim:
#!/usr/bin/env bash
set -eou pipefail
ansible localhost --module-name include_role --args name=marinatedconcrete.config.longhorn_allow_encrypted_trim