Install packages in one step

Installing all packages in one step speeds up the playbook run and is
being used in other roles already.

Change-Id: Iadd07d7979772a49e5f55f612fd95a099924638d
This commit is contained in:
Major Hayden
2017-02-21 15:05:56 -05:00
parent c277ab8aa1
commit 777641e056
5 changed files with 49 additions and 90 deletions

View File

@@ -13,18 +13,9 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
- include: galera_install_apt.yml - include: "galera_install_{{ ansible_pkg_mgr }}.yml"
static: no
when:
- ansible_pkg_mgr == 'apt'
tags: tags:
- install-apt - install-apt
- include: galera_install_yum.yml
static: no
when:
- ansible_pkg_mgr == 'yum'
tags:
- install-yum - install-yum
- name: Install pip packages - name: Install pip packages

View File

@@ -13,20 +13,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
- name: Install galera apt pre packages
apt:
pkg: "{{ item }}"
state: "{{ galera_server_package_state }}"
update_cache: yes
cache_valid_time: "{{ cache_timeout }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items: "{{ galera_server_required_distro_packages }}"
tags:
- galera-pre-apt-packages
- name: Add galera apt-keys - name: Add galera apt-keys
apt_key: apt_key:
id: "{{ item.hash_id }}" id: "{{ item.hash_id }}"
@@ -111,45 +97,21 @@
mode: "0755" mode: "0755"
backup: yes backup: yes
- name: Install galera packages - name: Install galera_server role remote packages (apt)
apt: apt:
pkg: "{{ item }}" name: "{{ item }}"
state: "{{ galera_server_package_state }}" state: "{{ galera_server_package_state }}"
update_cache: yes update_cache: yes
cache_valid_time: "{{ add_repos | changed | ternary('0', cache_timeout) }}" cache_valid_time: "{{ add_repos | changed | ternary('0', cache_timeout) }}"
register: install_packages with_items:
until: install_packages|success - "{{ galera_packages_list | selectattr('enabled') | rejectattr('local_pkg') | sum(attribute='packages', start=[]) }}"
retries: 5
delay: 2
with_items: "{{ galera_server_mariadb_distro_packages }}"
notify: Restart mysql
tags:
- galera-apt-packages
- name: Install percona-xtrabackup package from .deb - name: Install galera_server role local packages (apt)
apt: apt:
deb: "{{ percona_package_path }}" deb: "{{ item }}"
force: yes force: yes
when: not use_percona_upstream | bool with_items:
tags: - "{{ galera_packages_list | selectattr('enabled') | selectattr('local_pkg') | sum(attribute='packages', start=[]) }}"
- percona-apt-packages
- name: Install qpress package from .deb
apt:
deb: "{{ qpress_package_path }}"
force: yes
when: not use_percona_upstream | bool
tags:
- percona-apt-packages
- name: Install percona packages
apt:
pkg: "{{ item }}"
state: installed
with_items: "{{ galera_server_percona_distro_packages }}"
when: use_percona_upstream | bool
tags:
- percona-apt-packages
- name: Remove policy-rc - name: Remove policy-rc
file: file:

View File

@@ -67,18 +67,6 @@
tags: tags:
- galera-repos - galera-repos
- name: Install galera yum pre packages
yum:
pkg: "{{ item }}"
state: "{{ galera_server_package_state }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items: "{{ galera_server_required_distro_packages }}"
tags:
- galera-pre-yum-packages
- name: Install percona repo - name: Install percona repo
yum: yum:
pkg: "{{ galera_percona_xtrabackup_repo.repo }}" pkg: "{{ galera_percona_xtrabackup_repo.repo }}"
@@ -91,30 +79,12 @@
tags: tags:
- galera-pre-yum-packages - galera-pre-yum-packages
- name: Install percona yum packages - name: Install galera_server role remote packages (yum)
yum: yum:
pkg: "{{ item }}" name: "{{ item }}"
state: "{{ galera_server_package_state }}" state: "{{ galera_server_package_state }}"
register: install_packages with_items:
until: install_packages|success - "{{ galera_packages_list | selectattr('enabled') | sum(attribute='packages', start=[]) }}"
retries: 5
delay: 2
with_items: "{{ galera_server_percona_distro_packages }}"
when: use_percona_upstream | bool
tags:
- galera-pre-yum-packages
- name: Install galera yum packages
yum:
pkg: "{{ item }}"
state: "{{ galera_server_package_state }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items: "{{ galera_server_mariadb_distro_packages }}"
tags:
- galera-pre-yum-packages
- name: Enable mysql to start at boot - name: Enable mysql to start at boot
service: service:

View File

@@ -36,6 +36,11 @@
tags: tags:
- always - always
- name: Gather variables that apply to all operating systems
include_vars: common.yml
tags:
- always
- include: galera_upgrade_check.yml - include: galera_upgrade_check.yml
tags: galera_server-upgrade tags: galera_server-upgrade

31
vars/common.yml Normal file
View File

@@ -0,0 +1,31 @@
---
# 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.
galera_packages_list:
- packages: "{{ galera_server_required_distro_packages }}"
enabled: yes
local_pkg: no
- packages: "{{ galera_server_mariadb_distro_packages }}"
enabled: yes
local_pkg: no
- packages: "{{ galera_server_percona_distro_packages }}"
enabled: "{{ use_percona_upstream }}"
local_pkg: no
- packages: "{{ [percona_package_path] }}"
enabled: "{{ not use_percona_upstream }}"
local_pkg: yes
- packages: "{{ [qpress_package_path] }}"
enabled: "{{ not use_percona_upstream }}"
local_pkg: yes