libvirt role
This commit is contained in:
92
ansible/roles/libvirt-server/tasks/main.yml
Normal file
92
ansible/roles/libvirt-server/tasks/main.yml
Normal file
@ -0,0 +1,92 @@
|
||||
---
|
||||
- name: install libvirt server packages
|
||||
become: true
|
||||
community.general.pacman:
|
||||
name: "{{ libvirt_server_packages }}"
|
||||
state: latest
|
||||
update_cache: true
|
||||
reason: explicit
|
||||
when:
|
||||
- ansible_os_family == 'Arch'
|
||||
|
||||
- name: add user to libvirt group
|
||||
become: true
|
||||
ansible.builtin.user:
|
||||
name: "{{ ansible_user }}"
|
||||
groups: libvirt
|
||||
append: true
|
||||
|
||||
- name: start and enable libvirt service
|
||||
become: true
|
||||
ansible.builtin.service:
|
||||
name: libvirtd.service
|
||||
state: started
|
||||
enabled: yes
|
||||
|
||||
- name: define vm network
|
||||
community.libvirt.virt_net:
|
||||
name: "{{ libvirt_vm_network_name }}"
|
||||
command: define
|
||||
xml: '{{ lookup("template", "network.xml.j2") }}'
|
||||
|
||||
- name: build vm network
|
||||
community.libvirt.virt_net:
|
||||
name: "{{ libvirt_vm_network_name }}"
|
||||
command: build
|
||||
|
||||
- name: start vm network
|
||||
community.libvirt.virt_net:
|
||||
name: "{{ libvirt_vm_network_name }}"
|
||||
state: active
|
||||
autostart: true
|
||||
|
||||
- name: define zfs storage pool
|
||||
community.libvirt.virt_pool:
|
||||
name: "{{ libvirt_zfs_pool_name }}"
|
||||
command: define
|
||||
xml: '{{ lookup("template", "zfs.xml.j2") }}'
|
||||
|
||||
- name: build zfs storage pool
|
||||
community.libvirt.virt_pool:
|
||||
name: "{{ libvirt_zfs_pool_name }}"
|
||||
command: build
|
||||
|
||||
- name: start zfs storage pool
|
||||
community.libvirt.virt_pool:
|
||||
name: "{{ libvirt_zfs_pool_name }}"
|
||||
state: active
|
||||
autostart: true
|
||||
|
||||
- name: define iso storage pool
|
||||
community.libvirt.virt_pool:
|
||||
name: "{{ libvirt_iso_pool_name }}"
|
||||
command: define
|
||||
xml: '{{ lookup("template", "iso.xml.j2") }}'
|
||||
|
||||
- name: build iso storage pool
|
||||
community.libvirt.virt_pool:
|
||||
name: "{{ libvirt_iso_pool_name }}"
|
||||
command: build
|
||||
|
||||
- name: start iso storage pool
|
||||
community.libvirt.virt_pool:
|
||||
name: "{{ libvirt_iso_pool_name }}"
|
||||
state: active
|
||||
autostart: true
|
||||
|
||||
- name: define qcow storage pool
|
||||
community.libvirt.virt_pool:
|
||||
name: "{{ libvirt_qcow_pool_name }}"
|
||||
command: define
|
||||
xml: '{{ lookup("template", "qcow.xml.j2") }}'
|
||||
|
||||
- name: build qcow storage pool
|
||||
community.libvirt.virt_pool:
|
||||
name: "{{ libvirt_qcow_pool_name }}"
|
||||
command: build
|
||||
|
||||
- name: start qcow storage pool
|
||||
community.libvirt.virt_pool:
|
||||
name: "{{ libvirt_qcow_pool_name }}"
|
||||
state: active
|
||||
autostart: true
|
Reference in New Issue
Block a user