diff options
author | Patrick Spek <p.spek@tyil.nl> | 2022-04-16 14:42:35 +0200 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2022-04-16 14:42:35 +0200 |
commit | e3f5c683a1d2b34be698cb59d77d379d38458cad (patch) | |
tree | 43a2c6a2cd7306f19f3cc9a87ccf1a973595e4fb /lib/util.bash | |
parent | f2f03d6ea4d6d181880a9f9c4f019d24065db4ec (diff) |
Update config() to also search playbook-specific config files
Diffstat (limited to 'lib/util.bash')
-rw-r--r-- | lib/util.bash | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/util.bash b/lib/util.bash index c6ef534..32d61c6 100644 --- a/lib/util.bash +++ b/lib/util.bash @@ -14,21 +14,30 @@ config() { } config_for() { + local host=$1 ; shift + local key=$1 ; shift + local default=$1 ; shift + local default local file local files - local host - local value - local key - - host=$1 ; shift - key=$1 ; shift - default=$1 ; shift files=( "$BASHTARD_ETCDIR/hosts.d/$host" "$BASHTARD_ETCDIR/os.d/${BASHTARD_PLATFORM[key]}" "$BASHTARD_ETCDIR/defaults" + ) + + if [[ ! -z "$BASHTARD_PLAYBOOK" ]] + then + debug "bashtard/config_for" "BASHTARD_PLAYBOOK=$BASHTARD_PLAYBOOK, adding etc entries" + files+=( + "$BASHTARD_ETCDIR/playbooks.d/$BASHTARD_PLAYBOOK/etc/os.d" + "$BASHTARD_ETCDIR/playbooks.d/$BASHTARD_PLAYBOOK/etc/defaults" + ) + fi + + files+=( "$BASHTARD_BASEDIR/etc/os.d/${BASHTARD_PLATFORM[key]}" "$BASHTARD_BASEDIR/etc/defaults" ) @@ -36,6 +45,8 @@ config_for() { # Check configuration files for file in "${files[@]}" do + debug "bashtard/config_for" "Checking for '$key' in '$file'" + [[ ! -f $file ]] && continue value="$(awk -F= '$1 == "'"$key"'" { print $NF }' "$file")" |