Skip to content

Commit e0f2650

Browse files
authored
Merge pull request #232 from stackhpc/libvirt-on-host
Support running libvirt as a host daemon
2 parents 7961423 + 8592da4 commit e0f2650

File tree

27 files changed

+545
-25
lines changed

27 files changed

+545
-25
lines changed

ansible/compute-libvirt-host.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
- name: Ensure the libvirt daemon is configured
3+
hosts: compute
4+
tags:
5+
- libvirt-host
6+
tasks:
7+
- name: Ensure Ceph package repository is available
8+
package:
9+
name: "centos-release-ceph-{{ compute_libvirt_ceph_repo_release }}"
10+
state: present
11+
when:
12+
- compute_libvirt_enabled | bool
13+
- ansible_facts.distribution in ['CentOS', 'Rocky']
14+
- compute_libvirt_ceph_repo_install | bool
15+
become: true
16+
17+
- name: Include stackhpc.libvirt-host role
18+
include_role:
19+
name: stackhpc.libvirt-host
20+
vars:
21+
libvirt_host_libvirtd_conf: "{{ compute_libvirt_conf }}"
22+
libvirt_host_qemu_conf: "{{ compute_qemu_conf }}"
23+
libvirt_host_enable_sasl_support: "{{ compute_libvirt_enable_sasl | bool }}"
24+
libvirt_host_sasl_authname: nova
25+
libvirt_host_sasl_password: "{{ compute_libvirt_sasl_password }}"
26+
libvirt_host_tcp_listen: "{{ not compute_libvirt_enable_tls | bool }}"
27+
libvirt_host_tcp_listen_address: "{{ internal_net_name | net_ip }}:16509"
28+
libvirt_host_tls_listen: "{{ compute_libvirt_enable_tls | bool }}"
29+
libvirt_host_tls_listen_address: "{{ internal_net_name | net_ip }}:16514"
30+
# TLS server and client certificates.
31+
libvirt_host_tls_server_cert: >-
32+
{{ lookup('file', lookup('first_found', lookup_params | combine({'files': ['servercert.pem']})))
33+
if libvirt_host_tls_listen | default(False) | bool else '' }}
34+
libvirt_host_tls_server_key: >-
35+
{{ lookup('file', lookup('first_found', lookup_params | combine({'files': ['serverkey.pem']})))
36+
if libvirt_host_tls_listen | default(False) | bool else '' }}
37+
libvirt_host_tls_client_cert: >-
38+
{{ lookup('file', lookup('first_found', lookup_params | combine({'files': ['clientcert.pem']})))
39+
if libvirt_host_tls_listen | default(False) | bool else '' }}
40+
libvirt_host_tls_client_key: >-
41+
{{ lookup('file', lookup('first_found', lookup_params | combine({'files': ['clientkey.pem']})))
42+
if libvirt_host_tls_listen | default(False) | bool else '' }}
43+
libvirt_host_tls_cacert: >-
44+
{{ lookup('file', lookup('first_found', lookup_params | combine({'files': ['cacert.pem']})))
45+
if libvirt_host_tls_listen | default(False) | bool else '' }}
46+
lookup_params:
47+
paths: "{{ libvirt_tls_cert_paths }}"
48+
skip: true
49+
# Support loading libvirt TLS certificates & keys from per-host and
50+
# global locations.
51+
libvirt_tls_cert_paths: >-
52+
{{ (libvirt_tls_cert_dirs | unique | product([inventory_hostname]) | map('path_join') | list +
53+
libvirt_tls_cert_dirs | unique | list) | list }}
54+
libvirt_tls_cert_dirs:
55+
- "{{ kayobe_env_config_path }}/certificates/libvirt"
56+
- "{{ kayobe_config_path }}/certificates/libvirt"
57+
libvirt_host_enable_efi_support: true
58+
when:
59+
- compute_libvirt_enabled | bool

ansible/group_vars/all/compute

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,61 @@ compute_firewalld_default_zone:
154154
# - permanent: true
155155
# - state: enabled
156156
compute_firewalld_rules: []
157+
158+
###############################################################################
159+
# Compute node host libvirt configuration.
160+
161+
# Whether to enable a host libvirt daemon. Default is true if kolla_enable_nova
162+
# is true and kolla_enable_nova_libvirt_container is false.
163+
compute_libvirt_enabled: "{{ kolla_enable_nova | bool and not kolla_enable_nova_libvirt_container | bool }}"
164+
165+
# A dict of default configuration options to write to
166+
# /etc/libvirt/libvirtd.conf.
167+
compute_libvirt_conf_default:
168+
auth_tcp: "{{ 'sasl' if compute_libvirt_enable_sasl | bool else 'none' }}"
169+
auth_tls: "{{ 'sasl' if compute_libvirt_enable_sasl | bool else 'none' }}"
170+
log_level: "{{ compute_libvirtd_log_level }}"
171+
172+
# A dict of additional configuration options to write to
173+
# /etc/libvirt/libvirtd.conf.
174+
compute_libvirt_conf_extra: {}
175+
176+
# A dict of configuration options to write to /etc/libvirt/libvirtd.conf.
177+
# Default is a combination of compute_libvirt_conf_default and
178+
# compute_libvirt_conf_extra.
179+
compute_libvirt_conf: "{{ compute_libvirt_conf_default | combine(compute_libvirt_conf_extra) }}"
180+
181+
# Numerical log level for libvirtd. Default is 3.
182+
compute_libvirtd_log_level: 3
183+
184+
# A dict of default configuration options to write to
185+
# /etc/libvirt/qemu.conf.
186+
compute_qemu_conf_default:
187+
max_files: 32768
188+
max_processes: 131072
189+
190+
# A dict of additional configuration options to write to
191+
# /etc/libvirt/qemu.conf.
192+
compute_qemu_conf_extra: {}
193+
194+
# A dict of configuration options to write to /etc/libvirt/qemu.conf.
195+
# Default is a combination of compute_qemu_conf_default and
196+
# compute_qemu_conf_extra.
197+
compute_qemu_conf: "{{ compute_qemu_conf_default | combine(compute_qemu_conf_extra) }}"
198+
199+
# Whether to enable libvirt SASL authentication. Default is true.
200+
compute_libvirt_enable_sasl: true
201+
202+
# libvirt SASL password. Default is unset.
203+
compute_libvirt_sasl_password:
204+
205+
# Whether to enable a libvirt TLS listener. Default is false.
206+
compute_libvirt_enable_tls: false
207+
208+
# Whether to install a Ceph package repository on CentOS and Rocky hosts.
209+
# Default is true.
210+
compute_libvirt_ceph_repo_install: true
211+
212+
# Ceph package repository release to install on CentOS and Rocky hosts when
213+
# compute_libvirt_ceph_repo_install is true. Default is 'pacific'.
214+
compute_libvirt_ceph_repo_release: pacific

ansible/group_vars/all/kolla

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ kolla_enable_murano: "no"
559559
kolla_enable_neutron_mlnx: "no"
560560
kolla_enable_neutron_provider_networks: "no"
561561
kolla_enable_neutron_sriov: "no"
562+
kolla_enable_nova_libvirt_container: "yes"
562563
kolla_enable_octavia: "no"
563564
kolla_enable_openvswitch: "{{ kolla_enable_neutron | bool }}"
564565
kolla_enable_ovn: "no"
@@ -589,9 +590,9 @@ kolla_enable_zun: "no"
589590
###############################################################################
590591
# Passwords and credentials.
591592

592-
# Dictionary containing default custom passwords to add or override in the
593+
# Dictionary containing base custom passwords to add or override in the
593594
# Kolla passwords file.
594-
kolla_ansible_default_custom_passwords:
595+
kolla_ansible_base_custom_passwords:
595596
# SSH key authorized in hosts deployed by Bifrost.
596597
bifrost_ssh_key:
597598
private_key: "{{ lookup('file', ssh_private_key_path) }}"
@@ -602,6 +603,19 @@ kolla_ansible_default_custom_passwords:
602603
public_key: "{{ lookup('file', ssh_public_key_path) }}"
603604
docker_registry_password: "{{ kolla_docker_registry_password }}"
604605

606+
# Dictionary containing libvirt custom passwords to add or override in the
607+
# Kolla passwords file.
608+
kolla_ansible_libvirt_custom_passwords:
609+
libvirt_sasl_password: "{{ compute_libvirt_sasl_password }}"
610+
611+
# Dictionary containing default custom passwords to add or override in the
612+
# Kolla passwords file.
613+
kolla_ansible_default_custom_passwords: >-
614+
{{ kolla_ansible_base_custom_passwords |
615+
combine(kolla_ansible_libvirt_custom_passwords
616+
if compute_libvirt_enabled | bool and compute_libvirt_enable_sasl | bool
617+
else {}) }}
618+
605619
# Dictionary containing custom passwords to add or override in the Kolla
606620
# passwords file.
607621
kolla_ansible_custom_passwords: "{{ kolla_ansible_default_custom_passwords }}"

ansible/kolla-ansible.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
kolla_inspector_netmask: "{{ inspection_net_name | net_mask }}"
104104
kolla_inspector_default_gateway: "{{ inspection_net_name | net_inspection_gateway or inspection_net_name | net_gateway }}"
105105
kolla_inspector_extra_kernel_options: "{{ inspector_extra_kernel_options }}"
106+
kolla_libvirt_tls: "{{ compute_libvirt_enable_tls | bool }}"
106107
kolla_enable_host_ntp: false
107108
docker_daemon_mtu: "{{ public_net_name | net_mtu | default }}"
108109
kolla_globals_paths_extra:

ansible/kolla-openstack.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,5 @@
246246
kolla_extra_sahara: "{{ kolla_extra_config.sahara | default }}"
247247
kolla_extra_zookeeper: "{{ kolla_extra_config.zookeeper | default }}"
248248
kolla_extra_config_path: "{{ kayobe_env_config_path }}/kolla/config"
249+
kolla_libvirt_tls: "{{ compute_libvirt_enable_tls | bool }}"
250+
kolla_nova_libvirt_certificates_src: "{{ kayobe_env_config_path }}/certificates/libvirt"

ansible/roles/kolla-ansible/defaults/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ kolla_openstack_logging_debug:
231231
# controllers.
232232
kolla_nova_compute_ironic_host:
233233

234+
kolla_libvirt_tls:
235+
236+
kolla_libvirt_enable_sasl:
237+
234238
###############################################################################
235239
# Extra free-form configuraton.
236240

ansible/roles/kolla-ansible/templates/kolla/globals.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,13 @@ enable_{{ feature_flag }}: {{ hostvars[inventory_hostname]['kolla_enable_' ~ fea
375375
# Valid options are [ none, novnc, spice, rdp ]
376376
#nova_console: "novnc"
377377

378+
{% if kolla_libvirt_tls is not none %}
379+
libvirt_tls: {{ kolla_libvirt_tls | bool }}
380+
{% endif %}
381+
382+
{% if kolla_libvirt_enable_sasl is not none %}
383+
libvirt_enable_sasl: {{ kolla_libvirt_enable_sasl | bool }}
384+
{% endif %}
378385
#################
379386
# Hyper-V options
380387
#################

ansible/roles/kolla-ansible/vars/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ kolla_feature_flags:
181181
- nova
182182
- nova_fake
183183
- nova_horizon_policy_file
184+
- nova_libvirt_container
184185
- nova_serialconsole_proxy
185186
- nova_ssh
186187
- octavia

ansible/roles/kolla-openstack/defaults/main.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,19 @@ kolla_extra_neutron_ml2:
447447
# Whether to enable Nova.
448448
kolla_enable_nova:
449449

450+
# Whether to enable Nova libvirt container.
451+
kolla_enable_nova_libvirt_container:
452+
450453
# Free form extra configuration to append to nova.conf.
451454
kolla_extra_nova:
452455

456+
# Whether libvirt TLS is enabled.
457+
kolla_libvirt_tls:
458+
459+
# Directory containing libvirt certificates for nova-compute when running
460+
# libvirt on the host.
461+
kolla_nova_libvirt_certificates_src:
462+
453463
###############################################################################
454464
# Octavia configuration.
455465

ansible/roles/kolla-openstack/molecule/enable-everything/molecule.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ provisioner:
1515
inventory:
1616
group_vars:
1717
all:
18-
kolla_extra_config_path:
18+
kolla_extra_config_path: ${MOLECULE_TEMP_PATH:-/tmp}/molecule/kolla/config
1919
kolla_enable_aodh: true
2020
kolla_extra_aodh: |
2121
[extra-aodh.conf]
@@ -116,9 +116,12 @@ provisioner:
116116
[extra-ml2_conf.ini]
117117
foo=bar
118118
kolla_enable_nova: true
119+
kolla_enable_nova_libvirt_container: false
119120
kolla_extra_nova: |
120121
[extra-nova.conf]
121122
foo=bar
123+
kolla_libvirt_tls: true
124+
kolla_nova_libvirt_certificates_src: ${MOLECULE_TEMP_PATH:-/tmp}/molecule/nova-libvirt/certificates
122125
kolla_enable_octavia: true
123126
kolla_extra_octavia: |
124127
[extra-octavia.conf]

0 commit comments

Comments
 (0)