2024-09/helper/create_inventory_from_lxc.sh
2024-09-20 15:59:46 +02:00

86 lines
1.1 KiB
Bash
Executable file

#!/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