setup bridge and fix salt before first highstate for hypervisors

This commit is contained in:
Josh Patterson
2025-05-16 14:24:07 -04:00
parent 9e0f13cce5
commit 6988f03ebc
4 changed files with 61 additions and 45 deletions

View File

@@ -13,12 +13,12 @@
{% if sls in allowed_states %}
{% if 'vrt' in salt['pillar.get']('features', []) %}
{% from 'libvirt/map.jinja' import LIBVIRTMERGED %}
{% from 'salt/map.jinja' import SYSTEMD_UNIT_FILE %}
include:
- libvirt.64962
- libvirt.packages
- libvirt.ssh.users
- salt.mine_functions
install_libvirt:
pkg.installed:
@@ -93,50 +93,6 @@ disable_default_bridge:
- onlyif:
- virsh net-list | grep default
# this should only run during the first highstate after setup. it will transfer connection from mgmt to br0
down_original_mgmt_interface:
cmd.run:
- name: "nmcli con down {{ pillar.host.mainint }}"
- unless:
- nmcli -f GENERAL.CONNECTION dev show {{ pillar.host.mainint }} | grep bridge-slave-{{ pillar.host.mainint }}
- order: last
update_mine_functions_interface:
file.replace:
- name: /etc/salt/minion.d/mine_functions.conf
- pattern: " - interface: ([a-zA-Z0-9]+)"
- repl: " - interface: br0"
- onchanges:
- cmd: down_original_mgmt_interface
wait_for_br0_ip:
cmd.run:
- name: |
counter=0
until ip addr show br0 | grep -q "inet "; do
sleep 1
counter=$((counter+1))
if [ $counter -ge 90 ]; then
echo "Timeout waiting for br0 to get an IP address"
exit 1
fi
done
echo "br0 has IP address: $(ip addr show br0 | grep 'inet ' | awk '{print $2}')"
- timeout: 95
- onchanges:
- file: update_mine_functions_interface
mine_update_mine_interface:
module.run:
- mine.send:
- network.ip_addrs
- interface: br0
- onchanges:
- cmd: wait_for_br0_ip
# virtlogd service may not restart following reboot without this
#semanage permissive -a virtlogd_t
{% else %}
{{sls}}_no_license_detected:
test.fail_without_changes: