1
0
mirror of https://gitlab.com/dbrw/ansible-setup.git synced 2025-08-04 17:55:41 +07:00
ansible-setup/roles/common/tasks/virtualization.yml
2022-07-12 17:06:26 +07:00

58 lines
1.3 KiB
YAML

- name: Install kvm virtualization
pacman:
name:
- virt-manager
- qemu-desktop
- libvirt
- dmidecode
- edk2-ovmf
- dnsmasq
- samba
- 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: copy samba config
ansible.builtin.template:
src: smb.conf.j2
dest: /etc/samba/smb.conf
owner: root
group: root
mode: '0644'
- name: Enable libvirt service
ansible.builtin.systemd:
name: libvirtd
state: started
enabled: yes
- name: Enable samba service
ansible.builtin.systemd:
name: smb
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
name: jungle