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 <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2016-03-17 00:57:50 -05:00
parent 7f94d6b18e
commit 0c6e5fb911
6 changed files with 113 additions and 44 deletions

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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

31
vars/ubuntu-14.04.yml Normal file
View File

@ -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