Merge branch 'macvtap' into fvs

This commit is contained in:
Raphael Dannecker 2024-06-11 14:45:15 +02:00
commit 07ff7f258c
4 changed files with 53 additions and 15 deletions

View file

@ -96,11 +96,15 @@
when: groups.localhome is defined and inventory_hostname in groups.localhome when: groups.localhome is defined and inventory_hostname in groups.localhome
- role: lmn_teacherlaptop - role: lmn_teacherlaptop
when: groups.teacherlaptop is defined and inventory_hostname in groups.teacherlaptop when: groups.teacherlaptop is defined and inventory_hostname in groups.teacherlaptop
- role: lmn_networkd
when: ansible_interfaces | select('search', 'enp.+') | length > 1
tasks: tasks:
## Temporary fixes and quirks: ## Temporary fixes and quirks:
- name: Remove disturbing NetworkManager connection
file:
path: "/etc/NetworkManager/system-connections/Wired connection 1"
state: absent
when: ansible_interfaces | select('search', '^en[pso].+') | length > 1
- name: Fix 8086:4909 external graphics card - name: Fix 8086:4909 external graphics card
replace: replace:
dest: "/etc/default/grub" dest: "/etc/default/grub"
@ -276,6 +280,14 @@
- /etc/sudoers.d/90-lmn-startvirtiofsd - /etc/sudoers.d/90-lmn-startvirtiofsd
- /etc/sudoers.d/90-lmn-link-images - /etc/sudoers.d/90-lmn-link-images
- /etc/rsync.secret - /etc/rsync.secret
- /etc/systemd/network/30-virbr1.netdev
- /etc/systemd/network/30-virbr2.netdev
- /etc/systemd/network/40-ethernet.network
- /etc/systemd/network/40-ethernet-usb.network
- /etc/systemd/network/50-virbr1.network
- /etc/systemd/network/50-virbr2.network
- /etc/systemd/network/60-wlan0-dhcp.network
- /etc/NetworkManager/system-connections/macvlan-vm-macvtap.nmconnection
- name: check if vm_usage_information.txt exists - name: check if vm_usage_information.txt exists
stat: path=/lmn/vm/vm_usage_information.txt stat: path=/lmn/vm/vm_usage_information.txt
@ -304,12 +316,22 @@
done done
when: not ipp_everywhere.rc when: not ipp_everywhere.rc
- name: Remove old VM-printerlists
shell:
cmd: rm -f /lmn/media/*/.printerlist.csv
- name: Remove Listen on VMBridge - name: Remove Listen on VMBridge
lineinfile: lineinfile:
dest: /etc/cups/cupsd.conf dest: /etc/cups/cupsd.conf
line: 'Listen 192.168.122.1:631' line: 'Listen 192.168.122.1:631'
state: absent state: absent
- name: Remove NetworkManager Ansible-Block for non-laptops
blockinfile:
path: /etc/NetworkManager/NetworkManager.conf
state: absent
when: groups.laptop is defined and inventory_hostname not in groups.laptop
## bookworm fixes/hacks: ## bookworm fixes/hacks:
- name: Work around sddm hang on shutdown - name: Work around sddm hang on shutdown
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
@ -367,7 +389,6 @@
roles: roles:
- role: lmn_wlan_iwd - role: lmn_wlan_iwd
when: ansible_interfaces | select('search', 'wl.+') | first is defined when: ansible_interfaces | select('search', 'wl.+') | first is defined
- lmn_networkd
- lmn_localuser - lmn_localuser
tasks: tasks:
- name: Remove deprecated files and directories (laptop-class) - name: Remove deprecated files and directories (laptop-class)

View file

@ -19,6 +19,7 @@ options:
--os OS operating system (win10|linux|..) --os OS operating system (win10|linux|..)
--data-disk size additional data-disk --data-disk size additional data-disk
--bridge virbrX additional network interface on bridge virbrX --bridge virbrX additional network interface on bridge virbrX
--macvtap additional network interface on device macvtap
--options options additional options for virt-install command --options options additional options for virt-install command
EOF EOF
} }
@ -124,7 +125,7 @@ NO_VIEWER=0
source /etc/lmn/vm.conf source /etc/lmn/vm.conf
TEMP=$(getopt -o no:ps --long new,no-viewer,options:,persistent,system,memory:,data-disk:,heads:,cpu:,bridge:,os:,help -n $0 -- "$@") TEMP=$(getopt -o no:ps --long new,no-viewer,options:,persistent,system,memory:,data-disk:,heads:,cpu:,bridge:,macvtap,os:,help -n $0 -- "$@")
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$TEMP" eval set -- "$TEMP"
@ -189,6 +190,15 @@ while true; do
fi fi
shift 2 shift 2
;; ;;
--macvtap )
for interface in $(ip link | sed -En 's/.*(macvtap-.*)@.*/\1/p'); do
mac="$(ip link | grep -A1 "${interface}" | \
sed -nE "s%\s+link/ether ([[:xdigit:]:]{17}) .+%\1%p")"
type="ethernet,mac=${mac},target.dev=${interface},xpath1.set=./target/@managed=no,model.type=virtio"
LIBVIRTOPTS="${LIBVIRTOPTS} --network type=$type"
done
shift
;;
--os ) --os )
LIBVIRTOSINFO=$2 LIBVIRTOSINFO=$2
shift 2 shift 2

View file

@ -215,29 +215,31 @@
- name: Configure macvtap interface - name: Configure macvtap interface
ansible.builtin.copy: ansible.builtin.copy:
dest: /etc/NetworkManager/system-connections/macvlan-vm-macvtap.nmconnection dest: "/etc/NetworkManager/system-connections/macvlan-vm-macvtap-{{ item }}.nmconnection"
mode: '0600' mode: '0600'
content: | content: |
[connection] [connection]
id=macvlan-vm-macvtap id=macvlan-macvtap-{{ item[3:9] }}
type=macvlan type=macvlan
interface-name=vm-macvtap interface-name=macvtap-{{ item[3:9] }}
[macvlan] [macvlan]
mode=2 mode=2
parent={{ ansible_default_ipv4['interface'] }} parent={{ item }}
tap=true tap=true
[ipv4] [ipv4]
method=disabled method=disabled
[ipv6] [ipv6]
method=disabled method=disabled
[proxy] [proxy]
loop: "{{ ansible_interfaces | select('search', '^en[pso].+') }}"
- name: Adjust interface permissions for user mode VMs - name: Adjust interface permissions for user mode VMs
ansible.builtin.copy: ansible.builtin.copy:
dest: /etc/udev/rules.d/80-macvlan.rules dest: /etc/udev/rules.d/80-macvlan.rules
content: | content: |
SUBSYSTEMS=="net", KERNELS=="vm-macvtap", MODE="0666" {% for interface in (ansible_interfaces | select('search', '^en[pso].+')) %}
SUBSYSTEMS=="net", KERNELS=="macvtap-{{ interface[3:9] }}", MODE="0666"
{% endfor %}
- name: Create directory for local .desktop-Files - name: Create directory for local .desktop-Files
ansible.builtin.file: ansible.builtin.file:

View file

@ -33,11 +33,16 @@
[Security] [Security]
Passphrase={{ wifipasswd }} Passphrase={{ wifipasswd }}
- name: Enable systemd-networkd - name: Use iwd (NetworkManager)
ansible.builtin.systemd: blockinfile:
name: systemd-networkd.service dest: /etc/NetworkManager/NetworkManager.conf
enabled: True block: |
[device]
match-device=interface-name:wl*
wifi.backend=iwd
[connection]
match-device=interface-name:wl*
ipv4.route-metric=2048
- name: Provide service to enable WiFi on boot - name: Provide service to enable WiFi on boot
ansible.builtin.copy: ansible.builtin.copy: