support for multiple hypervisors

This commit is contained in:
Pim Kunis 2023-05-03 23:35:57 +02:00
parent 8e72446652
commit b9ad2e866a
9 changed files with 70 additions and 15 deletions

2
ansible/README.md Normal file
View file

@ -0,0 +1,2 @@
Prerequisites on Ansible CONTROLLER:
- python3-netaddr

View file

@ -4,6 +4,7 @@ inventory=inventory
vault_password_file=util/secret-service-client.sh
interpreter_python=/usr/bin/python3
host_key_checking = False
remote_user = root
[diff]
always = True

View file

@ -1,6 +1,5 @@
---
- name: Setup Atlas
hosts: atlas
- hosts: hypervisors
handlers:
- name: enable interfaces
@ -12,12 +11,6 @@
timezone:
name: Europe/Amsterdam
- name: Copy interfaces configuration
copy:
src: dmz.conf
dest: /etc/network/interfaces.d/dmz.conf
notify: enable interfaces
- name: Create data directory
file:
path: /data
@ -27,9 +20,30 @@
roles:
- {role: setup_apt, tags: setup_apt}
- {role: libvirt, tags: libvirt}
- hosts: atlas
roles:
- {role: postgresql, tags: postgresql}
- {role: wireguard, tags: wireguard}
- {role: ssh_ca, tags: ssh_ca}
- hosts: hypervisors
no_log: False
handlers:
- name: enable interfaces
command:
cmd: ifup -a
pre_tasks:
- name: Copy interfaces configuration
copy:
src: dmz.conf
dest: /etc/network/interfaces.d/dmz.conf
notify: enable interfaces
roles:
- {role: wireguard, tags: wireguard}
- {role: ssh_ca_known_hosts, tags: ssh_ca_known_hosts}
- {role: deploy_ssh_certificates, tags: deploy_ssh_certificates}
- {role: borg, tags: borg}

View file

@ -0,0 +1,5 @@
apt_install_packages:
- qemu-kvm
- libvirt-daemon-system
- sudo
- bridge-utils

View file

@ -0,0 +1,12 @@
deploy_ssh_certificates:
- name: ssh_user_ed25519_key
type: user
key_type: ed25519
signing_key: hyp_user
host: jefke.hyp
principals: hypervisor
- name: ssh_host_ed25519_key
type: host
key_type: ed25519
signing_key: hyp_host
host: jefke.hyp

View file

@ -0,0 +1,18 @@
wireguard_addresses:
- "10.42.1.1/32"
wireguard_endpoint: "jefke.hyp"
wireguard_private_key: !vault |
$ANSIBLE_VAULT;1.1;AES256
36376161636365313033613362336239656164643430306437393866353036303938616136613933
6333613866643139653130393532613838353031613562350a663664633033353364303035353131
66363439353537323636313466303236393530653938393838373837366436316665343831623934
3234363066366235300a346636613930346466643566666265613733343266613030613765313161
63343133646566623264393533613733363735666432396366623737306232303761366465306164
3937653537316461376263613338373439313531383961623333
wireguard_unmanaged_peers:
pim:
public_key: "xQ1hkwpIf5x7Wkx1leQHXx3RK8fjGWt2ZmG9XUN3V08="
allowed_ips: "10.42.1.2/32"
niels:
public_key: "WJO/DQUJyDp4rFW291F2Ai51lotU2IC+OATu+5P3Jio="
allowed_ips: "10.42.1.3/32"

View file

@ -1,5 +1,8 @@
all:
hosts:
atlas:
ansible_host: atlas.hyp
ansible_user: root
children:
hypervisors:
hosts:
atlas:
ansible_host: atlas.hyp
jefke:
ansible_host: jefke.hyp

View file

@ -2,7 +2,7 @@ location:
source_directories:
- /data
repositories:
- 'ssh://root@lewis.hyp/mnt/kingston1TB/hosts/atlas'
- 'ssh://root@lewis.hyp/mnt/kingston1TB/hosts/{{ ansible_hostname }}'
retention:
keep_daily: 7
keep_weekly: 4

View file

@ -1,6 +1,6 @@
#!/bin/bash
pass=`secret-tool lookup ansible_vault atlas`
pass=`secret-tool lookup ansible_vault hypervisors`
retval=$?
if [ $retval -ne 0 ]; then