Skip to content

Commit 3e22b44

Browse files
committed
libvirt: deploy libvirt on the host
In some cases it may be desirable to run libvirt daemon on the host. For example, when mixing host and container OS distributions. This change makes it possible to disable the nova_libvirt container, by setting kolla_enable_nova_libvirt_container to false. The stackhpc.libvirt-host role is used in order to install and configure a libvirt daemon on compute hosts when kolla_enable_nova_libvirt_container is false. Depends-On: https://review.opendev.org/c/openstack/kolla-ansible/+/825357 Depends-On: https://review.opendev.org/c/openstack/kayobe-config-dev/+/829225 Depends-On: stackhpc/ansible-role-libvirt-host#51 Story: 2009858 Task: 44495 Change-Id: I73fef63fb886a9d543d2f4231fb009523495edb3 (cherry picked from commit c4b74f4)
1 parent 7961423 commit 3e22b44

File tree

25 files changed

+482
-23
lines changed

25 files changed

+482
-23
lines changed

ansible/compute-libvirt-host.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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_tcp_listen: "{{ not compute_libvirt_enable_tls | bool }}"
24+
libvirt_host_tcp_listen_address: "{{ internal_net_name | net_ip }}:16509"
25+
libvirt_host_tls_listen: "{{ compute_libvirt_enable_tls | bool }}"
26+
libvirt_host_tls_listen_address: "{{ internal_net_name | net_ip }}:16514"
27+
# TLS server and client certificates.
28+
libvirt_host_tls_server_cert: >-
29+
{{ lookup('file', lookup('first_found', lookup_params | combine({'files': ['servercert.pem']})))
30+
if libvirt_host_tls_listen | default(False) | bool else '' }}
31+
libvirt_host_tls_server_key: >-
32+
{{ lookup('file', lookup('first_found', lookup_params | combine({'files': ['serverkey.pem']})))
33+
if libvirt_host_tls_listen | default(False) | bool else '' }}
34+
libvirt_host_tls_client_cert: >-
35+
{{ lookup('file', lookup('first_found', lookup_params | combine({'files': ['clientcert.pem']})))
36+
if libvirt_host_tls_listen | default(False) | bool else '' }}
37+
libvirt_host_tls_client_key: >-
38+
{{ lookup('file', lookup('first_found', lookup_params | combine({'files': ['clientkey.pem']})))
39+
if libvirt_host_tls_listen | default(False) | bool else '' }}
40+
libvirt_host_tls_cacert: >-
41+
{{ lookup('file', lookup('first_found', lookup_params | combine({'files': ['cacert.pem']})))
42+
if libvirt_host_tls_listen | default(False) | bool else '' }}
43+
lookup_params:
44+
paths: "{{ libvirt_tls_cert_paths }}"
45+
skip: true
46+
# Support loading libvirt TLS certificates & keys from per-host and
47+
# global locations.
48+
libvirt_tls_cert_paths: >-
49+
{{ (libvirt_tls_cert_dirs | unique | product([inventory_hostname]) | map('path_join') | list +
50+
libvirt_tls_cert_dirs | unique | list) | list }}
51+
libvirt_tls_cert_dirs:
52+
- "{{ kayobe_env_config_path }}/certificates/libvirt"
53+
- "{{ kayobe_config_path }}/certificates/libvirt"
54+
libvirt_host_enable_efi_support: true
55+
when:
56+
- compute_libvirt_enabled | bool

ansible/group_vars/all/compute

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,54 @@ 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: "none"
169+
log_level: "{{ compute_libvirtd_log_level }}"
170+
171+
# A dict of additional configuration options to write to
172+
# /etc/libvirt/libvirtd.conf.
173+
compute_libvirt_conf_extra: {}
174+
175+
# A dict of configuration options to write to /etc/libvirt/libvirtd.conf.
176+
# Default is a combination of compute_libvirt_conf_default and
177+
# compute_libvirt_conf_extra.
178+
compute_libvirt_conf: "{{ compute_libvirt_conf_default | combine(compute_libvirt_conf_extra) }}"
179+
180+
# Numerical log level for libvirtd. Default is 3.
181+
compute_libvirtd_log_level: 3
182+
183+
# A dict of default configuration options to write to
184+
# /etc/libvirt/qemu.conf.
185+
compute_qemu_conf_default:
186+
max_files: 32768
187+
max_processes: 131072
188+
189+
# A dict of additional configuration options to write to
190+
# /etc/libvirt/qemu.conf.
191+
compute_qemu_conf_extra: {}
192+
193+
# A dict of configuration options to write to /etc/libvirt/qemu.conf.
194+
# Default is a combination of compute_qemu_conf_default and
195+
# compute_qemu_conf_extra.
196+
compute_qemu_conf: "{{ compute_qemu_conf_default | combine(compute_qemu_conf_extra) }}"
197+
198+
# Whether to enable a libvirt TLS listener. Default is false.
199+
compute_libvirt_enable_tls: false
200+
201+
# Whether to install a Ceph package repository on CentOS and Rocky hosts.
202+
# Default is true.
203+
compute_libvirt_ceph_repo_install: true
204+
205+
# Ceph package repository release to install on CentOS and Rocky hosts when
206+
# compute_libvirt_ceph_repo_install is true. Default is 'pacific'.
207+
compute_libvirt_ceph_repo_release: pacific

ansible/group_vars/all/kolla

Lines changed: 1 addition & 0 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"

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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ kolla_openstack_logging_debug:
231231
# controllers.
232232
kolla_nova_compute_ironic_host:
233233

234+
kolla_libvirt_tls:
235+
234236
###############################################################################
235237
# Extra free-form configuraton.
236238

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,10 @@ 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+
378382
#################
379383
# Hyper-V options
380384
#################

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)