From a74b076ff0be6ef0e7f284160d39bfcf2309acd3 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Sun, 22 Mar 2015 00:37:49 -0500 Subject: [PATCH] Updated nova logic to correct issues with addon devices The logic within the pre_tasks was too loose. The pre_tasks need to have a bit more restrictive conditionals. Additionall the `lxc-device add` command which is being used always exits 0 even when the device add fails. While the task does not have issues with running we should be making sure that our changes are being recoreded correctly. Closes-Bug: 1434945 Change-Id: Icb1707db6bde6c0a26af6bca21a1f88dc3c315a8 --- playbooks/os-nova-install.yml | 21 ++++++++++++++++--- .../roles/os_nova/tasks/nova_compute.yml | 4 +++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/playbooks/os-nova-install.yml b/playbooks/os-nova-install.yml index 5c99d99837..ef8d3d5309 100644 --- a/playbooks/os-nova-install.yml +++ b/playbooks/os-nova-install.yml @@ -32,8 +32,14 @@ for i in /dev/nbd*;do lxc-device -n {{ container_name }} add $i $i done + failed_when: false + register: device_add + changed_when: > + 'added' in device_add.stdout.lower() delegate_to: "{{ physical_host }}" - when: is_metal == false or is_metal == "False" + when: > + inventory_hostname in groups['nova_compute'] and + (is_metal == false or is_metal == "False") tags: - nova-kvm - nova-kvm-container-devices @@ -41,7 +47,9 @@ shell: | lxc-device -n {{ container_name }} add /dev/net/tun /dev/net/tun delegate_to: "{{ physical_host }}" - when: is_metal == false or is_metal == "False" + when: > + inventory_hostname in groups['nova_compute'] and + (is_metal == false or is_metal == "False") tags: - nova-kvm - nova-kvm-container-devices @@ -49,7 +57,14 @@ shell: | lxc-device -n {{ container_name }} add /dev/kvm /dev/kvm delegate_to: "{{ physical_host }}" - when: is_metal == false or is_metal == "False" + register: device_add + failed_when: false + changed_when: > + 'added' in device_add.stdout.lower() + when: > + inventory_hostname in groups['nova_compute'] and + (is_metal == false or is_metal == "False") and + nova_virt_type == 'kvm' tags: - nova-kvm - nova-kvm-container-devices diff --git a/playbooks/roles/os_nova/tasks/nova_compute.yml b/playbooks/roles/os_nova/tasks/nova_compute.yml index fd4b343271..4bd7d53c50 100644 --- a/playbooks/roles/os_nova/tasks/nova_compute.yml +++ b/playbooks/roles/os_nova/tasks/nova_compute.yml @@ -14,7 +14,9 @@ # limitations under the License. - include: nova_compute_kvm.yml - when: nova_virt_type == 'kvm' or nova_virt_type == 'qemu' + when: > + nova_virt_type == 'kvm' or + nova_virt_type == 'qemu' - include: nova_compute_key_create.yml