Svens Extra-Scripts/-Beispiele
This commit is contained in:
parent
b86303068a
commit
2e35e881f3
18
extra/changed_failed_when.yml
Normal file
18
extra/changed_failed_when.yml
Normal file
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
- hosts:
|
||||
- tn00-debian12
|
||||
- tn00-alpine3i
|
||||
|
||||
gather_facts: no
|
||||
|
||||
tasks:
|
||||
- name: "Gebe CHANGED zurück, wenn /etc/hostname den String 'debian' enthält"
|
||||
command: cat /etc/hostname
|
||||
register: output
|
||||
changed_when: '"debian" in output.stdout'
|
||||
|
||||
- name: "Gebe FAILED zurück, wenn /etc/hostname den String 'alpine' enthält"
|
||||
command: cat /etc/hostname
|
||||
register: output
|
||||
failed_when: '"alpine" in output.stdout'
|
||||
|
9
extra/changed_when.yml
Normal file
9
extra/changed_when.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
- hosts: all
|
||||
gather_facts: no
|
||||
|
||||
tasks:
|
||||
- command: cat /etc/hosts
|
||||
register: output
|
||||
changed_when: '"tn00-cento" in output.stdout'
|
||||
|
26
extra/ein_rechner_failed.yml
Normal file
26
extra/ein_rechner_failed.yml
Normal file
|
@ -0,0 +1,26 @@
|
|||
---
|
||||
- hosts:
|
||||
- tn00-debian12
|
||||
- tn00-alpine3i
|
||||
|
||||
gather_facts: no
|
||||
|
||||
tasks:
|
||||
- name: Debian bricht ab
|
||||
debug:
|
||||
msg: "Hallo"
|
||||
failed_when: '"debian" in inventory_hostname'
|
||||
|
||||
|
||||
- hosts:
|
||||
- tn00-debian12
|
||||
- tn00-alpine3i
|
||||
|
||||
gather_facts: no
|
||||
|
||||
tasks:
|
||||
- name: "Wer lebt noch?"
|
||||
debug:
|
||||
msg: "Lebenszeichen"
|
||||
|
||||
|
8
extra/wireguard-key-anlegen_changed_when.yml
Normal file
8
extra/wireguard-key-anlegen_changed_when.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
- hosts: localhost
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- shell: "[ ! -f wg.pub ] && wg genkey | tee wg.priv | wg pubkey | tee wg.pub || true"
|
||||
register: output
|
||||
changed_when: output.stdout != ""
|
||||
|
8
extra/wireguard-key-anlegen_creates.yml
Normal file
8
extra/wireguard-key-anlegen_creates.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
- hosts: localhost
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- shell: "wg genkey | tee wg.priv | wg pubkey | tee wg.pub"
|
||||
args:
|
||||
creates: wg.pub
|
||||
|
11
helper/06_gitmodules.sh
Executable file
11
helper/06_gitmodules.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash -ex
|
||||
|
||||
mkdir -p roles.extern
|
||||
|
||||
git submodule add https://git.velt.biz/Ansible/cleanup-hosts.git roles.extern/cleanup-hosts
|
||||
git submodule add https://git.velt.biz/Ansible/role.ssh-keyonly.git roles.extern/ssh-keyonly
|
||||
git submodule add https://git.velt.biz/Ansible/epel-simplified roles.extern/epel-simplified
|
||||
|
||||
ln -s cleanup-hosts roles.extern/hosts
|
||||
ln -s epel-simplified roles.extern/epel
|
||||
|
7
helper/07_gitmodules.sh
Executable file
7
helper/07_gitmodules.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash -ex
|
||||
|
||||
mkdir -p roles.extern
|
||||
|
||||
git submodule add https://git.velt.biz/Ansible/dokuwiki_inventory.git roles.extern/dokuwiki_inventory
|
||||
git submodule add -b devel https://git.velt.biz/Ansible/dokuwiki_inventory.git roles.extern/dokuwiki_inventory.devel
|
||||
|
4
helper/07_packages.sh
Executable file
4
helper/07_packages.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
sudo apt install --no-install-recommends --yes python3-netaddr
|
||||
|
5
helper/08_packages.sh
Executable file
5
helper/08_packages.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
sudo apt install --no-install-recommends --yes \
|
||||
python3-dnspython \
|
||||
|
8
helper/09_gitmodules.sh
Executable file
8
helper/09_gitmodules.sh
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash -ex
|
||||
|
||||
mkdir -p roles.extern
|
||||
rm -fr 09/ssh-wrapper-for-monitoring
|
||||
|
||||
git submodule add https://git.velt.biz/Ansible/monitored.git roles.extern/monitored
|
||||
git submodule add https://git.velt.biz/Monitoring/ssh-wrapper-for-monitoring.git 09/ssh-wrapper-for-monitoring
|
||||
|
12
helper/11_gitmodules.sh
Executable file
12
helper/11_gitmodules.sh
Executable file
|
@ -0,0 +1,12 @@
|
|||
#!/bin/bash -ex
|
||||
|
||||
mkdir -p roles.extern
|
||||
|
||||
git submodule add https://git.velt.biz/Ansible/roles.webcluster.git roles.webcluster
|
||||
git submodule add https://git.velt.biz/Ansible/selfsignedcert.git roles.extern/selfsignedcert
|
||||
|
||||
cd roles.webcluster
|
||||
git submodule init
|
||||
git submodule update
|
||||
cd ..
|
||||
|
7
helper/12_gitmodules.sh
Executable file
7
helper/12_gitmodules.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash -ex
|
||||
|
||||
mkdir -p roles.extern
|
||||
|
||||
git submodule add https://git.velt.biz/Ansible/roles_timesync.git roles.extern/roles_timesync
|
||||
git submodule add https://git.velt.biz/Ansible/Prepare_Workshop.git 12/Prepare_Workshop
|
||||
|
6
helper/12_packages.sh
Executable file
6
helper/12_packages.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
sudo apt install --no-install-recommends --yes \
|
||||
jq \
|
||||
nmap\
|
||||
|
15
helper/create_hosts_from_file.sh
Executable file
15
helper/create_hosts_from_file.sh
Executable 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
10
helper/create_hosts_from_lxc.sh
Executable 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
|
||||
|
90
helper/create_inventory_from_file.sh
Executable file
90
helper/create_inventory_from_file.sh
Executable 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
|
||||
|
85
helper/create_inventory_from_lxc.sh
Executable file
85
helper/create_inventory_from_lxc.sh
Executable 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
|
||||
|
Loading…
Reference in a new issue