Move vyos config to its own directory, build workflow tools for deploying configs, encrypt entire vyos config file until a better approach can be built

This commit is contained in:
Joey Hafner 2024-10-09 15:49:33 -07:00
parent 8f578aed76
commit 152403cc55
No known key found for this signature in database
6 changed files with 129 additions and 1 deletions

1
.gitattributes vendored
View File

@ -2,3 +2,4 @@ secrets.env filter=sops diff=sops
*.secrets filter=sops diff=sops
*.token filter=sops diff=sops
*.passwd filter=sops diff=sops
config.boot filter=sops diff=sops

58
homelab/vyos/config.boot Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,5 @@
#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
show

View File

@ -0,0 +1,9 @@
#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
configure
load /home/vyos/config.boot
echo "Running commit && exit"
commit && exit || exit discard

View File

@ -0,0 +1,8 @@
#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
configure
save || exit discard

47
homelab/vyos/vyos.sh Executable file
View File

@ -0,0 +1,47 @@
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# Returns saved config file
function get_config_saved () {
ssh vyos@192.168.1.1 'cat /config/config.boot'
}
# Returns active config file
function get_config_active () {
scp -q ./get_config.sh vyos@192.168.1.1:/home/vyos/get_config.sh
ssh vyos@192.168.1.1 'chmod +x /home/vyos/get_config.sh; /home/vyos/get_config.sh; rm /home/vyos/get_config.sh'
}
# Push local ./config.boot to remote /home/vyos/config.boot
function post_config () {
scp -q ./config.boot vyos@192.168.1.1:/home/vyos/config.boot
}
function load_config () {
scp -q ./load_config.sh vyos@192.168.1.1:/home/vyos/load_config.sh
ssh vyos@192.168.1.1 'chmod +x /home/vyos/load_config.sh; /home/vyos/load_config.sh; rm /home/vyos/load_config.sh'
}
function save_config () {
scp -q ./save_config.sh vyos@192.168.1.1:/home/vyos/save_config.sh
ssh vyos@192.168.1.1 'chmod +x /home/vyos/save_config.sh; /home/vyos/save_config.sh; rm /home/vyos/save_config.sh'
}
function pull () {
get_config_saved > config.boot
}
function push () {
post_config
load_config
save_config
}
function edit () {
get_config_saved > $SCRIPT_DIR/config.boot
vim $SCRIPT_DIR/config.boot
push
}
"$1"