1
0

new hypervisor wip

This commit is contained in:
michael 2023-08-09 18:38:34 +10:00
parent 590a50cd1a
commit 5007f0b68e
14 changed files with 233 additions and 52 deletions

View File

@ -0,0 +1,26 @@
systemd_networkd_configs:
- name: 00-eth0.link
src: ethernet.link.j2
mac_address: 00-00-00-00-00-00
- name: 00-eth1.link
src: ethernet.link.j2
mac_address: 00-00-00-00-00-00
- name: 00-eth2.link
src: ethernet.link.j2
mac_address: 00-00-00-00-00-00
- name: 00-eth3.link
src: ethernet.link.j2
mac_address: 00-00-00-00-00-00
- name: br0.netdev
src: bridge.netdev.j2
vlan_filtering: true
stp: true
- name: br0.network
src: bridge.network.j2
- name: vlan110.netdev
src: vlan.netdev.j2
- name: vlan110.network
src: vlan.network.j2
qemu_bridges:
br0

View File

@ -1,64 +1,101 @@
all:
children:
ups:
hosts:
ups00_balsillie_house:
firewalls:
children:
opnsense:
hosts:
fw00_balsillie_net:
openwrt:
hosts:
fw00_balsillie_house:
switches:
hosts:
sw00_balsillie_house:
waps:
hosts:
wap00_balsillie_house:
virtual_machines:
hosts:
kube01_balsillie_net:
kube02_balsillie_net:
kube03_balsillie_net:
fw00_balsillie_net:
fw00_balsillie_house:
mp00_balsillie_house:
win11_balsillie_house:
bare_metal:
hosts:
ups00_balsillie_house:
sw00_balsillie_house:
wap00_balsillie_house:
hv00_balsillie_house:
hv00_balsillie_net:
lat5420_balsillie_house:
lat7490_balsillie_house:
sff_balsillie_house:
servers:
children:
hypervisors:
hosts:
server:
lab:
hv00:
vms:
children:
nodes:
hosts:
node1:
node2:
node3:
hosts:
router:
hetzner:
hosts:
hv00:
fw00:
hv00_balsillie_net: # Hetzner
hv00_balsillie_house: # vp2420
hv01_balsillie_net: # 4U Rosewill
k8s:
children:
k8s_control:
hosts:
kube01:
# kube02:
# kube03:
kube01_balsillie_net:
kube02_balsillie_net:
kube03_balsillie_net:
k8s_taint:
hosts:
kube01:
# kube02:
# kube03:
kube01_balsillie_net:
kube02_balsillie_net:
kube03_balsillie_net:
k8s_worker:
hosts:
kube01:
# kube02:
# kube03:
kube01_balsillie_net:
kube02_balsillie_net:
kube03_balsillie_net:
k8s_storage:
hosts:
kube01:
# kube02:
# kube03:
firewalls:
children:
fortigate:
hosts:
fortigate00:
opnsense:
hosts:
fw00:
switches:
hosts:
sw00:
kube01_balsillie_net:
kube02_balsillie_net:
kube03_balsillie_net:
workstations:
children:
arch:
hosts:
lat5420:
sff:
lat5420_balsillie_house:
sff_balsillie_house:
mp00_balsillie_house:
windows:
hosts:
bridie:
lat7490_balsillie_house:
win11_balsillie_house:
laptops:
hosts:
lat5420_balsillie_house:
lat7490_balsillie_house:
desktops:
hosts:
sff_balsillie_house:
mp00_balsillie_house:
hetzner:
hosts:
fw00_balsillie_net:
hv00_balsillie_net:
kube01_balsillie_net:
kube02_balsillie_net:
kube03_balsillie_net:
house:
hosts:
hv00_balsillie_house:
fw00_balsillie_house:
mp00_balsillie_house:
win11_balsillie_house:
lat5420_balsillie_house:
sff_balsillie_house:

View File

@ -0,0 +1,5 @@
---
iso_source:
ntp_servers:
- time.example.com

View File

@ -1,2 +0,0 @@
---
iso_source:

View File

@ -0,0 +1,12 @@
libvirt_packages:
arch:
qemu-base
openbsd-netcat
swtpm
gettext
libvirt
libvirt-python
default_network_services:
Archlinux:
NetworkManager

View File

@ -0,0 +1,76 @@
---
- name: Clear systemd-networkd config directory
ansible.builtin.file:
path: "/etc/systemd/network/"
state: "{{ item }}"
owner: root
group: root
mode: '0755'
with_items:
- absent
- directory
- name: Create systemd-networkd config files
ansible.builtin.template:
src: "{{ item.src }}"
dest: /etc/systemd/network/"{{ item.name }}"
owner: root
group: root
mode: '0644'
loop: "{{ systemd_networkd_configs }}"
- name: Disable non-systemd networking services
ansible.builtin.service:
name: "{{ item }}"
state: stopped
enabled: false
loop: "{{ default_network_services[ansible_os_family] }}"
- name: Enable systemd networking
ansible.builtin.service:
name: "{{ item }}"
state: started
enabled: true
loop:
- systemd-networkd
- systemd-resolved
- name: Install libvirt packages (Arch)
when: ansible_os_distribution == 'Archlinux'
community.general.pacman:
name: "{{ libvirt_packages['Arch'] }}"
state: present
update_cache: true
- name: Add user to libvirt group
ansible.builtin.user:
name: "{{ ansible_user }}"
groups: libvirt
append: true
- name: Add bridge(s) to qemu_bridge_helper
when: qemu_bridges is defined
ansible.builtin.lineinfile:
path: /etc/qemu/bridge.conf
line: "{{ item }}"
state: present
backup: false
insertafter: EOF
loop: "{{ qemu_bridges | default(['virbr0']) }}"
- name: Start and enable libvirt service
ansible.builtin.service:
name: libvirtd.service
state: started
enabled: true
- name: Stop the default libvirt network
community.libvirt.virt_net:
name: default
state: inactive
- name: Remove default libvirt network
community.libvirt.virt_net:
name: default
state: absent

View File

@ -0,0 +1,9 @@
[NetDev]
Name=br0
Kind=bridge
[Bridge]
DefaultPVID=none
VLANFiltering={{ item.vlan_filtering }}
VLANProtocol=802.1q
STP={{ item.stp }}

View File

@ -0,0 +1,6 @@
[Match]
PermanentMACAddress={{ item.mac_address }}
[Link]
MACAddressPolicy=permanent
MACAddress={{ item.mac_address }}
Name={{ item.name | regex_replace('^[0-9]*-', '') | regex_replace('\.link', '') }}

View File

@ -0,0 +1,12 @@
[Match]
MACAddress={{ item.mac_address }}
[Link]
ARP={{ item.arp }}
[Network]
DHCP=no
if item.bond
Bond={{ item.bond }}
if item.bridge
Bridge={{ item.bridge }}