From 68248df359020b4fc42780cf2d75aa1e04c7c3a1 Mon Sep 17 00:00:00 2001 From: Jonas Forsberg Date: Wed, 22 Sep 2021 12:30:23 +0200 Subject: [PATCH] changed to parse yaml for network --- .gitignore | 1 - network.env.example | 3 --- salt/pillars/network.sls | 3 ++- update.sh | 43 ++++++++++++++++++++++++++++++---------- 4 files changed, 34 insertions(+), 16 deletions(-) delete mode 100644 network.env.example diff --git a/.gitignore b/.gitignore index ae123e9..9cef971 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -network.env salt/pillars/local.sls diff --git a/network.env.example b/network.env.example deleted file mode 100644 index 4b5ccb1..0000000 --- a/network.env.example +++ /dev/null @@ -1,3 +0,0 @@ -INTERNAL_IF="eth0" -INTERNAL_ADDRESS="192.168.0.1/24" -EXTERNAL_IF="eth0.1000" diff --git a/salt/pillars/network.sls b/salt/pillars/network.sls index db4f0c5..7fd51c9 100644 --- a/salt/pillars/network.sls +++ b/salt/pillars/network.sls @@ -1,7 +1,8 @@ network: domain: suse.lan - address: 192.168.0.0 + netaddress: 192.168.0.0 netmask: 24 + ip: 192.168.0.1 interface: internal: eth0 diff --git a/update.sh b/update.sh index c5f2b43..09578cb 100755 --- a/update.sh +++ b/update.sh @@ -40,6 +40,24 @@ function log(){ printf "%s\n" "$*" } +function parse_yaml { + local prefix=$2 + local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034') + sed -ne "s|^\($s\):|\1|" \ + -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \ + -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 | + awk -F$fs '{ + indent = length($1)/2; + vname[indent] = $2; + for (i in vname) {if (i > indent) {delete vname[i]}} + if (length($3) > 0) { + vn=""; for (i=0; i