Scripte zum Erzeugen des Inventory

This commit is contained in:
Sven Velt 2025-05-14 09:13:03 +02:00
parent cf354508fd
commit 9078900dd1
4 changed files with 200 additions and 0 deletions

View file

@ -0,0 +1,15 @@
#!/bin/bash
if [ -z "$1" -o ! -f "$1" ]; then
echo Need filename
exit 1
fi
for GROUP in alpine archlinux centos debian devuan fedora oracle opensuse ubuntu voidlinux
do
grep "${GROUP}" "$1" | while read NAME IP REST
do
echo -e "${IP}\t${NAME}.heinlein.akademie\t\t${NAME}"
done
done

10
helper/create_hosts_from_lxc.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
for GROUP in alpine archlinux centos debian devuan fedora oracle opensuse ubuntu voidlinux
do
sudo lxc-ls -f -F name,ipv4 -g ${GROUP} | grep -v NAME | while read NAME IP
do
echo -e "${IP}\t${NAME}.heinlein.akademie\t\t${NAME}"
done
done

View file

@ -0,0 +1,90 @@
#!/bin/bash
if [ -z "$1" -o ! -f "$1" ]; then
echo Need filename
exit 1
fi
for GROUP in almalinux alpine archlinux centos debian devuan fedora oracle rockylinux opensuse ubuntu voidlinux
do
echo "[${GROUP}]"
grep "${GROUP}" "$1" | while read NAME IP REST
do
case "${GROUP}" in
almalinux|rockylinux)
echo -e "${NAME}\t\tansible_host=${IP}"
;;
*)
echo "${NAME}"
;;
esac
done
echo ""
done
cat <<EOF
############################################################
[apk:children]
alpine
[apt]
EOF
grep "mint" "$1" | while read NAME IP REST
do
echo "${NAME}"
done
cat <<EOF
[apt:children]
debian
devuan
ubuntu
[pacman:children]
archlinux
[yum:children]
almalinux
centos
fedora
oracle
rockylinux
[xbps:children]
voidlinux
[zypper:children]
opensuse
############################################################
[lb]
tn00-alpine3j
tn00-alpine3k
[lb:vars]
ansible_ssh_transfer_method=piped
[worker]
tn00-ubu2004a
tn00-ubu2004b
tn00-ubu2004c
tn00-ubu2004d
tn00-debian11
[db]
tn00-ubu2004a
tn00-ubu2004b
[webcluster:children]
lb
worker
db
EOF

View file

@ -0,0 +1,85 @@
#!/bin/bash
for GROUP in almalinux alpine archlinux centos debian devuan fedora oracle rockylinux opensuse ubuntu voidlinux
do
echo "[${GROUP}]"
sudo lxc-ls -f -F name,ipv4 -g ${GROUP} | grep -v NAME | while read NAME IP
do
case "${GROUP}" in
almalinux|rockylinux)
echo -e "${NAME}\t\tansible_host=${IP}"
;;
*)
echo "${NAME}"
;;
esac
done
echo ""
done
cat <<EOF
############################################################
[apk:children]
alpine
[apt]
EOF
sudo lxc-ls -f -F name,ipv4 -g mint | grep -v NAME | while read NAME IP
do
echo "${NAME}"
done
cat <<EOF
[apt:children]
debian
devuan
ubuntu
[pacman:children]
archlinux
[yum:children]
almalinux
centos
fedora
oracle
rockylinux
[xbps:children]
voidlinux
[zypper:children]
opensuse
############################################################
[lb]
tn00-alpine3j
tn00-alpine3k
[lb:vars]
ansible_ssh_transfer_method=piped
[worker]
tn00-ubu2004a
tn00-ubu2004b
tn00-ubu2004c
tn00-ubu2004d
tn00-debian11
[db]
tn00-ubu2004a
tn00-ubu2004b
[webcluster:children]
lb
worker
db
EOF