Optimise the distro package installation

In order to optimise the distro package installation
process the list of packages to install is prepared
for the host in vars, instead of using two tasks.

A dynamic inclusion is used to further optimise the
execution of the package installation. The minimum
Ansible version is updated to 2.0 to provide for
the ability to do dynamic inclusions.

The package lists in defaults are removed as it is
undesirable to make it easy to override these lists.
This is not provided for in any other roles.

Change-Id: I71307d2a808fdc0f76e376a84651dad86b3f8b69
This commit is contained in:
Jesse Pretorius 2017-06-09 09:13:01 +01:00
parent 989d6959d0
commit 5a84473dc2
6 changed files with 17 additions and 39 deletions

View File

@ -39,6 +39,4 @@ memcached_connections: 1024
memcached_threads: 4
memcached_file_limits: "{{ memcached_connections | int + 1024 }}"
memcached_distro_packages: []
memcached_test_distro_packages: []
install_test_packages: False

View File

@ -18,7 +18,7 @@ galaxy_info:
description: Installation and setup of memcached
company: Rackspace
license: Apache2
min_ansible_version: 1.6.6
min_ansible_version: 2.0
platforms:
- name: Ubuntu
versions:

View File

@ -24,7 +24,7 @@
tags:
- always
- include: memcached_install.yml
- include: "memcached_install-{{ ansible_pkg_mgr }}.yml"
tags:
- memcached_server-install

View File

@ -31,18 +31,7 @@
pkg: "{{ item }}"
state: "{{ memcached_package_state }}"
register: install_packages
until: install_packages|success
until: install_packages | success
retries: 5
delay: 2
with_items: "{{ memcached_distro_packages }}"
- name: Install apt packages for testing
apt:
pkg: "{{ item }}"
state: "{{ memcached_package_state }}"
register: install_test_packages
until: install_test_packages|success
retries: 5
delay: 2
with_items: "{{ memcached_test_distro_packages }}"
when: install_test_packages|bool
with_items: "{{ memcached_package_list }}"

View File

@ -30,15 +30,4 @@
until: install_yum_packages | success
retries: 5
delay: 2
with_items: "{{ memcached_distro_packages }}"
- name: Install yum packages for testing
yum:
pkg: "{{ item }}"
state: "{{ memcached_package_state }}"
register: install_yum_test_packages
until: install_yum_test_packages | success
retries: 5
delay: 2
with_items: "{{ memcached_test_distro_packages }}"
when: install_test_packages|bool
with_items: "{{ memcached_package_list }}"

View File

@ -1,5 +1,5 @@
---
# Copyright 2014, Rackspace US, Inc.
# 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.
@ -13,12 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- include: install-apt.yml
static: no
when:
- ansible_pkg_mgr == 'apt'
- include: install-yum.yml
static: no
when:
- ansible_pkg_mgr == 'yum'
#
# Compile a list of the distro packages to install based on
# whether the host is in the host group and the service is
# enabled.
#
memcached_package_list: |-
{% set packages = memcached_distro_packages %}
{% if install_test_packages | bool %}
{% set _ = packages.extend(memcached_test_distro_packages) %}
{% endif %}
{{ packages }}