diff --git a/ansible/group_vars/libvirt b/ansible/group_vars/libvirt index 694a712..1002a1a 100644 --- a/ansible/group_vars/libvirt +++ b/ansible/group_vars/libvirt @@ -11,3 +11,22 @@ libvirt_pool_group: "{{ ansible_user_id }}" # By default, allow QEMU without hardware virtualisation since this is a # development tool. libvirt_require_vt: false + +# This determines the libvirt unix_sock_dir configuration option. You can set +# this option to the empty string if you want to use the default location. The +# main use case is to run multiple instances of libvirt side-by-side. +libvirt_custom_socket_path: "" + +# Sets the path to the libvirtd PID file. You will need to change this if you +# want to run multiple instances of the libvirt daemon side-by-side. +libvirt_custom_pid_path: >- + {%- if libvirt_custom_socket_path -%} + {{ libvirt_custom_socket_path }}/libvirt.pid + {%- endif -%} + +# This controls the libvirt connection URI. This value is used on commands run +# on the hypervisor (as opposed to remote connections). +libvirt_local_uri: >- + {%- if libvirt_custom_socket_path -%} + qemu+unix:///system?socket={{ libvirt_custom_socket_path }}/libvirt-sock + {%- endif %} diff --git a/ansible/host_setup.yml b/ansible/host_setup.yml index 398108e..e677aa8 100644 --- a/ansible/host_setup.yml +++ b/ansible/host_setup.yml @@ -29,6 +29,9 @@ owner: "{{ libvirt_pool_owner }}" group: "{{ libvirt_pool_group }}" libvirt_host_require_vt: "{{ libvirt_require_vt }}" + libvirt_host_uri: "{{ libvirt_local_uri }}" + libvirt_host_socket_dir: "{{ libvirt_custom_socket_path }}" + libvirt_host_pid_path: "{{ libvirt_custom_pid_path }}" - name: Set up Virtual BMC daemon include_role: diff --git a/ansible/node_bmc.yml b/ansible/node_bmc.yml index 3627e77..c91e33f 100644 --- a/ansible/node_bmc.yml +++ b/ansible/node_bmc.yml @@ -28,6 +28,7 @@ name: virtualbmc-domain vars: vbmc_domain: "{{ domain }}" + vbmc_libvirt_uri: "{{ libvirt_local_uri }}" vbmc_ipmi_address: "{{ ipmi_address }}" vbmc_ipmi_username: "{{ ipmi_username }}" vbmc_ipmi_password: "{{ ipmi_password }}" diff --git a/ansible/node_instantiation.yml b/ansible/node_instantiation.yml index 404e759..720e102 100644 --- a/ansible/node_instantiation.yml +++ b/ansible/node_instantiation.yml @@ -16,6 +16,7 @@ include_role: name: stackhpc.libvirt-vm vars: + libvirt_vm_uri: "{{ libvirt_local_uri }}" libvirt_vm_default_console_log_dir: "{{ log_directory }}" # Configure VM definitions for the Libvirt provider. # FIXME(w-miller): Set absent/present in tenks_schedule on a per-node diff --git a/ansible/roles/ironic-enrolment/tasks/node.yml b/ansible/roles/ironic-enrolment/tasks/node.yml index f87398d..7743d31 100644 --- a/ansible/roles/ironic-enrolment/tasks/node.yml +++ b/ansible/roles/ironic-enrolment/tasks/node.yml @@ -12,7 +12,12 @@ # The output format of this command gives two lines of header, followed by # (for each vNIC): # - command: /usr/bin/virsh domiflist '{{ node.name }}' + command: >- + /usr/bin/virsh + {% if uri %}-c {{ uri }}{% endif %} + domiflist '{{ node.name }}' + vars: + uri: "{{ hostvars[ironic_hypervisor].libvirt_local_uri }}" register: iflist_res changed_when: false become: true diff --git a/ansible/roles/virtualbmc-domain/defaults/main.yml b/ansible/roles/virtualbmc-domain/defaults/main.yml index 4ecc498..04f7f82 100644 --- a/ansible/roles/virtualbmc-domain/defaults/main.yml +++ b/ansible/roles/virtualbmc-domain/defaults/main.yml @@ -15,3 +15,5 @@ vbmc_log_directory: vbmc_virtualenv_path: # Whether the domain should be `present` or `absent` in Virtual BMC. vbmc_state: present +# libvirt connnection URI +vbmc_libvirt_uri: diff --git a/ansible/roles/virtualbmc-domain/tasks/main.yml b/ansible/roles/virtualbmc-domain/tasks/main.yml index 691b456..a664471 100644 --- a/ansible/roles/virtualbmc-domain/tasks/main.yml +++ b/ansible/roles/virtualbmc-domain/tasks/main.yml @@ -45,6 +45,7 @@ --username '{{ vbmc_ipmi_username }}' --password '{{ vbmc_ipmi_password }}' --address {{ vbmc_ipmi_address }} + {% if vbmc_libvirt_uri %} --libvirt-uri '{{vbmc_libvirt_uri}}'{% endif %} when: vbmc_state == 'present' become: true tags: diff --git a/releasenotes/notes/add-support-for-libvirt-connection-uri-10fd40407fb1cc53.yaml b/releasenotes/notes/add-support-for-libvirt-connection-uri-10fd40407fb1cc53.yaml new file mode 100644 index 0000000..98c8d6d --- /dev/null +++ b/releasenotes/notes/add-support-for-libvirt-connection-uri-10fd40407fb1cc53.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Adds support for setting the libvirt connection uri via the + ``libvirt_local_uri`` variable. See + `this story `_ + for details.