Compare commits

...

3 commits

3 changed files with 42 additions and 4 deletions

View file

@ -1,3 +1,3 @@
# novos # Raclette
A wrapper-script for ansible-playbook A wrapper-script for ansible-playbook

View file

@ -7,6 +7,7 @@ function config_help() {
$(basename ${0}) config <command> [...] $(basename ${0}) config <command> [...]
commands: commands:
$(basename ${0}) config help $(basename ${0}) config help
$(basename ${0}) config configure
$(basename ${0}) config pull $(basename ${0}) config pull
$(basename ${0}) config full $(basename ${0}) config full
$(basename ${0}) config single [playbook] $(basename ${0}) config single [playbook]
@ -45,3 +46,40 @@ function config_single() {
fi fi
ansible-playbook $([[ $debuglevel -eq 4 ]] && echo '-v') $([[ $dryrun -eq 1 ]] && echo '-C') -D "$newpath" ansible-playbook $([[ $debuglevel -eq 4 ]] && echo '-v') $([[ $dryrun -eq 1 ]] && echo '-C') -D "$newpath"
} }
function config_configure() {
# Check if serverspecific.ansible.yml exists, if not: create
if [[ ! -f "$CONFIG_ROOT/serverspecific.ansible.yml" ]]; then
touch "$CONFIG_ROOT/serverspecific.ansible.yml"
fi
# Check if 'serverspecific' is inside top.ansible.yml, if not: append
if [[ -z $(grep "serverspecific" "$CONFIG_ROOT/top.ansible.yml") ]]; then
echo "- import_playbook: serverspecific.ansible.yml" >> "$CONFIG_ROOT/top.ansible.yml"
fi
available_playbooks=($(find "$CONFIG_ROOT" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | grep -vE "^\.[a-z]+"))
available_playbooks+=($(find "$CONFIG_ROOT" -mindepth 1 -maxdepth 1 -type f -exec basename {} \; | grep -vE "^\.[a-z]+" | grep -v "top.*" | grep -v "map." | grep -v "serverspecific."))
top_content=($(cat "$CONFIG_ROOT/top.ansible.yml" | cut -d: -f2 | cut -d/ -f1 | awk '{$1=$1};1'))
echo "${available_playbooks[@]}"
for top_item in ${top_content[@]}; do
available_playbooks=( $(echo "${available_playbooks[@]/$top_item}" | awk '{$1=$1};1') )
done
echo "${available_playbooks[@]}"
local dialog_string
for playbook in "${available_playbooks[@]}"; do
[[ $(grep "$playbook" "$CONFIG_ROOT/serverspecific.ansible.yml") ]] && playbook="$playbook:on" || playbook="$playbook:off"
echo "$playbook"
dialog_string="${dialog_string} $(echo $playbook | cut -d: -f1) .. $(echo $playbook | cut -d: -f2)"
done
selected=($(dialog --output-fd 1 --clear --title "Select additional playbooks to apply" --checklist "available playbooks" 10 70 3 $dialog_string))
if [[ -n "${selected[@]}" ]]; then
rm -f "$CONFIG_ROOT/serverspecific.ansible.yml"
for sel in "${selected[@]}"; do
echo "- import_playbook: $sel/init.ansible.yml" >> "$CONFIG_ROOT/serverspecific.ansible.yml"
done
fi
}

View file

@ -4,7 +4,7 @@
readonly PKGVER="0.0.1" readonly PKGVER="0.0.1"
readonly LICENSE="GNU AGPLv3" readonly LICENSE="GNU AGPLv3"
readonly ROOTPATH="$(dirname $(readlink -f $(which ${0})))" readonly ROOTPATH="$(dirname $(readlink -f $(which ${0})))"
readonly CONFIG="/usr/local/noveria/etc/novos/novos.json" readonly CONFIG="/usr/local/noveria/etc/raclette/config.json"
for util in ${ROOTPATH}/functions/*; do for util in ${ROOTPATH}/functions/*; do
source ${util} source ${util}
@ -30,7 +30,7 @@ EOF
function version() { function version() {
cat << EOF cat << EOF
Novos v${PKGVER} Raclette v${PKGVER}
Copyright (C) 2024 Noveria Network Copyright (C) 2024 Noveria Network
This program may be freely redistributed under This program may be freely redistributed under