Implement a basic 'facts' system

This commit is contained in:
Andrew Dunham 2021-07-15 22:33:27 -04:00
parent a243a9a9c0
commit d77a87fb9e
2 changed files with 12 additions and 1 deletions

11
push
View file

@ -41,5 +41,16 @@ if scp -q -r "${APPLY_ROOT}"/{groups,units} run lib "$remote":"$tmp"; then
echo -e " \033[32mOK\033[0m" echo -e " \033[32mOK\033[0m"
fi fi
factfile="$APPLY_ROOT/facts/$remote"
if [[ -f "$factfile" ]]; then
if [[ -n "${vflag:-}" ]]; then
echo -e -n "\033[33m** pushing facts to\033[0m $remote:$tmp"
fi
if scp -q -r "$factfile" "$remote:$tmp/facts"; then
echo -e " \033[32mOK\033[0m"
fi
fi
# shellcheck disable=SC2029 # shellcheck disable=SC2029
ssh "$remote" "cd '$tmp' && ./run $vflag ${targets[*]} && cd; rm -rf '$tmp'" ssh "$remote" "cd '$tmp' && ./run $vflag ${targets[*]} && cd; rm -rf '$tmp'"

2
run
View file

@ -53,7 +53,7 @@ run_group() {
} }
run_unit() { run_unit() {
/bin/sh -l -c "set -e; set -u; set -o pipefail; . ./lib; . '$(root_path)/$*'" /bin/sh -l -c "set -e; set -u; set -o pipefail; . ./lib; test -f facts && . ./facts; . '$(root_path)/$*'"
} }
log_file() { log_file() {