Files

63 lines
1.3 KiB
YAML

---
- name: Install KVM and virtualization tools
package:
name:
- qemu-kvm
- libvirt-daemon-system
- libvirt-clients
- bridge-utils
- virtinst
- virt-manager
- libguestfs-tools
- xz-utils
state: present
when: ansible_facts['os_family'] == "Debian"
- name: Install KVM and virtualization tools (RedHat/Fedora)
package:
name:
- qemu-kvm
- libvirt
- virt-install
- virt-manager
- libguestfs-tools
- xz
state: present
when: ansible_facts['os_family'] == "RedHat"
- name: Install KVM and virtualization tools (Arch/CachyOS)
package:
name:
- qemu-full
- libvirt
- virt-manager
- iproute2
- libguestfs
- guestfs-tools
- xz
- dnsmasq
state: present
when: ansible_facts['os_family'] == "Archlinux"
- name: Ensure libvirtd is started and enabled
service:
name: libvirtd
state: started
enabled: yes
- name: Ensure KVM default network is active and autostarts
shell: |
virsh net-start default || true
virsh net-autostart default || true
become: yes
- name: Add current user to libvirt group
user:
name: "{{ ansible_facts['user_id'] }}"
groups: libvirt
append: yes
become: yes
ignore_errors: yes # Some distros use different group names (e.g., kvm)