2019-06-09 00:11:06 -04:00
|
|
|
---
|
|
|
|
- name: install libvirt packages
|
|
|
|
apt:
|
|
|
|
name:
|
|
|
|
- libvirt-daemon-system
|
|
|
|
- qemu-kvm
|
|
|
|
- qemu-utils
|
|
|
|
- qemu-block-extra
|
|
|
|
- vhostmd
|
|
|
|
- ceph-common
|
2021-03-15 13:39:22 -04:00
|
|
|
- libguestfs-tools
|
2019-06-09 00:11:06 -04:00
|
|
|
state: latest
|
|
|
|
|
2019-06-21 11:40:53 -04:00
|
|
|
- name: add libvirt user to ceph group
|
|
|
|
user:
|
|
|
|
name: libvirt-qemu
|
|
|
|
groups: ceph
|
|
|
|
append: yes
|
|
|
|
|
2019-06-09 00:11:06 -04:00
|
|
|
- name: install libvirt configuration
|
|
|
|
template:
|
|
|
|
src: libvirt/{{ item }}.j2
|
|
|
|
dest: /etc/libvirt/{{ item }}
|
|
|
|
with_items:
|
|
|
|
- libvirtd.conf
|
|
|
|
- ceph-secret.xml
|
|
|
|
notify: restart libvirtd
|
|
|
|
|
2019-06-12 21:06:06 -04:00
|
|
|
- include: libvirt/bootstrap.yml
|
|
|
|
when: bootstrap is defined and bootstrap
|
|
|
|
run_once: yes
|
|
|
|
|
2019-06-11 13:30:55 -04:00
|
|
|
- name: get ceph libvirt secret key
|
|
|
|
command: ceph auth get-key client.libvirt
|
|
|
|
register: libvirt_key
|
|
|
|
|
2019-06-09 00:11:06 -04:00
|
|
|
- name: define ceph secret
|
|
|
|
command: virsh secret-define /etc/libvirt/ceph-secret.xml
|
|
|
|
ignore_errors: true
|
|
|
|
|
2019-06-11 13:30:55 -04:00
|
|
|
- name: set ceph libvirt secret value
|
2019-06-11 13:38:02 -04:00
|
|
|
command: virsh secret-set-value --secret {{ pvc_ceph_storage_secret_uuid }} --base64 {{ libvirt_key.stdout }}
|
2019-06-09 00:11:06 -04:00
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: configure libvirt for listening
|
|
|
|
replace:
|
|
|
|
dest: /etc/default/libvirtd
|
|
|
|
regexp: '#libvirtd_opts=""'
|
|
|
|
replace: 'libvirtd_opts="--listen"'
|
|
|
|
notify: restart libvirtd
|
|
|
|
|
2021-06-06 19:02:02 -04:00
|
|
|
- name: install systemd unit file (override default on Bullseye)
|
|
|
|
template:
|
|
|
|
src: libvirt/libvirtd.service.j2
|
|
|
|
dest: /etc/systemd/system/libvirtd.service
|
|
|
|
register: systemd
|
|
|
|
|
|
|
|
- name: reload systemd to apply changes
|
|
|
|
command: systemctl daemon-reload
|
|
|
|
when: systemd.changed
|
|
|
|
|
|
|
|
- name: start and enable services (not managed by PVC)
|
2020-01-07 10:45:12 -05:00
|
|
|
service:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: started
|
2021-06-06 19:02:02 -04:00
|
|
|
enabled: yes
|
2020-01-07 10:45:12 -05:00
|
|
|
with_items:
|
|
|
|
- vhostmd
|
|
|
|
|
2021-06-06 19:02:02 -04:00
|
|
|
- name: start but disable services (managed by PVC)
|
2019-06-09 00:11:06 -04:00
|
|
|
service:
|
|
|
|
name: "{{ item }}"
|
2021-06-06 19:02:02 -04:00
|
|
|
state: started
|
2019-06-09 00:11:06 -04:00
|
|
|
enabled: no
|
|
|
|
with_items:
|
|
|
|
- libvirtd
|
2019-06-12 21:06:06 -04:00
|
|
|
|
|
|
|
- meta: flush_handlers
|