summaryrefslogtreecommitdiff
path: root/test/integration/targets/setup_mysql8
diff options
context:
space:
mode:
authorSam Doran <sdoran@redhat.com>2019-11-12 22:01:19 -0500
committerMatt Davis <nitzmahone@users.noreply.github.com>2019-11-12 19:01:19 -0800
commitaf2def550700f4cceee9aedaf61d4515c0c35b2e (patch)
tree1c2831c10d7c76edbe16098e367af5c12f210da1 /test/integration/targets/setup_mysql8
parent1e0d7ac25bd571efc03a07d910412295ce77149c (diff)
downloadansible-af2def550700f4cceee9aedaf61d4515c0c35b2e.tar.gz
[stable-2.9] Cleanup after MySQL integration tests (#63641) (#63863)
Add handlers to setup_mysql_db and setup_mysql8 to remove installed packages.. (cherry picked from commit 3e4ae4225688c02190a00cd1818136d8e09f3a16) Co-authored-by: Sam Doran <sdoran@redhat.com>
Diffstat (limited to 'test/integration/targets/setup_mysql8')
-rw-r--r--test/integration/targets/setup_mysql8/defaults/main.yml14
-rw-r--r--test/integration/targets/setup_mysql8/handlers/main.yml24
-rw-r--r--test/integration/targets/setup_mysql8/tasks/main.yml18
-rw-r--r--test/integration/targets/setup_mysql8/tasks/setup_mysql8.yml59
-rw-r--r--test/integration/targets/setup_mysql8/vars/Debian.yml3
-rw-r--r--test/integration/targets/setup_mysql8/vars/RedHat.yml3
-rw-r--r--test/integration/targets/setup_mysql8/vars/default.yml0
7 files changed, 121 insertions, 0 deletions
diff --git a/test/integration/targets/setup_mysql8/defaults/main.yml b/test/integration/targets/setup_mysql8/defaults/main.yml
new file mode 100644
index 0000000000..ec14bb2918
--- /dev/null
+++ b/test/integration/targets/setup_mysql8/defaults/main.yml
@@ -0,0 +1,14 @@
+repo_link: https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
+repo_name: mysql-community
+my_cnf: /etc/my.cnf
+mysql_packages:
+ - mysql-community-server
+ - MySQL-python
+
+mysql_cleanup_packages:
+ - mysql-community-client
+ - mysql-community-common
+ - mysql-community-libs
+ - mysql-community-libs-compat
+ - mysql-community-server
+ - mysql80-community-release
diff --git a/test/integration/targets/setup_mysql8/handlers/main.yml b/test/integration/targets/setup_mysql8/handlers/main.yml
new file mode 100644
index 0000000000..b3183dd7d9
--- /dev/null
+++ b/test/integration/targets/setup_mysql8/handlers/main.yml
@@ -0,0 +1,24 @@
+- name: stop mysql service
+ service:
+ name: mysqld
+ state: stopped
+ listen: cleanup mysql8
+
+- name: remove repo
+ yum:
+ name: mysql80-community-release
+ state: absent
+ listen: cleanup mysql8
+
+- name: remove mysql packages
+ yum:
+ name: '{{ mysql_packages | union(mysql_cleanup_packages) }}'
+ state: absent
+ listen: cleanup mysql8
+
+- name: remove mysql data
+ file:
+ path: "{{ item }}"
+ state: absent
+ loop: "{{ mysql_data_dirs }}"
+ listen: cleanup mysql8
diff --git a/test/integration/targets/setup_mysql8/tasks/main.yml b/test/integration/targets/setup_mysql8/tasks/main.yml
new file mode 100644
index 0000000000..86ea1f8e0f
--- /dev/null
+++ b/test/integration/targets/setup_mysql8/tasks/main.yml
@@ -0,0 +1,18 @@
+# Copyright: (c) 2019, Andrew Klychkov (@Andersson007) <aaklychkov@mail.ru>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+# Setup MySQL 8:
+- name: Include distribution specific variables
+ include_vars: "{{ lookup('first_found', params) }}"
+ vars:
+ params:
+ files:
+ - '{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml'
+ - '{{ ansible_facts.os_family }}.yml'
+ - 'default.yml'
+ paths: vars
+
+- import_tasks: setup_mysql8.yml
+ when:
+ - ansible_facts.distribution == 'CentOS'
+ - ansible_facts.distribution_major_version is version_compare('7', '>=')
diff --git a/test/integration/targets/setup_mysql8/tasks/setup_mysql8.yml b/test/integration/targets/setup_mysql8/tasks/setup_mysql8.yml
new file mode 100644
index 0000000000..2c747d7ca3
--- /dev/null
+++ b/test/integration/targets/setup_mysql8/tasks/setup_mysql8.yml
@@ -0,0 +1,59 @@
+# Copyright: (c) 2019, Andrew Klychkov (@Andersson007) <aaklychkov@mail.ru>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Install MySQL repo
+ yum:
+ name: '{{ repo_link }}'
+ notify: cleanup mysql8
+
+- name: Install MySQL community server
+ yum:
+ name: '{{ mysql_packages }}'
+ notify: cleanup mysql8
+
+- name: Copy my.cnf
+ copy:
+ src: my.cnf
+ dest: '{{ my_cnf }}'
+
+- name: Start MySQL
+ service:
+ name: mysqld
+ state: started
+
+### Debug #######################
+#- name: Debug
+# shell: cat /var/log/mysqld.log
+#################################
+
+- name: Check connection to the server
+ shell: 'echo "SHOW DATABASES;" | mysql'
+
+- name: Check connection to the server
+ shell: "echo \"SHOW VARIABLES LIKE '%version%';\" | mysql"
+
+- name: Detect socket path
+ shell: 'echo "show variables like ''socket''\G" | mysql | grep ''Value: '' | sed ''s/[ ]\+Value: //'''
+ register: _socket_path
+
+- name: Set socket path
+ set_fact:
+ mysql_socket: '{{ _socket_path["stdout"] }}'
+
+- name: Set root pass
+ set_fact:
+ root_pass: "dlsafjlkjdsaK1#"
+
+- name: Set root password
+ shell: 'echo "flush privileges; ALTER USER ''root''@''localhost'' IDENTIFIED WITH mysql_native_password BY ''{{ root_pass }}'';" | mysql'
+
+- name: Change configuration
+ lineinfile:
+ path: '{{ my_cnf }}'
+ line: skip-grant-tables
+ state: absent
+
+- name: Restart MySQL
+ service:
+ name: mysqld
+ state: restarted
diff --git a/test/integration/targets/setup_mysql8/vars/Debian.yml b/test/integration/targets/setup_mysql8/vars/Debian.yml
new file mode 100644
index 0000000000..78323264f6
--- /dev/null
+++ b/test/integration/targets/setup_mysql8/vars/Debian.yml
@@ -0,0 +1,3 @@
+mysql_data_dirs:
+ - /var/lib/mysql
+ - /usr/share/mysql
diff --git a/test/integration/targets/setup_mysql8/vars/RedHat.yml b/test/integration/targets/setup_mysql8/vars/RedHat.yml
new file mode 100644
index 0000000000..498e7771e4
--- /dev/null
+++ b/test/integration/targets/setup_mysql8/vars/RedHat.yml
@@ -0,0 +1,3 @@
+mysql_data_dirs:
+ - /var/lib/mysql
+ - /usr/mysql
diff --git a/test/integration/targets/setup_mysql8/vars/default.yml b/test/integration/targets/setup_mysql8/vars/default.yml
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/integration/targets/setup_mysql8/vars/default.yml