diff --git a/salt/libvirt/init.sls b/salt/libvirt/init.sls index 4c87e22e7..7d1d19240 100644 --- a/salt/libvirt/init.sls +++ b/salt/libvirt/init.sls @@ -53,13 +53,18 @@ install_qemu: pkg.installed: - name: qemu-kvm -install_libguestfs: - pkg.installed: - - name: libguestfs +create_host_bridge: + virt.network_running: + - name: host-bridge + - bridge: br0 + - forward: bridge + - autostart: True -install-guestfs-tools: - pkg.installed: - - name: guestfs-tools +disable_default_bridge: + cmd.run: + - name: virsh net-destroy default && virsh net-autostart default --disable + - require: + - pkg: install_libvirt-client # this should only run during the first highstate after setup. it will transfer connection from mgmt to br0 down_original_mgmt_interface: diff --git a/salt/libvirt/packages.sls b/salt/libvirt/packages.sls index bc39d4df1..9b56c6f64 100644 --- a/salt/libvirt/packages.sls +++ b/salt/libvirt/packages.sls @@ -11,6 +11,25 @@ install_libvirt-client: pkg.installed: - name: libvirt-client +# allows for creating vm images +# any node manipulating images needs this +install_qemu-img: + pkg.installed: + - name: qemu-img + +install_guestfs-tools: + pkg.installed: + - name: guestfs-tools + +install_xorriso: + pkg.installed: + - name: xorriso + +install_virt-install: + pkg.installed: + - name: virt-install +### + libvirt_python_wheel: file.recurse: - name: /opt/so/conf/libvirt/source-packages/libvirt-python diff --git a/salt/libvirt/ssh/users.sls b/salt/libvirt/ssh/users.sls index 5913deb15..28d9afe0d 100644 --- a/salt/libvirt/ssh/users.sls +++ b/salt/libvirt/ssh/users.sls @@ -51,6 +51,6 @@ qemu_ssh_client_config: soqemussh_pub_key: ssh_auth.present: - user: soqemussh - - source: salt://libvirt/ssh_keys/id_ed25519.pub + - source: salt://libvirt/ssh/keys/id_ed25519.pub {% endif %} diff --git a/salt/salt/cloud/cloud.profiles.d/socloud.conf.jinja b/salt/salt/cloud/cloud.profiles.d/socloud.conf.jinja index da8044323..1a5243666 100644 --- a/salt/salt/cloud/cloud.profiles.d/socloud.conf.jinja +++ b/salt/salt/cloud/cloud.profiles.d/socloud.conf.jinja @@ -49,10 +49,11 @@ sensor: sls_list: - setHostname -{%- for hv in HYPERVISORS %} +{%- for node_type, hosts in HYPERVISORS.items() %} +{%- for host in hosts %} -core-{{hv}}: - provider: kvm-ssh-{{hv}} +core-{{host}}: + provider: kvm-ssh-{{host}} base_domain: jppol9vm ip_source: qemu-agent ssh_username: onionuser @@ -67,4 +68,5 @@ core-{{hv}}: sls_list: - setHostname +{%- endfor %} {%- endfor %} diff --git a/salt/salt/cloud/cloud.providers.d/libvirt.conf.jinja b/salt/salt/cloud/cloud.providers.d/libvirt.conf.jinja index 5ead21f1f..3f18a9124 100644 --- a/salt/salt/cloud/cloud.providers.d/libvirt.conf.jinja +++ b/salt/salt/cloud/cloud.providers.d/libvirt.conf.jinja @@ -3,12 +3,14 @@ # driver: libvirt # url: qemu+ssh://soqemussh@jpphype1/system?socket=/var/run/libvirt/libvirt-sock -{%- for hv in HYPERVISORS %} +{%- for node_type, hosts in HYPERVISORS.items() %} +{%- for host in hosts %} -kvm-ssh-{{hv}}: +kvm-ssh-{{host}}: driver: libvirt - url: qemu+ssh://soqemussh@{{hv}}/system?socket=/var/run/libvirt/libvirt-sock + url: qemu+ssh://soqemussh@{{host}}/system?socket=/var/run/libvirt/libvirt-sock +{%- endfor %} {%- endfor %} # Or connect to a local libvirt instance diff --git a/salt/salt/cloud/init.sls b/salt/salt/cloud/init.sls index 60ee23067..63c624bdb 100644 --- a/salt/salt/cloud/init.sls +++ b/salt/salt/cloud/init.sls @@ -28,7 +28,7 @@ cloud_profiles: - name: /etc/salt/cloud.profiles.d/socloud.conf - source: salt://salt/cloud/cloud.profiles.d/socloud.conf.jinja - defaults: - HYPERVISORS: {{pillar.hypervisor.nodes}} + HYPERVISORS: {{pillar.hypervisor.nodes.hypervisor}} - template: jinja {% else %}