This commit is contained in:
DerLinkman
2026-10-17 17:16:53 +02:00
parent ceda1ae4a6
commit 7abcd14c94
11 changed files with 93 additions and 25 deletions
+15 -6
View File
@@ -1,6 +1,18 @@
#!/bin/bash
defaultimage="ansible:deb13"
ssh_key_dir="${SSH_KEY_DIR:-$HOME/.ssh}"
if [ ! -d "$ssh_key_dir" ] || [ ! -r "$ssh_key_dir" ]; then
echo "Lokales SSH-Verzeichnis '$ssh_key_dir' fehlt oder ist nicht lesbar." >&2
echo "Setze SSH_KEY_DIR auf das Verzeichnis mit deinem SSH-Key." >&2
exit 1
fi
case "$ssh_key_dir" in
/*) ;;
*) ssh_key_dir="$(pwd)/$ssh_key_dir" ;;
esac
export ANSIBLE_HOST_KEY_CHECKING=False
export ANSIBLE_CONFIG=./ansible.cfg
@@ -36,12 +48,10 @@ docker run --rm -dit \
-e ANSIBLE_HOST_KEY_CHECKING=False \
-e ANSIBLE_CONFIG=./ansible.cfg \
-v "$(pwd):/ansible" \
-v ansible_ssh_keys:/root/.ssh \
-v "$ssh_key_dir:/root/.ssh:ro" \
-w /ansible \
$defaultimage \
"/bin/bash"
docker exec "$container_name" sh -lc "mkdir -p /root/.ssh && chmod 700 /root/.ssh && printf 'Host *\n StrictHostKeyChecking no\n UserKnownHostsFile /dev/null\n' > /root/.ssh/config && chmod 600 /root/.ssh/config"
"$defaultimage" \
"/bin/bash" || exit "$?"
container_ipv4=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{if .IPAddress}}{{.IPAddress}}{{end}}{{end}}' "$container_name" 2>/dev/null)
container_ipv6=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{if .GlobalIPv6Address}}{{.GlobalIPv6Address}}{{end}}{{end}}' "$container_name" 2>/dev/null)
@@ -56,4 +66,3 @@ echo "-----------------------------------"
docker attach "$container_name"