From 3c573ae56488da0193624d9da7dc0a7dd9406b3b Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Thu, 8 Jun 2017 14:45:00 +0100 Subject: [PATCH] Normalise distro package installation This patch makes the distro package list compilation just a little easier to understand, and avoids the double evaluation of the variable. It also adds the spice distro package list which was missing. It also passes the package list directly to the package module instead of using a with_items loop and removes the nested inclusions for distro package installation. Finally, the async process for installing the packages is removed as it doesn't give much benefit in terms of speed and instead obscures the process a little. Change-Id: I910868db9780d9b56eabf5f059fe2f6d32719238 --- tasks/nova_install.yml | 23 ++++++++++-------- tasks/nova_install_apt.yml | 37 ---------------------------- tasks/nova_install_yum.yml | 26 -------------------- vars/main.yml | 50 ++++++++++++++++++++++++++------------ vars/redhat-7.yml | 4 ++- vars/ubuntu-16.04.yml | 6 ++--- 6 files changed, 54 insertions(+), 92 deletions(-) delete mode 100644 tasks/nova_install_apt.yml delete mode 100644 tasks/nova_install_yum.yml diff --git a/tasks/nova_install.yml b/tasks/nova_install.yml index 9eda22af..38d1c7d2 100644 --- a/tasks/nova_install.yml +++ b/tasks/nova_install.yml @@ -13,7 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -- include: "nova_install_{{ ansible_pkg_mgr }}.yml" +- name: Setup powervm repository + include: nova_install_apt_powervm.yml + when: + - "'nova_compute' in group_names" + - "nova_virt_type == 'powervm'" + - "ansible_pkg_mgr == 'apt'" + +- name: Install distro packages + package: + name: "{{ nova_package_list }}" + state: "{{ nova_package_state }}" + update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" + cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}" - name: Remove known problem packages for the Spice console package: @@ -145,15 +157,6 @@ tags: - nova-pip-packages -- name: Ensure distro packages are fully installed on all hosts - async_status: - jid: "{{ item.ansible_job_id }}" - register: install_nova_role_packages_async_job - until: install_nova_role_packages_async_job.finished - retries: 300 - with_items: - - "{{ install_nova_role_packages.results }}" - - include: "consoles/nova_console_{{ nova_console_type }}_install.yml" when: - "'nova_console' in group_names" diff --git a/tasks/nova_install_apt.yml b/tasks/nova_install_apt.yml deleted file mode 100644 index d139ab42..00000000 --- a/tasks/nova_install_apt.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -# Copyright 2017, Rackspace US, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Only PowerVM needs to load a separate file. Skip for the others. -- include: "{{ item }}" - with_first_found: - - files: - - "nova_install_apt_{{ nova_virt_type }}.yml" - skip: true - tags: - - nova-install - -- name: Install nova role packages (apt) - apt: - name: "{{ item }}" - state: "{{ nova_package_state }}" - update_cache: yes - cache_valid_time: "{{ cache_timeout }}" - with_items: - - "{{ nova_packages_list | selectattr('enabled') | sum(attribute='packages', start=[]) }}" - when: - - item != '' - register: install_nova_role_packages - async: 600 - poll: 0 diff --git a/tasks/nova_install_yum.yml b/tasks/nova_install_yum.yml deleted file mode 100644 index 84f9ea63..00000000 --- a/tasks/nova_install_yum.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -# Copyright 2017, Rackspace US, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -- name: Install nova role packages (yum) - yum: - name: "{{ item }}" - state: "{{ nova_package_state }}" - with_items: - - "{{ nova_packages_list | selectattr('enabled') | sum(attribute='packages', start=[]) }}" - when: - - item != '' - register: install_nova_role_packages - async: 600 - poll: 0 diff --git a/vars/main.yml b/vars/main.yml index 07ddd9d3..0d7392f2 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -13,22 +13,42 @@ # See the License for the specific language governing permissions and # limitations under the License. -# This special list brings together all of the package installations into one -# task to save time and allow for async to work. -nova_packages_list: - - packages: "{{ nova_distro_packages }}" - enabled: yes - - packages: "{{ nova_novnc_distro_packages }}" - enabled: "{{ 'nova_console' in group_names and nova_console_type == 'novnc' }}" - - packages: "{{ nova_compute_kvm_distro_packages }}" - enabled: "{{ 'nova_compute' in group_names and nova_virt_type in ['kvm', 'qemu'] }}" - - packages: "{{ nova_compute_lxd_distro_packages }}" - enabled: "{{ 'nova_compute' in group_names and nova_virt_type == 'lxd' }}" - - packages: "{{ nova_compute_powervm_distro_packages }}" - enabled: "{{ 'nova_compute' in group_names and nova_virt_type == 'powervm' }}" - - packages: "{{ nova_nginx_distro_packages }}" - enabled: "{{ 'nova_api_placement' in group_names }}" +# +# Compile a list of the distro packages to install based on +# whether the host is in the host group and the service is +# enabled. +# +nova_package_list: |- + {% set packages = nova_distro_packages %} + {% if 'nova_console' in group_names %} + {% if nova_console_type == 'novnc' %} + {% set _ = packages.extend(nova_novnc_distro_packages) %} + {% endif %} + {% if nova_console_type == 'spice' %} + {% set _ = packages.extend(nova_spice_distro_packages) %} + {% endif %} + {% endif %} + {% if 'nova_compute' in group_names %} + {% if nova_virt_type in ['kvm', 'qemu'] %} + {% set _ = packages.extend(nova_compute_kvm_distro_packages) %} + {% elif nova_virt_type == 'lxd' %} + {% set _ = packages.extend(nova_compute_lxd_distro_packages) %} + {% elif nova_virt_type == 'powervm' %} + {% set _ = packages.extend(nova_compute_powervm_distro_packages) %} + {% endif %} + {% if nova_barbican_enabled | bool %} + {% set _ = packages.extend(nova_compute_barbican_distro_packages) %} + {% endif %} + {% endif %} + {% if 'nova_api_placement' in group_names %} + {% set _ = packages.extend(nova_nginx_distro_packages) %} + {% endif %} + {{ packages }} +# +# Compile a list of the services on a host based on whether +# the host is in the host group and the service is enabled. +# filtered_nova_services: > {%- set services = nova_services.copy() %} {%- for key,value in nova_services.items() %} diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml index f6a1656b..452bf84d 100644 --- a/vars/redhat-7.yml +++ b/vars/redhat-7.yml @@ -36,9 +36,11 @@ nova_novnc_distro_packages: - librabbitmq - libyaml +nova_compute_barbican_distro_packages: + - cryptsetup + nova_compute_kvm_distro_packages: - bridge-utils - - "{% if nova_barbican_enabled | bool %}cryptsetup{% endif %}" - device-mapper-multipath - dosfstools - genisoimage diff --git a/vars/ubuntu-16.04.yml b/vars/ubuntu-16.04.yml index 5bfeec56..a9d714bd 100644 --- a/vars/ubuntu-16.04.yml +++ b/vars/ubuntu-16.04.yml @@ -38,9 +38,11 @@ nova_novnc_distro_packages: - librabbitmq4 - libyaml-0-2 +nova_compute_barbican_distro_packages: + - cryptsetup + nova_compute_kvm_distro_packages: - bridge-utils - - "{% if nova_barbican_enabled | bool %}cryptsetup{% endif %}" - genisoimage - kpartx - libvirt-bin @@ -58,7 +60,6 @@ nova_compute_kvm_distro_packages: nova_compute_lxd_distro_packages: - bridge-utils - - "{% if nova_barbican_enabled | bool %}cryptsetup{% endif %}" - dosfstools - dosfstools-dbg - genisoimage @@ -78,7 +79,6 @@ nova_nginx_distro_packages: # nova powervm virt driver nova_compute_powervm_distro_packages: - bridge-utils - - "{% if nova_barbican_enabled | bool %}cryptsetup{% endif %}" - genisoimage - kpartx - open-iscsi