Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
#!/bin/bash
# This template will check some ansible variables to know what and how to deploy:
# - kvm_guest_bridge (boolean) => if we'll be using bridge network
# - if true => kvm_host_bridge is the br interface on which to attach vnic for bridge
# - if not, which kvm_guest_network to use (usually 'default' from libvirt)
# - rhel_version : if defined, we'll deploy RHEL and not CentOS version (kvm_guest_distro_release)
{% if kvm_guest_bridge == True %}
{% set kvm_guest_network = 'bridge=' + kvm_host_bridge %}
{% else %}
{% set kvm_guest_network = 'network=' + kvm_guest_default_net %}
{% endif %}
{% if kvm_guest_eth1_bridge is defined %}
{% set kvm_guest_eth1_network = 'bridge=' + kvm_guest_eth1_bridge %}
{% endif %}
virt-install \
--name {{ inventory_hostname }} \
--vcpus {{ kvm_guest_vcpus }} \
{% if not kvm_guest_arch == 'aarch64' -%}
--cpu host \
{% endif %}
--ram {{ kvm_guest_memory }} \
--disk path={{ kvm_host_libvirt_images_path | default('/var/lib/libvirt/images') }}/{{ inventory_hostname}}.qcow2,size={{ kvm_guest_disk_size }},format=qcow2,device=disk,bus=virtio,cache=none \
--nographics \
--network {{ kvm_guest_network }},model=virtio \
{% if kvm_guest_eth1_bridge is defined %}
--network {{ kvm_guest_eth1_network }},model=virtio \
{% endif %}
--hvm --accelerate \
--autostart --wait=-1 \
--noautoconsole \
--initrd-inject=/var/lib/libvirt/local-kickstarts/{{ inventory_hostname }}.cfg \
{% if kvm_guest_arch == 'power9' or kvm_guest_arch == 'ppc64le' %}
--extra-args "console=hvc0 console=hvc1 net.ifnames=0 inst.ks=file:/{{ inventory_hostname }}.cfg" \
{% else %}
--extra-args "console=ttyS0 net.ifnames=0 inst.ks=file:/{{ inventory_hostname }}.cfg" \
{% endif %}
{% if rhel_version is defined %}
--location {{ rhel_deploy_mirror_url }}/{{ rhel_version }}/{{ kvm_guest_arch }}/
{% elif kvm_guest_distro_release == 8 or kvm_guest_distro_release == '8-stream' %}
--location http://mirror.centos.org/centos/{{ kvm_guest_distro_release }}/BaseOS/{{ kvm_guest_arch }}/os/
{% elif kvm_guest_distro_release == '9-stream' %}
--location http://mirror.stream.centos.org/{{ kvm_guest_distro_release }}/BaseOS/{{ kvm_guest_arch}}/os/
{% elif (kvm_guest_distro_release == 7 and kvm_guest_arch == 'ppc64le') or (kvm_guest_distro_release == 7 and kvm_guest_arch == 'ppc64') or (kvm_guest_distro_release == 7 and kvm_guest_arch == 'power9') or (kvm_guest_distro_release == '7' and kvm_guest_arch == 'aarch64') %}
--location http://mirror.centos.org/altarch/{{ kvm_guest_distro_release }}/os/{{ kvm_guest_arch }}/
{% else %}
--location http://mirror.centos.org/centos/{{ kvm_guest_distro_release }}/os/{{ kvm_guest_arch }}/
{% endif %}