Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup after MariaDB integration tests #63657

Merged
merged 2 commits into from
Oct 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 18 additions & 1 deletion test/integration/targets/setup_mariadb/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
repo_link: http://yum.mariadb.org/10.1/centos7-amd64
repo_gpgkey: https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

mariadb_packages:
- MariaDB-server
- MariaDB-client

packages_to_cleanup:
- MariaDB-server
- MariaDB-client
- MariaDB-common
- boost-program-options
- galera
- jemalloc

master_port: 3306
standby_port: 3307
master_datadir: /var/lib/mysql_master

standby_port: 3307
standby_datadir: /var/lib/mysql_standby
standby_logdir: /var/log/mysql_standby

default_logdir: /var/log/mariadb
mysql_safe_err_log: /var/log/mariadb/mysql_safe-err.log
24 changes: 24 additions & 0 deletions test/integration/targets/setup_mariadb/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- name: Remove MariaDB repo
yum_repository:
name: MariaDB
state: absent
listen: cleanup mariadb

- name: Remove MariaDB related packages
yum:
name: "{{ item }}"
state: absent
loop: "{{ packages_to_cleanup }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's much more efficient to pass a list to the yum module rather than iterating over a list. This results in one task per item in the list rather than one task that installs multiples packages at once.

In the past, the yum action plugin did some magic to avoid multiple yum tasks, but that has been removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samdoran , please, look #63848

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for pointing this out!

listen: cleanup mariadb

- name: Remove related FS objects
file:
state: absent
path: "{{ item }}"
loop:
- "{{ master_datadir }}"
- "{{ standby_datadir }}"
- "{{ standby_logdir }}"
- "{{ default_logdir }}"
- "{{ mysql_safe_err_log }}"
listen: cleanup mariadb
4 changes: 3 additions & 1 deletion test/integration/targets/setup_mariadb/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

- import_tasks: setup_mariadb.yml
when: ansible_distribution == 'CentOS' and ansible_distribution_major_version >= '7'
when:
- ansible_distribution == 'CentOS'
- ansible_distribution_major_version >= '7'
13 changes: 7 additions & 6 deletions test/integration/targets/setup_mariadb/tasks/setup_mariadb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
yum_repository:
name: MariaDB
description: MariaDB official repo
baseurl: http://yum.mariadb.org/10.1/centos7-amd64
gpgkey: https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
baseurl: "{{ repo_link }}"
gpgkey: "{{ repo_gpgkey }}"
gpgcheck: yes
notify: cleanup mariadb

- name: Install MariaDB packages on RedHat family OS
yum:
name: "{{ item }}"
enablerepo: epel
loop:
- MariaDB-server
- MariaDB-client
loop: "{{ mariadb_packages }}"
when: ansible_os_family == 'RedHat'
notify: cleanup mariadb

- name: Create directories for standby
- name: Create directories for instances
file:
state: directory
path: "{{ item }}"
Expand All @@ -29,6 +29,7 @@
- "{{ standby_datadir }}"
- "{{ standby_logdir }}"
- "{{ default_logdir }}"
notify: cleanup mariadb

- name: Copy cnf template
template:
Expand Down