Docs-as-code: full deploy configs, compose stacks, and DR guide
- Add root README and docs/ (architecture, hosts, disaster-recovery, operations) - Add compose/ for superset, forgejo, lam, cadvisor; unified deploy compose - Add scripts/deploy (deploy-atc-docker01.sh, container inventory export) - Add inventory/containers-atc-docker01.json snapshot - Add config READMEs for kafka and airflow; .env.example; expand .gitignore - Sync atclab helper scripts; update homepage/superset compose with env support
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
# atclab scripts (referentie)
|
||||
|
||||
Kopie van `/opt/atclab/bin/` op lab hosts — handige wrappers voor yum/git/syslog.
|
||||
|
||||
| Script | Functie |
|
||||
|--------|---------|
|
||||
| `atclab-update` | yum update van atclab repo |
|
||||
| `gitcommit` | `git commit -m "$@"` shortcut |
|
||||
| `gittag` | git tagging helper |
|
||||
| `syslog` / `syslogf` | syslog viewers |
|
||||
|
||||
Deze scripts zijn host-specifiek; pas aan per omgeving.
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/bash
|
||||
#yum makecache
|
||||
|
||||
yum --disablerepo="*" --enablerepo="atclab" clean all && yum --disablerepo="*" --enablerepo="atclab" -y update
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
desc="$@"
|
||||
|
||||
git commit -m "$desc"
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
DIR=$(git rev-parse --show-toplevel) || exit 10
|
||||
NAME=$(rpm -q --qf '%{name}\n' --specfile ${DIR}/*.spec)
|
||||
VERSION=$(rpm -q --qf '%{version}\n' --specfile ${DIR}/*.spec)
|
||||
|
||||
|
||||
while getopts ":h:" OPT; do
|
||||
case "$OPT" in
|
||||
\?|h) usage ; exit 0 ;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
|
||||
case $1 in
|
||||
apply) git tag -a -mversion v${VERSION} ;;
|
||||
*) echo git tag -a -mversion v${VERSION} ;;
|
||||
esac
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
DEL=""
|
||||
|
||||
deletehost() {
|
||||
local host ip
|
||||
host=$(echo $1 | awk -F@ '{print $NF}')
|
||||
ip=$(host $host | awk '/has address/ {print $NF}' | head -1)
|
||||
ssh-keygen -R $host
|
||||
test -n "$ip" && ssh-keygen -R $ip
|
||||
}
|
||||
|
||||
while getopts ":dh" OPT; do
|
||||
case "$OPT" in
|
||||
d) DEL=Y ;;
|
||||
\?|h) usage >&2 ; exit 0 ;;
|
||||
esac
|
||||
done
|
||||
shift $(expr $OPTIND - 1)
|
||||
|
||||
test -n "$DEL" && deletehost $@
|
||||
|
||||
ssh root@${1:-none}
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
test -f /var/log/messages && tail -n100 /var/log/messages
|
||||
test -f /var/log/syslog && tail -n100 /var/log/syslog
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
test -f /var/log/messages && tail -n100 -f /var/log/messages
|
||||
test -f /var/log/syslog && tail -n100 -f /var/log/syslog
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
if [[ -f .env ]]; then
|
||||
set -a
|
||||
# shellcheck source=/dev/null
|
||||
source .env
|
||||
set +a
|
||||
fi
|
||||
|
||||
echo "==> Homepage + RSS + icons"
|
||||
docker compose -f deploy/docker-compose.homepage.yml up -d --build
|
||||
|
||||
echo "==> Superset + Redis"
|
||||
docker compose -f compose/superset/docker-compose.yaml up -d --build
|
||||
|
||||
echo "==> Forgejo (lokaal)"
|
||||
docker compose -f compose/forgejo/compose.yaml up -d
|
||||
|
||||
echo "==> LAM (lokaal)"
|
||||
docker compose -f compose/lam/compose.yml up -d
|
||||
|
||||
echo "==> Revalidate homepage"
|
||||
docker exec homepage wget -qO- http://127.0.0.1:3000/api/revalidate 2>/dev/null || true
|
||||
|
||||
echo "Done. Open http://atc-docker01.dell-atc.lan/"
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
SKIP_ENV_PREFIXES = (
|
||||
"PATH=", "NODE_", "PYTHON_", "GPG_", "LANG=", "YARN=", "HOSTNAME=",
|
||||
"NGINX_", "NJS_", "ACME_", "DYNPKG_", "PKG_", "CADVISOR_",
|
||||
)
|
||||
|
||||
ids = subprocess.check_output(["docker", "ps", "-aq"], text=True).split()
|
||||
if not ids or ids == [""]:
|
||||
raise SystemExit("no containers")
|
||||
|
||||
raw = subprocess.check_output(["docker", "inspect", *ids])
|
||||
data = json.loads(raw)
|
||||
out = []
|
||||
for c in data:
|
||||
env = [
|
||||
e for e in (c["Config"].get("Env") or [])
|
||||
if not any(e.startswith(p) for p in SKIP_ENV_PREFIXES)
|
||||
]
|
||||
out.append({
|
||||
"name": c["Name"].lstrip("/"),
|
||||
"image": c["Config"]["Image"],
|
||||
"ports": c["NetworkSettings"]["Ports"],
|
||||
"restart": c["HostConfig"]["RestartPolicy"]["Name"],
|
||||
"binds": c["HostConfig"].get("Binds") or [],
|
||||
"volumes": [
|
||||
{"name": m["Name"], "dest": m["Destination"]}
|
||||
for m in c["Mounts"]
|
||||
if m.get("Type") == "volume"
|
||||
],
|
||||
"env": env,
|
||||
})
|
||||
|
||||
with open("/root/lakehouse/inventory/containers-atc-docker01.json", "w") as f:
|
||||
json.dump(out, f, indent=2)
|
||||
print("wrote", len(out), "containers")
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
OUT="$ROOT/inventory/containers-atc-docker01.json"
|
||||
|
||||
python3 "$ROOT/scripts/deploy/export-inventory.py" "$OUT"
|
||||
echo "Wrote $OUT"
|
||||
Reference in New Issue
Block a user