From 0c6e5fb91106e827d550ce40892d3c9cf71367ed Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Thu, 17 Mar 2016 00:57:50 -0500 Subject: [PATCH] Modified apt install and lvm volume specific tasks The change updates the cinder role to isolate the packages being installed when using the LVM volume driver. Currently the tgt and other packages are being installed everywhere as well as setting up specific LVM config in all locations. This can and will cause issues when the role is executed on metal or in various other scenarios on top of the fact that the installation and maintenance of the extra packages is a burden that we no longer need to carry. To resolve this, the pattern for multi-distro support was added to the package install process and conditionals were added to the specific LVM volume type tasks. Change-Id: I85568e5680812c37fbf4aa4a21419127f8cee8d9 Signed-off-by: Kevin Carter --- defaults/main.yml | 18 ++--------- tasks/cinder_install.yml | 32 +++---------------- tasks/cinder_install_apt.yml | 60 +++++++++++++++++++++++++++++++++++ tasks/cinder_post_install.yml | 7 +++- tasks/main.yml | 9 ++++++ vars/ubuntu-14.04.yml | 31 ++++++++++++++++++ 6 files changed, 113 insertions(+), 44 deletions(-) create mode 100644 tasks/cinder_install_apt.yml create mode 100644 vars/ubuntu-14.04.yml diff --git a/defaults/main.yml b/defaults/main.yml index 6e0cde78..2e649318 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -192,6 +192,9 @@ cinder_quota_backup_gigabytes: 1000 # volume_driver: cinder.volume.drivers.lvm.LVMVolumeDriver # volume_backend_name: LVM_iSCSI +# cinder_backend_lvm_inuse: True if current host has an lvm backend +cinder_backend_lvm_inuse: '{{ (cinder_backends|default("")|to_json).find("lvm") != -1 }}' + ## Define nfs information for cinder. When the cinder_nfs_client dictionary is defined, ## it will enable nfs shares. The value ``nfs_shares_config`` is the path on the disk ## where the NFS export will live. The ``shares`` value is a list of dictionaries that @@ -218,21 +221,6 @@ cinder_glance_api_version: 1 cinder_service_in_ldap: false -# Common apt packages -cinder_apt_packages: - - dmeventd - - libpq-dev - - libkmod-dev - - libkmod2 - - libxslt1-dev - - nfs-common - - parted - - qemu-utils - - rpcbind - - tgt - - zlib1g - - zlibc - # Cinder packages that must be installed before anything else cinder_requires_pip_packages: - virtualenv diff --git a/tasks/cinder_install.yml b/tasks/cinder_install.yml index 40ef0b1f..b33ae275 100644 --- a/tasks/cinder_install.yml +++ b/tasks/cinder_install.yml @@ -13,35 +13,11 @@ # 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 +- include: cinder_install_apt.yml + when: + - ansible_pkg_mgr == 'apt' tags: - - cinder-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: - - cinder-apt-packages - -- name: Install apt packages - apt: - pkg: "{{ item }}" - state: latest - register: install_packages - until: install_packages|success - retries: 5 - delay: 2 - with_items: cinder_apt_packages - tags: - - cinder-install - - cinder-apt-packages + - install-apt - name: Create developer mode constraint file copy: diff --git a/tasks/cinder_install_apt.yml b/tasks/cinder_install_apt.yml new file mode 100644 index 00000000..09295098 --- /dev/null +++ b/tasks/cinder_install_apt.yml @@ -0,0 +1,60 @@ +--- +# Copyright 2016, 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. + +#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: + - cinder-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: + - cinder-apt-packages + +- name: Install apt packages + apt: + pkg: "{{ item }}" + state: latest + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: cinder_apt_packages + tags: + - cinder-install + - cinder-apt-packages + +- name: Install apt packages + apt: + pkg: "{{ item }}" + state: latest + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: cinder_lvm_volume_apt_packages + when: + - inventory_hostname in groups['cinder_volume'] + - cinder_backend_lvm_inuse | bool + tags: + - cinder-install + - cinder-apt-packages diff --git a/tasks/cinder_post_install.yml b/tasks/cinder_post_install.yml index 78d699b2..2dea259d 100644 --- a/tasks/cinder_post_install.yml +++ b/tasks/cinder_post_install.yml @@ -63,6 +63,9 @@ line: "include /var/lib/cinder/volumes/*" state: present notify: Ensure tgt service restarted + when: + - inventory_hostname in groups['cinder_volume'] + - cinder_backend_lvm_inuse | bool tags: - cinder-tgt @@ -70,7 +73,9 @@ template: src: nfs_shares.j2 dest: "{{ cinder_nfs_client.nfs_shares_config }}" - when: cinder_nfs_client is defined + when: + - cinder_nfs_client is defined + - inventory_hostname in groups['cinder_volume'] tags: - cinder-nfs diff --git a/tasks/main.yml b/tasks/main.yml index 959048e1..08a16f08 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,6 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Gather variables for each operating system + include_vars: "{{ item }}" + with_first_found: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" + - "{{ ansible_distribution | lower }}.yml" + - "{{ ansible_os_family | lower }}.yml" + tags: + - always + - include: cinder_pre_install.yml - include: cinder_install.yml - include: cinder_post_install.yml diff --git a/vars/ubuntu-14.04.yml b/vars/ubuntu-14.04.yml new file mode 100644 index 00000000..0b0a34e2 --- /dev/null +++ b/vars/ubuntu-14.04.yml @@ -0,0 +1,31 @@ +--- +# Copyright 2016, 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. + +# Common apt packages +cinder_apt_packages: + - libpq-dev + - libkmod-dev + - libkmod2 + - libxslt1-dev + - nfs-common + - rpcbind + - zlib1g + - zlibc + +cinder_lvm_volume_apt_packages: + - dmeventd + - parted + - qemu-utils + - tgt