1
0
mirror of https://gitlab.com/dbrw/ansible-setup.git synced 2025-08-04 20:35:41 +07:00
ansible-setup/roles/common/tasks/virtualization.yml
2022-07-08 11:59:56 +07:00

44 lines
1.0 KiB
YAML

- name: Install kvm virtualization
pacman:
name:
- virt-manager
- qemu-desktop
- libvirt
- dmidecode
- edk2-ovmf
- dnsmasq
- iptables-nft
- name: update qemu.conf
lineinfile:
path: /etc/libvirt/qemu.conf
regexp: '{{ item.regexp }}'
line: '{{ item.replace }}'
with_items:
- { regexp: '^#user = ', replace: 'user = "{{ username }}"' }
- { regexp: '^#group = ', replace: 'group = "{{ username }}"' }
- name: Add user {{ username }} to libvirt group
ansible.builtin.user:
groups: libvirt
append: True
user: "{{ username }}"
- name: Enable libvirt service
ansible.builtin.systemd:
name: libvirtd
state: started
enabled: yes
- name: Define a new network for virtualization
community.libvirt.virt_net:
command: define
name: jungle
xml: '{{ lookup("template", "libvirt/jungle.xml.j2") }}'
- name: Ensure virtualization network active
community.libvirt.virt_net:
autostart: yes
state: active
name: jungle