From a8b3c81942625ed0089db57d16870a446ea836a7 Mon Sep 17 00:00:00 2001 From: Michael Gugino Date: Fri, 2 Sep 2016 14:51:10 -0400 Subject: [PATCH] Add config template for qemu.conf Currently, qemu.conf is not tunable by OSA. However, the default config file for qemu.conf is typically all comments and is not frequently overwritten. This patch enables deployers to deploy a custom /etc/libvirt/qemu.conf config file by defining a dictionary qemu_conf_dict. config_template plugin is not used because the qemu.conf file does not have sections, thus putting values in [DEFAULT] is untested. Change-Id: I780951ef466d1a82168f1f787abf58aebfe95889 --- defaults/main.yml | 4 ++++ .../notes/add-qemu-conf-d42337dfd42bac6f.yaml | 4 ++++ tasks/nova_compute_kvm.yml | 13 +++++++++++++ templates/qemu.conf.j2 | 4 ++++ 4 files changed, 25 insertions(+) create mode 100644 releasenotes/notes/add-qemu-conf-d42337dfd42bac6f.yaml create mode 100644 templates/qemu.conf.j2 diff --git a/defaults/main.yml b/defaults/main.yml index be977b9c..b35913f2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -415,6 +415,10 @@ nova_compute_lxd_pip_packages: nova_qemu_user: libvirt-qemu nova_qemu_group: kvm +# Define the following variable to drop a replacement +# file for /etc/libvirt/qemu.conf +#qemu_conf_dict: {} + # This variable is used by the repo_build process to determine # which host group to check for members of before building the # pip packages required by this role. The value is picked up diff --git a/releasenotes/notes/add-qemu-conf-d42337dfd42bac6f.yaml b/releasenotes/notes/add-qemu-conf-d42337dfd42bac6f.yaml new file mode 100644 index 00000000..da48406a --- /dev/null +++ b/releasenotes/notes/add-qemu-conf-d42337dfd42bac6f.yaml @@ -0,0 +1,4 @@ +--- +features: + - The os_nova role can now deploy the a custom + /etc/libvirt/qemu.conf file by defining ``qemu_conf_dict``. diff --git a/tasks/nova_compute_kvm.yml b/tasks/nova_compute_kvm.yml index 1c7d62b1..bb6b3688 100644 --- a/tasks/nova_compute_kvm.yml +++ b/tasks/nova_compute_kvm.yml @@ -40,6 +40,19 @@ - nova-kvm - nova-libvirt +- name: Set qemu config + template: + src: "qemu.conf.j2" + dest: "/etc/libvirt/qemu.conf" + owner: "root" + group: "root" + mode: "0600" + when: qemu_conf_dict is defined + notify: Restart libvirt-bin + tags: + - nova-kvm + - nova-libvirt + - name: Set libvirt runtime options lineinfile: dest: "/etc/default/libvirt-bin" diff --git a/templates/qemu.conf.j2 b/templates/qemu.conf.j2 new file mode 100644 index 00000000..9a9934d4 --- /dev/null +++ b/templates/qemu.conf.j2 @@ -0,0 +1,4 @@ +# {{ ansible_managed }} +{% for key, value in qemu_conf_dict.iteritems() %} +{{ key }} = {{ value }} +{% endfor %}