From bdf7eb76a95df0c40b31b921b52dcc7101243e09 Mon Sep 17 00:00:00 2001 From: Major Hayden Date: Mon, 6 Feb 2017 08:56:14 -0600 Subject: [PATCH] Combine package install tasks This patch brings over the one-task package installation pattern from the security role and uses async to allow the package install to run while the virtual environment is downloaded/extracted. This should hopefully save time during the gate jobs since the nova KVM package install is one of the longest package install jobs in OSA. It also uses Ansible 2.0's ability to use variables in task includes to avoid running a ton of skipped tasks. Change-Id: I1e9259413d14670cf7f5bbc46eacc15837982779 --- tasks/main.yml | 5 + tasks/nova_compute.yml | 14 +-- tasks/nova_compute_powervm_install.yml | 15 --- tasks/nova_compute_qemu.yml | 1 + tasks/nova_install.yml | 127 +++---------------------- tasks/nova_install_apt.yml | 54 +++++++++++ tasks/nova_install_yum.yml | 35 +++++++ vars/common.yml | 30 ++++++ 8 files changed, 140 insertions(+), 141 deletions(-) create mode 120000 tasks/nova_compute_qemu.yml create mode 100644 tasks/nova_install_apt.yml create mode 100644 tasks/nova_install_yum.yml create mode 100644 vars/common.yml diff --git a/tasks/main.yml b/tasks/main.yml index 33d4973e..0ac561c2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -24,6 +24,11 @@ tags: - always +- name: Gather variables that apply to all operating systems + include_vars: common.yml + tags: + - always + - name: Fail when virt type is unsupported fail: msg="Unsupported Virt Type Provided {{ nova_supported_virt_types }}" when: diff --git a/tasks/nova_compute.yml b/tasks/nova_compute.yml index ea22d373..083690d7 100644 --- a/tasks/nova_compute.yml +++ b/tasks/nova_compute.yml @@ -13,17 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -- include: nova_compute_kvm.yml - when: nova_virt_type == 'kvm' or nova_virt_type == 'qemu' - -- include: nova_compute_powervm.yml - when: nova_virt_type == 'powervm' - -- include: nova_compute_lxd.yml - when: nova_virt_type == 'lxd' - -- include: nova_compute_ironic.yml - when: nova_virt_type == 'ironic' +- include: "nova_compute_{{ nova_virt_type }}.yml" tags: - nova-install @@ -33,4 +23,4 @@ - include: nova_compute_key_distribute.yml tags: - - nova-config \ No newline at end of file + - nova-config diff --git a/tasks/nova_compute_powervm_install.yml b/tasks/nova_compute_powervm_install.yml index 60cff12f..cfacc07a 100644 --- a/tasks/nova_compute_powervm_install.yml +++ b/tasks/nova_compute_powervm_install.yml @@ -38,21 +38,6 @@ tags: - novalink-repo -- name: Install apt packages - apt: - pkg: "{{ item }}" - state: "{{ nova_package_state }}" - update_cache: yes - cache_valid_time: "{{ cache_timeout }}" - register: install_packages - until: install_packages|success - retries: 5 - delay: 2 - with_items: "{{ nova_compute_powervm_distro_packages }}" - tags: - - nova-apt-packages - - nova-compute-powervm-apt-packages - - name: Register pypowervm module path (venv) command: python -c 'import pypowervm; print pypowervm.__file__' changed_when: false diff --git a/tasks/nova_compute_qemu.yml b/tasks/nova_compute_qemu.yml new file mode 120000 index 00000000..24e6a4ff --- /dev/null +++ b/tasks/nova_compute_qemu.yml @@ -0,0 +1 @@ +nova_compute_kvm.yml \ No newline at end of file diff --git a/tasks/nova_install.yml b/tasks/nova_install.yml index 9fcfcb9b..2c5e683c 100644 --- a/tasks/nova_install.yml +++ b/tasks/nova_install.yml @@ -13,62 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Ensure apt cache is up to date - apt: - update_cache: yes - cache_valid_time: "{{ cache_timeout }}" - when: - - ansible_pkg_mgr == 'apt' - -- name: Add Ubuntu Cloud Archive key package - package: - name: ubuntu-cloud-keyring - state: "{{ nova_package_state }}" - when: - - nova_uca_enable - - ansible_pkg_mgr == 'apt' - register: nova_uca_add_keys - tags: - - add-apt-keys - -- name: Add Ubuntu Cloud Archive apt repository - apt_repository: - repo: "{{ uca_repo }}" - state: present - update_cache: yes - filename: "{{ uca_apt_source_list_filename | default(omit) }}" - register: nova_uca_add_repo - when: - - nova_uca_enable - - ansible_pkg_mgr == 'apt' - until: add_repo|success - retries: 5 - delay: 2 - tags: - - add-uca-repo - -- name: Install RDO package - package: - name: "{{ rdo_package }}" - state: "present" - register: install_cloud_rdo_package - until: install_cloud_rdo_package | success - retries: 5 - delay: 2 - when: - - ansible_pkg_mgr == 'yum' - -- name: Install distro packages - package: - name: "{{ item }}" - state: "{{ nova_package_state }}" - register: install_packages - until: install_packages|success - retries: 5 - delay: 2 - with_items: "{{ nova_distro_packages }}" - tags: - - nova-apt-packages +- include: "nova_install_{{ ansible_pkg_mgr }}.yml" - name: Remove known problem packages for the Spice console package: @@ -86,54 +31,6 @@ - nova-apt-packages - nova-spice-apt-packages -- name: Install distro packages (novnc console) - package: - name: "{{ item }}" - state: "{{ nova_package_state }}" - register: install_packages - until: install_packages|success - retries: 5 - delay: 2 - with_items: "{{ nova_novnc_distro_packages }}" - when: - - inventory_hostname in groups['nova_console'] - - nova_console_type == "novnc" - tags: - - nova-apt-packages - - nova-novnc-apt-packages - -- name: Install distro packages (compute - KVM) - package: - name: "{{ item }}" - state: "{{ nova_package_state }}" - register: install_packages - until: install_packages|success - retries: 5 - delay: 2 - with_items: "{{ nova_compute_kvm_distro_packages }}" - when: - - inventory_hostname in groups['nova_compute'] - - nova_virt_type == 'kvm' or nova_virt_type == 'qemu' - tags: - - nova-apt-packages - - nova-compute-kvm-apt-packages - -- name: Install distro packages (compute - LXD) - package: - name: "{{ item }}" - state: "{{ nova_package_state }}" - register: install_packages - until: install_packages|success - retries: 5 - delay: 2 - with_items: "{{ nova_compute_lxd_distro_packages }}" - when: - - inventory_hostname in groups['nova_compute'] - - nova_virt_type == 'lxd' - tags: - - nova-apt-packages - - nova-compute-lxd-apt-packages - - name: Create developer mode constraint file copy: dest: "/opt/developer-pip-constraints.txt" @@ -145,7 +42,7 @@ tags: - nova-pip-packages -- name: Install requires pip packages +- name: Install required pip packages pip: name: "{{ nova_requires_pip_packages }}" state: "{{ nova_pip_package_state }}" @@ -230,16 +127,18 @@ tags: - nova-pip-packages -- include: nova_console_spice_install.yml - when: - - inventory_hostname in groups['nova_console'] - - nova_console_type == "spice" - tags: - - nova-spice-console +- 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: nova_console_novnc_install.yml +- include: "nova_console_{{ nova_console_type }}_install.yml" when: - - inventory_hostname in groups['nova_console'] - - nova_console_type == "novnc" + - "{{ 'nova_console' in group_names }}" tags: - nova-novnc-console + - nova-spice-console diff --git a/tasks/nova_install_apt.yml b/tasks/nova_install_apt.yml new file mode 100644 index 00000000..667918d6 --- /dev/null +++ b/tasks/nova_install_apt.yml @@ -0,0 +1,54 @@ +--- +# 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: Ensure apt cache is up to date + apt: + update_cache: yes + cache_valid_time: "{{ cache_timeout }}" + +- name: Add Ubuntu Cloud Archive key package + package: + name: ubuntu-cloud-keyring + state: "{{ nova_package_state }}" + when: + - nova_uca_enable + register: nova_uca_add_keys + tags: + - add-apt-keys + +- name: Add Ubuntu Cloud Archive apt repository + apt_repository: + repo: "{{ uca_repo }}" + state: present + update_cache: yes + filename: "{{ uca_apt_source_list_filename | default(omit) }}" + register: nova_uca_add_repo + when: + - nova_uca_enable + until: add_repo|success + retries: 5 + delay: 2 + tags: + - add-uca-repo + +- name: Install nova role packages (apt) + apt: + name: "{{ item }}" + state: "{{ nova_package_state }}" + with_items: + - "{{ nova_packages_list | selectattr('enabled') | sum(attribute='packages', start=[]) }}" + register: install_nova_role_packages + async: 600 + poll: 0 diff --git a/tasks/nova_install_yum.yml b/tasks/nova_install_yum.yml new file mode 100644 index 00000000..1975c679 --- /dev/null +++ b/tasks/nova_install_yum.yml @@ -0,0 +1,35 @@ +--- +# 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 RDO package + package: + name: "{{ rdo_package }}" + state: "present" + register: install_cloud_rdo_package + until: install_cloud_rdo_package | success + retries: 5 + delay: 2 + when: + - ansible_pkg_mgr == 'yum' + +- name: Install nova role packages (yum) + yum: + name: "{{ item }}" + state: "{{ nova_package_state }}" + with_items: + - "{{ nova_packages_list | selectattr('enabled') | sum(attribute='packages', start=[]) }}" + register: install_nova_role_packages + async: 600 + poll: 0 diff --git a/vars/common.yml b/vars/common.yml new file mode 100644 index 00000000..db5e261a --- /dev/null +++ b/vars/common.yml @@ -0,0 +1,30 @@ +--- +# 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. + +# 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: yes