Skip to content

Commit 8592da4

Browse files
committed
libvirt: support SASL authentication
Adds support for SASL authentication of libvirt TCP and TLS connections when using a compute host libvirt daemon. In line with the dependent Kolla Ansible patch, we enable SASL by default, and use DIGEST-MD5 with TCP and SCRAM-SHA-256 with TLS. Depends-On: https://review.opendev.org/c/openstack/kolla-ansible/+/833022 Depends-On: stackhpc/ansible-role-libvirt-host#52 Story: 2009858 Task: 44735 Change-Id: Id3972c24022aeb6421494c3cccdc8e7cbce802e6 (cherry picked from commit f4493e4)
1 parent 3e22b44 commit 8592da4

File tree

10 files changed

+65
-4
lines changed

10 files changed

+65
-4
lines changed

ansible/compute-libvirt-host.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
vars:
2121
libvirt_host_libvirtd_conf: "{{ compute_libvirt_conf }}"
2222
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 }}"
2326
libvirt_host_tcp_listen: "{{ not compute_libvirt_enable_tls | bool }}"
2427
libvirt_host_tcp_listen_address: "{{ internal_net_name | net_ip }}:16509"
2528
libvirt_host_tls_listen: "{{ compute_libvirt_enable_tls | bool }}"

ansible/group_vars/all/compute

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ compute_libvirt_enabled: "{{ kolla_enable_nova | bool and not kolla_enable_nova_
165165
# A dict of default configuration options to write to
166166
# /etc/libvirt/libvirtd.conf.
167167
compute_libvirt_conf_default:
168-
auth_tcp: "none"
168+
auth_tcp: "{{ 'sasl' if compute_libvirt_enable_sasl | bool else 'none' }}"
169+
auth_tls: "{{ 'sasl' if compute_libvirt_enable_sasl | bool else 'none' }}"
169170
log_level: "{{ compute_libvirtd_log_level }}"
170171

171172
# A dict of additional configuration options to write to
@@ -195,6 +196,12 @@ compute_qemu_conf_extra: {}
195196
# compute_qemu_conf_extra.
196197
compute_qemu_conf: "{{ compute_qemu_conf_default | combine(compute_qemu_conf_extra) }}"
197198

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+
198205
# Whether to enable a libvirt TLS listener. Default is false.
199206
compute_libvirt_enable_tls: false
200207

ansible/group_vars/all/kolla

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,9 @@ kolla_enable_zun: "no"
590590
###############################################################################
591591
# Passwords and credentials.
592592

593-
# Dictionary containing default custom passwords to add or override in the
593+
# Dictionary containing base custom passwords to add or override in the
594594
# Kolla passwords file.
595-
kolla_ansible_default_custom_passwords:
595+
kolla_ansible_base_custom_passwords:
596596
# SSH key authorized in hosts deployed by Bifrost.
597597
bifrost_ssh_key:
598598
private_key: "{{ lookup('file', ssh_private_key_path) }}"
@@ -603,6 +603,19 @@ kolla_ansible_default_custom_passwords:
603603
public_key: "{{ lookup('file', ssh_public_key_path) }}"
604604
docker_registry_password: "{{ kolla_docker_registry_password }}"
605605

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+
606619
# Dictionary containing custom passwords to add or override in the Kolla
607620
# passwords file.
608621
kolla_ansible_custom_passwords: "{{ kolla_ansible_default_custom_passwords }}"

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ kolla_nova_compute_ironic_host:
233233

234234
kolla_libvirt_tls:
235235

236+
kolla_libvirt_enable_sasl:
237+
236238
###############################################################################
237239
# Extra free-form configuraton.
238240

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,9 @@ enable_{{ feature_flag }}: {{ hostvars[inventory_hostname]['kolla_enable_' ~ fea
379379
libvirt_tls: {{ kolla_libvirt_tls | bool }}
380380
{% endif %}
381381

382+
{% if kolla_libvirt_enable_sasl is not none %}
383+
libvirt_enable_sasl: {{ kolla_libvirt_enable_sasl | bool }}
384+
{% endif %}
382385
#################
383386
# Hyper-V options
384387
#################

doc/source/configuration/reference/hosts.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,12 @@ are relevant only when using the libvirt daemon rather than the
899899
A dict of configuration options to write to ``/etc/libvirt/qemu.conf``.
900900
Default is a combination of ``compute_qemu_conf_default`` and
901901
``compute_qemu_conf_extra``.
902+
``compute_libvirt_enable_sasl``
903+
Whether to enable libvirt SASL authentication. Default is the same as
904+
``compute_libvirt_tcp_listen``.
905+
``compute_libvirt_sasl_password``
906+
libvirt SASL password. Default is unset. This must be defined when
907+
``compute_libvirt_enable_sasl`` is ``true``.
902908
``compute_libvirt_enable_tls``
903909
Whether to enable a libvirt TLS listener. Default is false.
904910
``compute_libvirt_ceph_repo_install``
@@ -930,6 +936,24 @@ To customise QEMU to avoid adding timestamps to logs:
930936
compute_qemu_conf_extra:
931937
log_timestamp: 0
932938
939+
Example: SASL
940+
-------------
941+
942+
SASL authentication is enabled by default. This provides authentication for
943+
TCP and TLS connections to the libvirt API. A password is required, and should
944+
be encrypted using Ansible Vault.
945+
946+
.. code-block:: yaml
947+
:caption: ``compute.yml``
948+
949+
compute_libvirt_sasl_password: !vault |
950+
$ANSIBLE_VAULT;1.1;AES256
951+
63363937303539373738356236393563636466313130633435353933613637343231303836343933
952+
3463623265653030323665383337376462363434396361320a653737376237353261303066616637
953+
66613562316533313632613433643537346463303363376664396661343835373033326261383065
954+
3731643633656636360a623534313665343066656161333866613338313266613465336332376463
955+
3234
956+
933957
Example: enabling libvirt TLS listener
934958
--------------------------------------
935959

playbooks/kayobe-overcloud-base/overrides.yml.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ pip_trusted_hosts:
3131
aio_bridge_ports:
3232
- dummy1
3333

34+
# Generate a password for libvirt SASL authentication.
35+
compute_libvirt_sasl_password: "{% raw %}{{ lookup('password', '/tmp/libvirt-sasl-password') }}{% endraw %}"
36+
3437
# Enable ironic for testing baremetal compute.
3538
kolla_enable_ironic: true
3639

playbooks/kayobe-overcloud-host-configure-base/overrides.yml.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,6 @@ chrony_ntp_servers:
130130
options:
131131
- option: maxsources
132132
val: 2
133+
134+
# Generate a password for libvirt SASL authentication.
135+
compute_libvirt_sasl_password: "{% raw %}{{ lookup('password', '/tmp/libvirt-sasl-password') }}{% endraw %}"

playbooks/kayobe-overcloud-upgrade-base/overrides.yml.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ pip_index_url: "http://{{ zuul_site_mirror_fqdn }}/pypi/simple"
3030
aio_bridge_ports:
3131
- dummy1
3232

33+
# Generate a password for libvirt SASL authentication.
34+
compute_libvirt_sasl_password: "{% raw %}{{ lookup('password', '/tmp/libvirt-sasl-password') }}{% endraw %}"
35+
3336
# Enable ironic for testing baremetal compute.
3437
kolla_enable_ironic: true
3538

requirements.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ roles:
2626
- src: stackhpc.grafana-conf
2727
version: 1.1.1
2828
- src: stackhpc.libvirt-host
29-
version: v1.10.0
29+
version: v1.11.0
3030
- src: stackhpc.libvirt-vm
3131
version: v1.14.2
3232
- src: stackhpc.luks

0 commit comments

Comments
 (0)