From f7b96c022922a5c100e1e4ca86aea52a05a9dbf2 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Wed, 15 Jun 2016 22:36:13 +0100 Subject: [PATCH] Update role to use the Multi-Distro framework * The default apt packages have been moved the appropriate platform specific vars files. * Most apt related tasks have been moved into the common nova_install_apt task file which is only executed when apt is the package manager. * Vars with 'apt' in the name have been changed to be more generic. Implements: blueprint multi-platform-host Change-Id: Ie97c0379b18a9ecabf3e4c0148cb555771b04747 --- defaults/main.yml | 69 ----------- .../var-deprecations-417d87b9d386466a.yaml | 12 ++ tasks/main.yml | 3 +- tasks/nova_compute_kvm_install.yml | 53 -------- tasks/nova_compute_powervm_install.yml | 6 +- tasks/nova_console_install.yml | 28 ----- tasks/nova_console_novnc_install.yml | 32 ----- tasks/nova_console_spice_install.yml | 32 ----- tasks/nova_install.yml | 38 ++---- tasks/nova_install_apt.yml | 116 ++++++++++++++++++ vars/ubuntu-14.04.yml | 82 +++++++++++++ vars/ubuntu-16.04.yml | 83 ++++++++++++- 12 files changed, 310 insertions(+), 244 deletions(-) create mode 100644 releasenotes/notes/var-deprecations-417d87b9d386466a.yaml delete mode 100644 tasks/nova_console_install.yml create mode 100644 tasks/nova_install_apt.yml diff --git a/defaults/main.yml b/defaults/main.yml index 4fea1e42..9f59d97a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -19,9 +19,6 @@ nova_ceilometer_enabled: False ## Verbosity Options debug: False -## APT Cache options -cache_timeout: 600 - nova_git_repo: https://git.openstack.org/openstack/nova nova_git_install_branch: master nova_requirements_git_repo: https://git.openstack.org/openstack/requirements @@ -347,45 +344,9 @@ nova_service_names: - "{{ nova_consoleauth_program_name }}" - "{{ nova_novncproxy_program_name }}" -# Common apt packages -nova_apt_packages: - - genisoimage - - git - - libpq-dev - - iptables - -# Spice console apt packages -nova_spice_apt_packages: - - spice-html5 - -nova_novnc_apt_packages: - - libjs-jquery - - libjs-sphinxdoc - - libjs-underscore - - libjs-swfobject - - librabbitmq1 - - libyaml-0-2 - nova_novnc_pip_packages: - websockify -nova_compute_kvm_apt_packages: - - bridge-utils - - genisoimage - - kpartx - - libvirt-bin - - open-iscsi - - python-libguestfs - - python-libvirt - - qemu - - qemu-utils - - sysfsutils - - vlan - - nfs-common - - dosfstools - - dosfstools-dbg - - multipath-tools - # nova packages that must be installed before anything else nova_requires_pip_packages: - virtualenv @@ -416,35 +377,5 @@ nova_rootwrap_conf_overrides: {} nova_api_paste_ini_overrides: {} nova_policy_overrides: {} -# Ubuntu Cloud Archive variables -nova_uca_enable: True -uca_openstack_release: mitaka -uca_apt_repo_url: "http://ubuntu-cloud.archive.canonical.com/ubuntu" -uca_repo_dist: "{{ ansible_lsb.codename }}-updates/{{ uca_openstack_release }}" -uca_repo: "deb {{ uca_apt_repo_url }} {{ uca_repo_dist }} main" - -# nova powervm virt driver -nova_compute_powervm_apt_packages: - - bridge-utils - - genisoimage - - kpartx - - open-iscsi - - python-libguestfs - - sysfsutils - - vlan - - nfs-common - - dosfstools - - dosfstools-dbg - - multipath-tools - - pvm-novalink - nova_compute_powervm_pip_packages: - nova-powervm - -novalink_apt_repo: - repo: "deb [arch=ppc64el] ftp://public.dhe.ibm.com/systems/virtualization/Novalink/debian/ novalink_1.0.0 non-free" - state: "present" - -novalink_gpg_keys: - - url: "ftp://public.dhe.ibm.com/systems/virtualization/Novalink/debian/novalink-gpg-pub.key" - state: "present" diff --git a/releasenotes/notes/var-deprecations-417d87b9d386466a.yaml b/releasenotes/notes/var-deprecations-417d87b9d386466a.yaml new file mode 100644 index 00000000..13952a82 --- /dev/null +++ b/releasenotes/notes/var-deprecations-417d87b9d386466a.yaml @@ -0,0 +1,12 @@ +--- +deprecations: + - | + The following variables have been renamed in order to make the variable + names neutral for multiple operating systems. + + * nova_apt_packages -> nova_packages + * nova_spice_apt_packages -> nova_spice_packages + * nova_novnc_apt_packages -> nova_novnc_packages + * nova_compute_kvm_apt_packages -> nova_compute_kvm_package + + The old variable names will be removed in the Ocata cycle. diff --git a/tasks/main.yml b/tasks/main.yml index 6925b85e..32ae2952 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -30,6 +30,8 @@ include_vars: "{{ item }}" with_first_found: - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - "{{ ansible_distribution | lower }}.yml" - "{{ ansible_os_family | lower }}.yml" tags: @@ -43,7 +45,6 @@ - include: nova_pre_install.yml - include: nova_install.yml -- include: nova_console_install.yml - include: nova_post_install.yml - include: nova_init.yml diff --git a/tasks/nova_compute_kvm_install.yml b/tasks/nova_compute_kvm_install.yml index 677c5916..e750fcd6 100644 --- a/tasks/nova_compute_kvm_install.yml +++ b/tasks/nova_compute_kvm_install.yml @@ -13,59 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Add ubuntu cloud archive key package - apt: - pkg: ubuntu-cloud-keyring - when: nova_uca_enable - register: add_keys - tags: - - add-apt-keys - -- name: Add UCA repo(s) - apt_repository: - repo: "{{ uca_repo }}" - state: present - register: add_repo - when: nova_uca_enable - until: add_repo|success - retries: 5 - delay: 2 - tags: - - add-uca-repo - -#TODO(evrardjp): Replace the next 2 tasks by a standard apt with cache -#when https://github.com/ansible/ansible-modules-core/pull/1517 is merged -#in 1.9.x or we move to 2.0 (if tested working) -- name: Check apt last update file - stat: - path: /var/cache/apt - register: apt_cache_stat - tags: - - nova-apt-packages - - nova-compute-kvm-apt-packages - -- name: Update apt if needed - apt: - update_cache: yes - when: ("ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" or - add_keys|changed or add_repo|changed) - tags: - - nova-apt-packages - - nova-compute-kvm-apt-packages - -- name: Install apt packages - apt: - pkg: "{{ item }}" - state: latest - register: install_packages - until: install_packages|success - retries: 5 - delay: 2 - with_items: "{{ nova_compute_kvm_apt_packages }}" - tags: - - nova-apt-packages - - nova-compute-kvm-apt-packages - - name: Check if qemu save directory is a directory stat: path: "/var/lib/libvirt/qemu/save" diff --git a/tasks/nova_compute_powervm_install.yml b/tasks/nova_compute_powervm_install.yml index 3d7a8bec..e28b58cf 100644 --- a/tasks/nova_compute_powervm_install.yml +++ b/tasks/nova_compute_powervm_install.yml @@ -28,8 +28,8 @@ - name: Add novalink repo apt_repository: - repo: "{{ novalink_apt_repo.repo }}" - state: "{{ novalink_apt_repo.state }}" + repo: "{{ novalink_repo.repo }}" + state: "{{ novalink_repo.state }}" register: add_nv_repos until: add_nv_repos|success retries: 5 @@ -66,7 +66,7 @@ until: install_packages|success retries: 5 delay: 2 - with_items: "{{ nova_compute_powervm_apt_packages }}" + with_items: "{{ nova_compute_powervm_packages }}" tags: - nova-apt-packages - nova-compute-powervm-apt-packages diff --git a/tasks/nova_console_install.yml b/tasks/nova_console_install.yml deleted file mode 100644 index f8a763e2..00000000 --- a/tasks/nova_console_install.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -# Copyright 2015, 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. - -- include: nova_console_spice_install.yml - when: - - inventory_hostname in groups['nova_console'] - - nova_console_type == "spice" - tags: - - nova-spice-console - -- include: nova_console_novnc_install.yml - when: - - inventory_hostname in groups['nova_console'] - - nova_console_type == "novnc" - tags: - - nova-novnc-console diff --git a/tasks/nova_console_novnc_install.yml b/tasks/nova_console_novnc_install.yml index 27668d77..dc234dd7 100644 --- a/tasks/nova_console_novnc_install.yml +++ b/tasks/nova_console_novnc_install.yml @@ -38,38 +38,6 @@ - nova-install - nova-novnc-git -#TODO(evrardjp): Replace the next 2 tasks by a standard apt with cache -#when https://github.com/ansible/ansible-modules-core/pull/1517 is merged -#in 1.9.x or we move to 2.0 (if tested working) -- name: Check apt last update file - stat: - path: /var/cache/apt - register: apt_cache_stat - tags: - - nova-apt-packages - -- name: Update apt if needed - apt: - update_cache: yes - when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" - tags: - - nova-apt-packages - - nova-novnc-apt-packages - -- name: Install apt packages - apt: - pkg: "{{ item }}" - state: latest - register: install_packages - until: install_packages|success - retries: 5 - delay: 2 - with_items: "{{ nova_novnc_apt_packages }}" - tags: - - nova-install - - nova-apt-packages - - nova-novnc-apt-packages - - name: Install pip packages (venv) pip: name: "{{ item }}" diff --git a/tasks/nova_console_spice_install.yml b/tasks/nova_console_spice_install.yml index bcfeaa75..855fa554 100644 --- a/tasks/nova_console_spice_install.yml +++ b/tasks/nova_console_spice_install.yml @@ -13,38 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -#TODO(evrardjp): Replace the next 2 tasks by a standard apt with cache -#when https://github.com/ansible/ansible-modules-core/pull/1517 is merged -#in 1.9.x or we move to 2.0 (if tested working) -- name: Check apt last update file - stat: - path: /var/cache/apt - register: apt_cache_stat - tags: - - nova-apt-packages - - nova-spice-apt-packages - -- name: Update apt if needed - apt: - update_cache: yes - when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" - tags: - - nova-apt-packages - - nova-spice-apt-packages - -- name: Remove apt packages - apt: - pkg: "{{ item }}" - state: absent - register: remove_packages - until: remove_packages|success - retries: 5 - delay: 2 - with_items: "{{ nova_spice_apt_packages }}" - tags: - - nova-apt-packages - - nova-spice-apt-packages - - name: Remove old git directory file: path: "/usr/share/spice-html5" diff --git a/tasks/nova_install.yml b/tasks/nova_install.yml index 0e45e82b..f40db576 100644 --- a/tasks/nova_install.yml +++ b/tasks/nova_install.yml @@ -13,35 +13,23 @@ # See the License for the specific language governing permissions and # limitations under the License. -#TODO(evrardjp): Replace the next 2 tasks by a standard apt with cache -#when https://github.com/ansible/ansible-modules-core/pull/1517 is merged -#in 1.9.x or we move to 2.0 (if tested working) -- name: Check apt last update file - stat: - path: /var/cache/apt - register: apt_cache_stat - tags: - - nova-apt-packages +- include: nova_install_apt.yml + when: + - ansible_pkg_mgr == 'apt' -- name: Update apt if needed - apt: - update_cache: yes - when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" +- include: nova_console_spice_install.yml + when: + - inventory_hostname in groups['nova_console'] + - nova_console_type == "spice" tags: - - nova-apt-packages + - nova-spice-console -- name: Install apt packages - apt: - pkg: "{{ item }}" - state: latest - register: install_packages - until: install_packages|success - retries: 5 - delay: 2 - with_items: "{{ nova_apt_packages }}" +- include: nova_console_novnc_install.yml + when: + - inventory_hostname in groups['nova_console'] + - nova_console_type == "novnc" tags: - - nova-install - - nova-apt-packages + - nova-novnc-console - name: Create developer mode constraint file copy: diff --git a/tasks/nova_install_apt.yml b/tasks/nova_install_apt.yml new file mode 100644 index 00000000..06f0d454 --- /dev/null +++ b/tasks/nova_install_apt.yml @@ -0,0 +1,116 @@ +--- +# Copyright 2014, 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: Add Ubuntu Cloud Archive key package + apt: + pkg: ubuntu-cloud-keyring + 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 + register: nova_uca_add_repo + when: nova_uca_enable + until: add_repo|success + retries: 5 + delay: 2 + tags: + - add-uca-repo + +#TODO(evrardjp): Replace the next 2 tasks by a standard apt with cache +#when https://github.com/ansible/ansible-modules-core/pull/1517 is merged +#in 1.9.x or we move to 2.0 (if tested working) +- name: Check apt last update file + stat: + path: /var/cache/apt + register: apt_cache_stat + tags: + - nova-apt-packages + +- name: Update apt if needed + apt: + update_cache: yes + when: ("ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" or + nova_uca_add_keys | changed or + nova_uca_add_repo | changed) + tags: + - nova-apt-packages + +- name: Install apt packages (common) + apt: + pkg: "{{ item }}" + state: latest + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: "{{ nova_packages | deprecated(nova_apt_packages, 'nova_apt_packages', 'nova_packages', 'Ocata') }}" + tags: + - nova-install + - nova-apt-packages + +- name: Remove known problem packages for the Spice console + apt: + pkg: "{{ item }}" + state: absent + register: remove_packages + until: remove_packages|success + retries: 5 + delay: 2 + with_items: "{{ nova_spice_packages | deprecated(nova_spice_apt_packages, 'nova_spice_apt_packages', 'nova_spice_packages', 'Ocata') }}" + when: + - inventory_hostname in groups['nova_console'] + - nova_console_type == "spice" + tags: + - nova-install + - nova-apt-packages + - nova-spice-apt-packages + +- name: Install apt packages (novnc console) + apt: + pkg: "{{ item }}" + state: latest + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: "{{ nova_novnc_packages | deprecated(nova_novnc_apt_packages, 'nova_novnc_apt_packages', 'nova_novnc_packages', 'Ocata') }}" + when: + - inventory_hostname in groups['nova_console'] + - nova_console_type == "novnc" + tags: + - nova-install + - nova-apt-packages + - nova-novnc-apt-packages + +- name: Install apt packages (compute - KVM) + apt: + pkg: "{{ item }}" + state: latest + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: "{{ nova_compute_kvm_packages | deprecated(nova_compute_kvm_apt_packages, 'nova_compute_kvm_apt_packages', 'nova_compute_kvm_packages', 'Ocata') }}" + 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 diff --git a/vars/ubuntu-14.04.yml b/vars/ubuntu-14.04.yml index ed97d539..8c5ee412 100644 --- a/vars/ubuntu-14.04.yml +++ b/vars/ubuntu-14.04.yml @@ -1 +1,83 @@ --- +# Copyright 2014, 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. + +## APT Cache options +cache_timeout: 600 + +# Common apt packages +nova_packages: + - genisoimage + - git + - libpq-dev + - iptables + +# Spice console apt packages +nova_spice_packages: + - spice-html5 + +nova_novnc_packages: + - libjs-jquery + - libjs-sphinxdoc + - libjs-underscore + - libjs-swfobject + - librabbitmq1 + - libyaml-0-2 + +nova_compute_kvm_packages: + - bridge-utils + - genisoimage + - kpartx + - libvirt-bin + - open-iscsi + - python-libguestfs + - python-libvirt + - qemu + - qemu-utils + - sysfsutils + - vlan + - nfs-common + - dosfstools + - dosfstools-dbg + - multipath-tools + +# Ubuntu Cloud Archive variables +nova_uca_enable: True +uca_openstack_release: mitaka +uca_repo_url: "http://ubuntu-cloud.archive.canonical.com/ubuntu" +uca_repo_dist: "{{ ansible_lsb.codename }}-updates/{{ uca_openstack_release }}" +uca_repo: "deb {{ uca_repo_url }} {{ uca_repo_dist }} main" + +# nova powervm virt driver +nova_compute_powervm_packages: + - bridge-utils + - genisoimage + - kpartx + - open-iscsi + - python-libguestfs + - sysfsutils + - vlan + - nfs-common + - dosfstools + - dosfstools-dbg + - multipath-tools + - pvm-novalink + +novalink_repo: + repo: "deb [arch=ppc64el] ftp://public.dhe.ibm.com/systems/virtualization/Novalink/debian/ novalink_1.0.0 non-free" + state: "present" + +novalink_gpg_keys: + - url: "ftp://public.dhe.ibm.com/systems/virtualization/Novalink/debian/novalink-gpg-pub.key" + state: "present" diff --git a/vars/ubuntu-16.04.yml b/vars/ubuntu-16.04.yml index fb1874fc..bf5d47b5 100644 --- a/vars/ubuntu-16.04.yml +++ b/vars/ubuntu-16.04.yml @@ -1,2 +1,83 @@ --- -nova_uca_enable: False +# Copyright 2014, 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. + +## APT Cache options +cache_timeout: 600 + +# Common apt packages +nova_packages: + - genisoimage + - git + - libpq-dev + - iptables + +# Spice console apt packages +nova_spice_packages: + - spice-html5 + +nova_novnc_packages: + - libjs-jquery + - libjs-sphinxdoc + - libjs-underscore + - libjs-swfobject + - librabbitmq1 + - libyaml-0-2 + +nova_compute_kvm_packages: + - bridge-utils + - genisoimage + - kpartx + - libvirt-bin + - open-iscsi + - python-libguestfs + - python-libvirt + - qemu + - qemu-utils + - sysfsutils + - vlan + - nfs-common + - dosfstools + - dosfstools-dbg + - multipath-tools + +# Ubuntu Cloud Archive variables +nova_uca_enable: True +uca_openstack_release: newton +uca_repo_url: "http://ubuntu-cloud.archive.canonical.com/ubuntu" +uca_repo_dist: "{{ ansible_lsb.codename }}-updates/{{ uca_openstack_release }}" +uca_repo: "deb {{ uca_repo_url }} {{ uca_repo_dist }} main" + +# nova powervm virt driver +nova_compute_powervm_packages: + - bridge-utils + - genisoimage + - kpartx + - open-iscsi + - python-libguestfs + - sysfsutils + - vlan + - nfs-common + - dosfstools + - dosfstools-dbg + - multipath-tools + - pvm-novalink + +novalink_repo: + repo: "deb [arch=ppc64el] ftp://public.dhe.ibm.com/systems/virtualization/Novalink/debian/ novalink_1.0.0 non-free" + state: "present" + +novalink_gpg_keys: + - url: "ftp://public.dhe.ibm.com/systems/virtualization/Novalink/debian/novalink-gpg-pub.key" + state: "present"