Some checks reported errors
continuous-integration/drone/push Build encountered an error
160 lines
4.1 KiB
YAML
160 lines
4.1 KiB
YAML
---
|
|
- name: Include vars for {{ ansible_os_family }}
|
|
ansible.builtin.include_vars: "{{ ansible_os_family }}.yml"
|
|
|
|
- name: "Ensure system is hardware virtualization capability"
|
|
ansible.builtin.fail:
|
|
msg: "qemu-kvm requires hypervisor capability"
|
|
when: "ansible_virtualization_type != 'kvm'"
|
|
|
|
- name: Include tasks for {{ ansible_os_family }}
|
|
ansible.builtin.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: Create a thin pool for libvirt
|
|
# community.general.lvol:
|
|
# vg: vg_sys
|
|
# thinpool: libvirt_var
|
|
# size: "{{ lv_libvirt_size | default('20g') }}"
|
|
#
|
|
# - name: Create cache pool logical volume
|
|
# community.general.lvol:
|
|
# vg: firefly
|
|
# lv: lvcache
|
|
# size: 512m
|
|
# opts: --type cache-pool
|
|
#
|
|
# - name: Verify or create backup LV
|
|
# community.general.lvol:
|
|
# lv: libvirt_var
|
|
# vg: vg_sys
|
|
# state: present
|
|
# active: yes
|
|
# size: 200G
|
|
#
|
|
# - name: Verify or apply filesystem for backup LV
|
|
# ansible.builtin.filesystem:
|
|
# fstype: ext4
|
|
# dev: "/dev/mapper/vg_sys-libvirt_var"
|
|
#
|
|
# - name: Create /var/lib/libvirt directory
|
|
# ansible.builtin.file:
|
|
# path: /var/lib/libvirt
|
|
# state: directory
|
|
# owner: root
|
|
# group: root
|
|
# mode: 0755
|
|
#
|
|
# - name: mount /var/lib/libvirt
|
|
# ansible.posix.mount:
|
|
# name: /var/lib/libvirt
|
|
# src: /dev/mapper/vg_sys-libvirt_var
|
|
# fstype: ext4
|
|
# opts: errors=remount-ro,discard
|
|
# state: mounted
|
|
|
|
- name: install packages
|
|
ansible.builtin.package:
|
|
name: "{{ libvirt_kvm_packages }}"
|
|
state: present
|
|
update_cache: true
|
|
notify: Restart libvirt
|
|
|
|
- name: Allow hypervisor in VM
|
|
ansible.builtin.template:
|
|
src: kvm.conf.j2
|
|
dest: /etc/modprobe.d/kvm.conf
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
|
|
- name: Install OpenVSwitch
|
|
ansible.builtin.include_role:
|
|
name: openvswitch
|
|
# vars:
|
|
# openvswitch_brname: "{{ libvirt_brname }}"
|
|
when:
|
|
- libvirt_openvswitch|bool
|
|
register: install_openvswitch
|
|
|
|
- name: Restart libvirt_kvm after openvswitch installation
|
|
ansible.builtin.service:
|
|
name: "{{ libvirt_service }}"
|
|
state: restarted
|
|
|
|
# - name: Add OpenVSwitch bridge
|
|
# openvswitch.openvswitch.openvswitch_bridge:
|
|
# bridge: '{{ qemu_default_network_interface }}'
|
|
# parent: '{{ openvswitch_interface }}'
|
|
# state: present
|
|
|
|
- name: Enable libvirt deamon
|
|
ansible.builtin.service:
|
|
name: "{{ libvirt_service }}"
|
|
state: started
|
|
enabled: true
|
|
|
|
- name: Add defaults networks
|
|
community.libvirt.virt_net:
|
|
ansible.builtin.command: define
|
|
name: '{{ item }}'
|
|
xml: '{{ lookup ("template", "networks/" + item + ".xml.j2") }}'
|
|
with_items:
|
|
- default
|
|
- private
|
|
|
|
- name: Enable defaults networks on boot
|
|
community.libvirt.virt_net:
|
|
name: '{{ item }}'
|
|
autostart: true
|
|
with_items:
|
|
- default
|
|
- private
|
|
|
|
- name: Activate defaults networks now if it doesn't already up
|
|
community.libvirt.virt_net:
|
|
name: '{{ item }}'
|
|
state: active
|
|
with_items:
|
|
- default
|
|
- private
|
|
|
|
- name: Add OpenVSwitch networks
|
|
community.libvirt.virt_net:
|
|
ansible.builtin.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
|
|
community.libvirt.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
|
|
community.libvirt.virt_net:
|
|
name: '{{ item.name }}'
|
|
autostart: true
|
|
with_items:
|
|
- '{{ virtual_network }}'
|
|
when:
|
|
- virtual_network is defined
|
|
- libvirt_openvswitch|bool
|