From 560742893136b209f76a3080fae0ef2ccd86ab06 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Wed, 24 Apr 2024 20:27:29 -0500 Subject: [PATCH] Craigs-MacBook-Pro.local --- setup.sh | 34 +++++++++++++++++++++++++++++----- simple/inventory.sh | 1 + 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/setup.sh b/setup.sh index f854a03..d8e82da 100755 --- a/setup.sh +++ b/setup.sh @@ -1,20 +1,27 @@ #!/usr/bin/env bash set -ex +function wait +{ + set +x + echo -n "$@" + read -r _r + set -x +} vm up vm ssh-config -# setup cf-remote names +wait "setup cf-remote names..." cf-remote destroy --all # start over each time cf-remote save --role hub --name server --hosts vagrant@ubuntu-20 cf-remote save --role hub --name hub --hosts vagrant@ubuntu-22 cf-remote save --role clients --name clients --hosts vagrant@debian-10,vagrant@centos-7 cf-remote save --role clients --name all --hosts vagrant@ubuntu-20,vagrant@ubuntu-22,vagrant@debian-10,vagrant@centos-7 -# uninstall +wait "uninstall..." cf-remote uninstall -H all -# install community, bootstrap +wait "install community, bootstrap..." cf-remote sudo -H server "apt install -y python3-pip; pip3 install cfbs" cf-remote install --edition community --clients server --bootstrap 192.168.56.20 cf-remote sudo -H server "curl --silent https://raw.githubusercontent.com/cfengine/core/master/contrib/masterfiles-stage/install-masterfiles-stage.sh --remote-name" @@ -28,7 +35,7 @@ cf-remote sudo -H server "cp /home/vagrant/cfe /usr/bin/cfe; chmod +x /usr/bin/c cf-remote sudo -H server cfe cf-remote install --edition community --clients clients --bootstrap 192.168.56.20 -# play around for a bit, setup the secret with cf-secret +wait "play around for a bit, setup the secret with cf-secret. press enter to pull, commit and push the secret to the repo..." # cf-secret encrypt -H 192.168.56.10,192.168.56.7,192.168.56.20 -o /home/vagrant/secret.dat - ssh ubuntu-20 sudo chown vagrant /home/vagrant/secret.dat scp ubuntu-20:secret.dat simple/ @@ -36,5 +43,22 @@ git add simple/secret.dat git commit -m 'updated secret' git push -cf-remote sudo -H server,clients cfe +cf-remote sudo -H server,clients "/var/cfengine/bin/cf-agent -K" +wait "install enterprise hub on ubuntu-22..." +cf-remote install --hub hub --bootstrap 192.168.56.22 + +wait "login to mission portal and setup VCS..." +cf-remote scp -H hub cfe +cf-remote sudo -H hub "cp /home/vagrant/cfe /usr/bin/cfe; chmod +x /usr/bin/cfe" +cf-remote sudo -H hub cfe + +wait "upgrade debian-10 to enterprise..." +cf-remote uninstall -H debian-10 +cf-remote install --clients debian-10 --bootstrap 192.168.56.22 +cf-remote sudo -H debian-10 cfe + +wait "upgrade centos-7 to enterprise and rebootstrap..." +cf-remote uninstall -H centos-7 +cf-remote install --clients centos-7 --bootstrap 192.168.56.7 +cf-remote sudo -H centos-7 cfe diff --git a/simple/inventory.sh b/simple/inventory.sh index 63594e3..11a2876 100755 --- a/simple/inventory.sh +++ b/simple/inventory.sh @@ -4,6 +4,7 @@ for client_ip in $(cf-key -s | grep Incoming | awk '{print $2}'); do for dir in $(cf-net -H $client_ip opendir /var/cfengine/data | grep -v '^\.'); do for file in $(cf-net -H $client_ip opendir /var/cfengine/data/$dir | grep -v '^\.'); do mkdir -p /var/cfengine/data/$dir + cd /var/cfengine/data/$dir cf-net -H $client_ip get /var/cfengine/data/$dir/$file done done