-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
256 lines (226 loc) · 9.16 KB
/
Copy pathTaskfile.yaml
File metadata and controls
256 lines (226 loc) · 9.16 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# https://taskfile.dev/ - Task is a task runner / build tool that aims to be simpler and easier to use than, for example, GNU Make.
# [Say Goodbye to Makefile - Use Taskfile to Manage Tasks in CI/CD Pipelines and Locally](https://www.youtube.com/watch?v=Z7EnwBaJzCk)
# Installed via the `debian_tools` Ansible role.
version: '3'
includes:
ansible: ./ansible/Taskfile.ansible.yaml
docker: ./docker/Taskfile.docker.yaml
app: ./docker/Taskfile.apps.yaml
crowdsec: ./docker/Taskfile.crowdsec.yaml
obsidian: ./docker/Taskfile.obsidian.yaml
docs: ./docs/web/Taskfile.web.yaml
devcontainer: ./.devcontainer/Taskfile.dev.yaml
azure-vm:
taskfile: ./terraform/azure-vm/Taskfile.yaml
dir: ./terraform/azure-vm
aws-vm:
taskfile: ./terraform/aws-vm/Taskfile.yaml
dir: ./terraform/aws-vm
tasks:
default:
desc: List all tasks
cmds:
- task --list-all
# TaskUI is a lightweight terminal user interface for executing tasks defined using taskfile.dev.
# https://github.com/thmshmm/taskui
ui:
desc: Open terminal user interface for executing tasks (TaskUI)
env:
TASKUI_HIGHLIGHT_STYLE_BG: "#00cc66"
TASKUI_HIGHLIGHT_STYLE_FG: "#4c4f69"
cmds:
- taskui
### Development-related tasks
# See https://pre-commit.com for more information
lint:
desc: Run linting tools on all files (via pre-commit)
cmds:
- pre-commit run --all-files
lint-app:
desc: Run linting tools on all files skipping infrastructure-related checks
env:
SKIP: "renovate-config-validator,terraform_fmt,terraform_docs,terraform_validate,terraform_tflint,ansible-lint,kics-scan"
cmds:
- pre-commit run --all-files
git-rebase-fixup:
desc: Interactively rebase current branch to origin/main (stash, rebase, pop)
aliases: [rebase]
cmds:
- scripts/git-rebase-to-main.sh
build:
desc: Run all linting and build tasks
cmds:
- task: lint
- task: docker:update-example-env
- task: docs:build
prepare-to-push:
desc: Prepare branch for push - lint, build, rebase
aliases: [prep]
cmds:
- clear
- task: build
- task: git-rebase-fixup
update-pre-commit:
desc: Update pre-commit repositories
cmds:
- pre-commit autoupdate
renovate:
desc: Run Renovatebot locally
cmds:
- docker run --rm -v .:/usr/src/app -e LOG_LEVEL=debug renovate/renovate --platform local
clean:
desc: Clear generated files and cache data
cmds:
- task: docs:clean
- task: azure-vm:clean
- task: aws-vm:clean
- task: clean-venvs
clean-venvs:
desc: Remove Python virtual environments (.venv directories)
cmds:
- find . -type d -name '.venv' -exec rm -rf {} +
btrfs-compsize:
desc: Show btrfs compression statistics
silent: true
cmds:
- |
if ! command -v compsize >/dev/null 2>&1; then
echo "Error: compsize is not installed. Please install it first."
exit 1
fi
if ! findmnt -n -o FSTYPE / | grep -q "btrfs"; then
echo "Error: Root filesystem is not btrfs"
exit 1
fi
echo "Analyzing btrfs compression stats (this may take a while)..."
sudo compsize -x /
star-github-repos:
desc: Add star to all GitHub repositories referenced in documentation/configuration
dotenv:
- "config/docker/.env"
preconditions:
- sh: "[ ! -z \"${GITHUB_API_TOKEN}\" ]"
msg: GITHUB_API_TOKEN environment variable must be set (exported)
cmds:
- scripts/github-extract-links.py . | sort | uniq | scripts/github-star-repo.py
### Operations-related tasks
docker-command:
internal: true
cmds:
- scripts/labctl.py service {{.COMMAND}} {{.SERVICE}}
get-public-ip:
desc: Display the public IP of the server (using ipinfo.io)
cmds:
- curl -s https://ipinfo.io/ip
versions:
desc: Show version numbers of the installed software
cmds:
- lsb_release -a
- uname -a
- 'ansible --version || echo "ansible: not installed"'
- 'terraform --version || echo "terraform: not installed"'
- 'docker --version || echo "docker: not installed"'
backup-config:
desc: Create a compressed backup of the configuration directory
cmds:
- mkdir -p ../infra-config-backup
- cd config && tar -cjf "../../infra-config-backup/infra-config-$(date +%Y-%m-%d_%H-%M-%S).tar.bz2" --exclude=.git .
- echo "Recent backups:"
- ls -lh ../infra-config-backup/infra-config-*.tar.bz2 | tail -n 5
# Remove old backups (they are still kept in the repository - see the push-config-repo task)
- ls -t ../infra-config-backup/infra-config-*.tar.bz2 | tail -n +31 | xargs -r rm
push-config-repo:
desc: Commit and push changes in the config git repository
silent: true
cmds:
- |
CONFIG_PATH="config"
cd "${CONFIG_PATH}" || { echo "Failed to cd to '${CONFIG_PATH}'"; exit 1; }
if [ ! -d ".git" ]; then
echo "Error: .git folder not found in '${CONFIG_PATH}'"
exit 1
fi
git add --all
if git diff --cached --quiet; then
echo "No changes to commit."
else
git commit -m "Automatic sync"
fi
if ! git remote get-url origin 2>/dev/null; then
echo "No remote origin URL is configured. Skipping push."
else
echo "$(git remote get-url origin)"
git pull --rebase --autostash
git push
fi
# Run `task setup-crontab` to install the cron schedule automatically.
backup:
desc: Create backup of the configuration directory and the Obsidian vault
silent: true
cmds:
- echo "=== Backup started at $(date) ==="
- task: backup-config
- task: push-config-repo
- task: obsidian:backup-vault-repo
- |
if [ -f "config/sync-backup-to-remote.sh" ]; then
bash "config/sync-backup-to-remote.sh"
fi
setup-crontab:
desc: Install or update the daily backup cron job
cmds:
- |
MARKER="# managed:infra-backup"
CRON_ENTRY="0 1 * * * cd \"$(pwd)\" && PATH=\"/home/linuxbrew/.linuxbrew/bin:$HOME/.local/bin:\$PATH\" task backup >> $HOME/infra-backup.log 2>&1 $MARKER"
(crontab -l 2>/dev/null | grep -vF "$MARKER"; echo "$CRON_ENTRY") | crontab -
echo "Crontab entry installed/updated."
get-offline-data:
desc: Download data files for offline use (stored both local and on Proxmox)
cmds:
- task: get-offline-data-ollama
- task: get-offline-data-kiwix
- task: get-offline-data-proxmox
get-offline-data-ollama:
desc: Pull Ollama LLM and embedding models into the running Ollama container
cmds:
- docker ps --filter name=^ollama$ --filter status=running --quiet | grep -q . || { echo "Error - Ollama container is not running" >&2; exit 1; }
# Large Language Models - https://ollama.com/search
- docker exec ollama ollama pull phi4-mini # 3.8B - best-in-class sub-4B; 128K ctx
- docker exec ollama ollama pull qwen3:8b # 8B - best-in-class 7-8B; hybrid thinking, top HumanEval
# Embedding Models - https://ollama.com/search?c=embedding
- docker exec ollama ollama pull nomic-embed-text
- docker exec ollama ollama list
get-offline-data-kiwix:
desc: Download Kiwix ZIM files and apps for offline use
dotenv:
- "config/docker/.env"
- "config/docker/localhost/.env"
cmds:
# Browse library: https://lb.download.kiwix.org/zim/
- |
scripts/get-offline-data-file.sh $STORAGE_KIWIX "https://download.kiwix.org/zim/wikipedia/" "wikipedia_hu_all_nopic_[0-9]{4}-[0-9]{2}\.zim"
scripts/get-offline-data-file.sh $STORAGE_KIWIX "https://download.kiwix.org/zim/wikipedia/" "wikipedia_hu_top_maxi_[0-9]{4}-[0-9]{2}\.zim"
scripts/get-offline-data-file.sh $STORAGE_KIWIX "https://download.kiwix.org/zim/wikipedia/" "wikipedia_en_top_maxi_[0-9]{4}-[0-9]{2}\.zim"
scripts/get-offline-data-file.sh $STORAGE_KIWIX "https://download.kiwix.org/zim/other/" "zimgit-post-disaster_en_[0-9]{4}-[0-9]{2}\.zim"
scripts/get-offline-data-file.sh $STORAGE_KIWIX "https://download.kiwix.org/zim/zimit/" "www.ready.gov_en_[0-9]{4}-[0-9]{2}\.zim"
- ls -lh $STORAGE_KIWIX
- |
mkdir -p $STORAGE_KIWIX/app
scripts/get-offline-data-file.sh $STORAGE_KIWIX/app "https://download.kiwix.org/release/kiwix-android/" "kiwix-[0-9]+\.[0-9]+\.[0-9]+\.apk"
scripts/get-offline-data-file.sh $STORAGE_KIWIX/app "https://download.kiwix.org/release/kiwix-desktop/" "kiwix-desktop_windows_x64_[0-9]+\.[0-9]+\.[0-9]+\.zip"
- ls -lh $STORAGE_KIWIX/app
get-offline-data-proxmox:
desc: Download data files for offline use (files stored on proxmox host)
env:
PROXMOX: "root@proxmox"
cmds:
- rsync -a vm/ ${PROXMOX}:/tmp/vm/
- ssh ${PROXMOX} bash /tmp/vm/proxmox/create-openwrt-vm.sh --download-only
- ssh ${PROXMOX} bash /tmp/vm/proxmox/create-ubuntu-server-vm.sh --download-only
- ssh ${PROXMOX} bash /tmp/vm/proxmox/create-ubuntu-cloud-vm.sh --download-only
# TODO Add Proxmox ISO
# TODO Add Linux Mint ISO
show-remote-mounts:
desc: Display mounted SMB network shares
cmds:
- findmnt -t cifs