26 lines
1.5 KiB
Bash
26 lines
1.5 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
{{ includeTemplate "universal/profile" }}
|
|
{{ includeTemplate "universal/logg" }}
|
|
|
|
### Symlink the variables / files / inventories to ~/.config/ansible folders if they are present
|
|
### i.e. Changes to upstream will not impact the play if your configuration files are stored locally
|
|
for TARGET in "files" "group_vars" "host_vars" "inventories" "templates"; do
|
|
if [ -d "${XDG_CONFIG_HOME:-$HOME/.config}/ansible/$TARGET" ] && [ "$(readlink -f "${XDG_DATA_HOME:-$HOME/.local/share}/ansible/$TARGET")" != "${XDG_CONFIG_HOME:-$HOME/.config}/ansible/$TARGET" ]; then
|
|
logg 'Symlinking Ansible playbook '"$TARGET"' to ~/.config/ansible/$TARGET'
|
|
rm -f "${XDG_DATA_HOME:-$HOME/.local/share}/ansible/$TARGET"
|
|
ln -s "${XDG_CONFIG_HOME:-$HOME/.config}/ansible/$TARGET" "${XDG_DATA_HOME:-$HOME/.local/share}/ansible/$TARGET"
|
|
fi
|
|
done
|
|
|
|
### Symlink tasks as well
|
|
### Note: Only handles tasks one level deep (i.e. ~/.config/ansible/tasks/my-task.yml will link to the tasks folder
|
|
### but ~/.config/ansible/tasks/directory/my-other-task.yml will not)
|
|
if [ -d "${XDG_CONFIG_HOME:-$HOME/.config}/ansible/tasks" ]; then
|
|
find "${XDG_CONFIG_HOME:-$HOME/.config}/ansible/tasks" -type f | while read TASK_FILE; do
|
|
TASK_FILE_NAME="$(echo "$TASK_FILE" | sed 's/.*\/\([^\/]*\)$/\1/')"
|
|
if [ "$(readlink -f "${XDG_DATA_HOME:-$HOME/.local/share}/ansible/tasks/$TASK_FILE_NAME")" != "$TASK_FILE" ]; then
|
|
ln -s "$TASK_FILE" "${XDG_DATA_HOME:-$HOME/.local/share}/ansible/tasks/$TASK_FILE_NAME"
|
|
fi
|
|
done
|
|
fi
|