2020-02-09 03:49:25 +00:00
|
|
|
- name: Install QEMU/KVM
|
2023-05-04 03:42:55 +00:00
|
|
|
ansible.builtin.apt:
|
2020-02-09 03:49:25 +00:00
|
|
|
name: qemu-kvm
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Install Libvirt
|
2023-05-04 03:42:55 +00:00
|
|
|
ansible.builtin.apt:
|
2020-02-09 03:49:25 +00:00
|
|
|
name: ["libvirt-clients", "libvirt-daemon-system"]
|
|
|
|
state: present
|
|
|
|
|
2020-06-30 05:25:53 +00:00
|
|
|
- name: Add users to libvirt group
|
2023-05-04 03:42:55 +00:00
|
|
|
ansible.builtin.user:
|
2020-06-30 04:55:35 +00:00
|
|
|
name: "{{ item }}"
|
2020-02-09 03:49:25 +00:00
|
|
|
groups: libvirt
|
|
|
|
append: yes
|
2020-06-30 04:55:35 +00:00
|
|
|
with_items: "{{ libvirt_users }}"
|
|
|
|
when: libvirt_users is defined
|
2020-07-01 04:45:47 +00:00
|
|
|
|
2020-09-21 23:21:30 +00:00
|
|
|
- name: Check for NODOWNLOAD file
|
2023-05-04 03:42:55 +00:00
|
|
|
ansible.builtin.stat:
|
2020-09-21 23:21:30 +00:00
|
|
|
path: /var/lib/libvirt/images/NODOWNLOAD
|
|
|
|
register: NODOWNLOAD
|
|
|
|
|
2020-07-01 04:45:47 +00:00
|
|
|
- name: Download GNU/Linux ISOs
|
2023-05-04 03:42:55 +00:00
|
|
|
ansible.builtin.get_url:
|
2020-07-01 04:45:47 +00:00
|
|
|
url: "{{ item.url }}"
|
|
|
|
dest: /var/lib/libvirt/images
|
|
|
|
checksum: "{{ item.hash }}"
|
|
|
|
owner: libvirt-qemu
|
|
|
|
group: libvirt-qemu
|
|
|
|
loop: "{{ libvirt_isos }}"
|
2020-09-21 23:21:30 +00:00
|
|
|
register: download_isos
|
|
|
|
when: libvirt_isos is defined and NODOWNLOAD.stat.exists == false
|
|
|
|
|
|
|
|
# Prevent downloaded ISOs from being rehashed every run
|
|
|
|
- name: Create NODOWNLOAD file
|
2023-05-04 03:42:55 +00:00
|
|
|
ansible.builtin.file:
|
2020-09-21 23:21:30 +00:00
|
|
|
path: /var/lib/libvirt/images/NODOWNLOAD
|
|
|
|
state: touch
|
|
|
|
when: download_isos.changed
|