refs #8025 Native ansible aproach for local inventory and vars
This commit is contained in:
parent
ccb95837fa
commit
b07704bf71
|
@ -4,8 +4,9 @@ venv
|
||||||
.vault.yml
|
.vault.yml
|
||||||
.passbolt.yml
|
.passbolt.yml
|
||||||
inventories/local
|
inventories/local
|
||||||
inventories/local-*
|
inventories/local.yml
|
||||||
inventories/*/local-*.yml
|
inventories/local.yaml
|
||||||
inventories/*/local-*.yaml
|
inventories/host_vars/*/local.yml
|
||||||
inventories/host_vars/*.local.yml
|
inventories/host_vars/*/local.yaml
|
||||||
inventories/host_vars/*.local.yaml
|
inventories/group_vars/*/local.yml
|
||||||
|
inventories/group_vars/*/local.yaml
|
||||||
|
|
|
@ -2,34 +2,12 @@
|
||||||
|
|
||||||
EXTRA_ARGS=()
|
EXTRA_ARGS=()
|
||||||
|
|
||||||
OPTSTRING=":i:l:"
|
|
||||||
while getopts ${OPTSTRING} opt; do
|
|
||||||
case ${opt} in
|
|
||||||
i)
|
|
||||||
INVENTORY="$OPTARG"
|
|
||||||
;;
|
|
||||||
l)
|
|
||||||
LIMIT="$OPTARG"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ -f .passbolt.yml ]; then
|
if [ -f .passbolt.yml ]; then
|
||||||
EXTRA_ARGS+=("--extra-vars" "@.passbolt.yml")
|
EXTRA_ARGS+=("--extra-vars" "@.passbolt.yml")
|
||||||
fi
|
fi
|
||||||
if [ -f .vault-pass ]; then
|
if [ -f .vault-pass ]; then
|
||||||
EXTRA_ARGS+=("--vault-password-file" ".vault-pass")
|
EXTRA_ARGS+=("--vault-password-file" ".vault-pass")
|
||||||
fi
|
fi
|
||||||
if [[ -n "${LIMIT:-}" && -n "${INVENTORY:-}" ]]; then
|
|
||||||
INVENTORY_DIR=$(dirname "$INVENTORY")
|
|
||||||
LOCAL_HOST_VARS="$INVENTORY_DIR/host_vars/$LIMIT.local"
|
|
||||||
if [ -f "$LOCAL_HOST_VARS.yml" ]; then
|
|
||||||
EXTRA_ARGS+=("--extra-vars" "@$LOCAL_HOST_VARS.yml")
|
|
||||||
fi
|
|
||||||
if [ -f "$LOCAL_HOST_VARS.yaml" ]; then
|
|
||||||
EXTRA_ARGS+=("--extra-vars" "@$LOCAL_HOST_VARS.yaml")
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
#export PYTHONPATH=./venv/lib/python3.12/site-packages/
|
#export PYTHONPATH=./venv/lib/python3.12/site-packages/
|
||||||
ansible-playbook ${EXTRA_ARGS[@]} $@
|
ansible-playbook ${EXTRA_ARGS[@]} $@
|
||||||
|
|
Loading…
Reference in New Issue