feature: added ip-gather command for improved workflow
All checks were successful
/ check (push) Successful in 1m3s
/ deploy (push) Has been skipped

This commit is contained in:
Jermeiah S 2025-06-22 17:15:45 -04:00
parent 5b91c9f3f5
commit 2802db394f
No known key found for this signature in database
3 changed files with 50 additions and 1 deletions

7
container_ips.json Normal file
View file

@ -0,0 +1,7 @@
{
"arma-reforger-tofu": "201:61dd:8232:55d9:f6ee:2594:d661:b202",
"base-tofu": "200:d642:9eee:8f38:d9f3:8272:817d:75da",
"forgejo-runner-tofu": "201:ea26:66c7:657b:3599:63a6:c66c:d388",
"observer-tofu": "200:b938:d405:92df:a6e:1ffd:5213:26b",
"tofu": "200:1978:6503:e6f0:2dbe:11fd:74b:ff64"
}

View file

@ -1,11 +1,17 @@
{
perSystem =
{ pkgs, ... }:
{
self',
pkgs,
system,
...
}:
{
devShells.default = pkgs.mkShell {
name = "nixos-unified-template-shell";
meta.description = "Shell environment for modifying this Nix configuration";
packages = with pkgs; [
self'.packages.ip-gather
openssh
deploy-rs
ssh-to-age

View file

@ -0,0 +1,36 @@
# incus-ip-collector.nix
{
writeShellScriptBin,
}:
writeShellScriptBin "ip-gather" ''
set -euo pipefail
remote_host="''${1:-"administrator@olympus"}"
output_file="''${2:-container_ips.json}"
generate_json() {
echo "{"
first=true
for c in $(incus list --format csv -c n | awk '!/NAME/ {print $1}'); do
ip=$(incus exec "$c" -- ip -6 addr show dev ygg0 2>/dev/null | awk '/inet6/ {print $2}' | cut -d/ -f1 | grep -v '^fe80' | head -n1)
if [ -n "$ip" ]; then
[ "$first" = false ] && echo ","
echo -n " \"$c\": \"$ip\""
first=false
fi
done
echo ""
echo "}"
}
if [ -n "''${remote_host}" ]; then
# Execute remotely and save to local file
ssh "$remote_host" "$(declare -f generate_json); generate_json" > "$output_file"
else
# Execute locally and save to file
generate_json > "$output_file"
fi
echo "Container IPs saved to: $output_file"
''