--- - name: Include vars for {{ ansible_os_family }} include_vars: "{{ ansible_os_family }}.yml" - name: "Ensure system is hardware virtualization capability" fail: msg: "qemu-kvm requires hypervisor capability" when: "ansible_virtualization_type != 'kvm'" - name: Include tasks for {{ ansible_os_family }} include_tasks: "{{ ansible_os_family }}.yml" when: - ansible_distribution == 'CentOS' - ansible_distribution_major_version == '7' #- name: Enable a AppStream RHSM repository # community.general.rhsm_repository: # name: "rhel-8-for-{{ ansible_architecture }}-appstream-rpms" # when: # - ansible_distribution == "RedHat" # - ansible_distribution_major_version == '8' - name: install packages package: name: "{{ libvirt_kvm_packages }}" state: present update_cache: yes notify: Restart libvirt - name: Allow hypervisor in VM template: src: kvm.conf.j2 dest: /etc/modprobe.d/kvm.conf owner: root group: root mode: 0644 - name: Install OpenVSwitch include_role: name: openvswitch # vars: # openvswitch_brname: "{{ libvirt_brname }}" when: - libvirt_openvswitch|bool register: install_openvswitch - name: Restart libvirt_kvm after openvswitch installation service: name: "{{ libvirt_service }}" state: restarted #- name: Add OpenVSwitch bridge # openvswitch_bridge: # bridge: '{{ qemu_default_network_interface }}' # parent: '{{ openvswitch_interface }}' # state: present - name: Enable libvirt deamon service: name: "{{ libvirt_service }}" state: started enabled: yes - name: Add defaults networks virt_net: command: define name: '{{ item }}' xml: '{{ lookup ("template", "networks/" + item + ".xml.j2") }}' with_items: - default - private - name: Enable defaults networks on boot virt_net: name: '{{ item }}' autostart: yes with_items: - default - private - name: Activate defaults networks now if it doesn't already up virt_net: name: '{{ item }}' state: active with_items: - default - private - name: Add OpenVSwitch networks virt_net: command: define name: '{{ item.name }}' xml: '{{ lookup ("template", "networks/openvswitch.xml.j2") }}' with_items: - '{{ virtual_network }}' when: - virtual_network is defined - libvirt_openvswitch|bool - name: Activate OpenVSwitch networks now if it doesn't already up virt_net: name: '{{ item.name }}' state: active with_items: - '{{ virtual_network }}' when: - virtual_network is defined - libvirt_openvswitch|bool - name: Enable OpenVSwitch networks on boot virt_net: name: '{{ item.name }}' autostart: yes with_items: - '{{ virtual_network }}' when: - virtual_network is defined - libvirt_openvswitch|bool