Skip to content

Commit

Permalink
Merge pull request #30 from Oefenweb/add-support-for-percona-57
Browse files Browse the repository at this point in the history
Add support for Percona 5.7
  • Loading branch information
tersmitten authored Apr 20, 2018
2 parents e04105f + 31cd1a0 commit 23956da
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 36 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ python: "2.7"

env:
- ANSIBLE_VERSION=latest
- ANSIBLE_VERSION=2.5.1
- ANSIBLE_VERSION=2.5.0
- ANSIBLE_VERSION=2.4.4.0
- ANSIBLE_VERSION=2.4.3.0
Expand Down
7 changes: 7 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ boxes = [
:cpu => "50",
:ram => "256"
},
{
:name => "debian-9",
:box => "bento/debian-9",
:ip => '10.0.0.16',
:cpu => "50",
:ram => "256"
},
]

Vagrant.configure("2") do |config|
Expand Down
1 change: 1 addition & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ galaxy_info:
versions:
- wheezy
- jessie
- stretch
galaxy_tags:
- system
- database
Expand Down
32 changes: 32 additions & 0 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@
tags:
- percona-server-configure-copy-certificate-files

- block:
- name: configure | service | stop
service:
name: mysql
state: stopped
tags:
- percona-server-configure-first-run-service-stop

- name: configure | remove (excessive) configuration files
file:
path: "{{ item }}"
state: absent
with_items:
- /etc/mysql/percona-server.cnf
- /etc/mysql/percona-server.conf.d
tags:
- percona-server-configure-first-run-cleanup
when: _mysqld_installed.rc != 0
tags:
- percona-server-configure-first-run

- name: configure | update (global) configuration file
template:
src: etc/mysql/my.cnf.j2
Expand All @@ -23,6 +44,17 @@
tags:
- percona-server-configure-global-my-cnf

- block:
- name: configure | service | start
service:
name: mysql
state: started
tags:
- percona-server-configure-first-run-service-start
when: _mysqld_installed.rc != 0
tags:
- percona-server-configure-first-run

- name: configure | update (root) configuration file
template:
src: root/.my.cnf.j2
Expand Down
5 changes: 3 additions & 2 deletions tasks/first-run.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# tasks file for percona-server
---
- name: first-run | check
shell: "dpkg-query -W -f='${Status}' percona-server-server-{{ percona_server_version }} | grep -q 'install ok installed'"
register: mysqld_installed
shell: >
dpkg-query -W -f='${Status}' percona-server-server-{{ percona_server_version }} | grep -q 'install ok installed'
register: _mysqld_installed
changed_when: false
failed_when: false
tags:
Expand Down
59 changes: 33 additions & 26 deletions tasks/ib-logfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,44 @@
- percona-server-store-datadir
- percona-server-store-datadir-retrieve

# Needed because of Ansible 1 / 2 differences
- name: ib logfile | store datadir
set_fact:
percona_server_datadir: "{{ datadir_value.msg.0.1 if datadir_value.msg.0.1 is defined else datadir_value.msg }}"
percona_server_datadir: "{{ datadir_value.msg }}"
tags:
- percona-server-store-datadir
- percona-server-store-datadir-set-fact

- name: ib logfile | stop service
service:
name: mysql
state: stopped
when: mysqld_installed.rc != 0
tags:
- percona-server-ib-logfile-stop-service
# Instead of doing this in main.yml we do it here because of a bug in 2.2.0.0
- block:
- name: ib logfile | set InnoDB shutdown mode
mysql_variables:
variable: innodb_fast_shutdown
value: "1"
tags:
- percona-server-ib-logfile-innodb-fast-shutdown
- percona-server-ib-logfile-innodb-fast-shutdown-set

- name: ib logfile | remove ib_logfile(s)
file:
path: "{{ item }}"
state: absent
with_items:
- "{{ percona_server_datadir.rstrip('/') }}/ib_logfile0"
- "{{ percona_server_datadir.rstrip('/') }}/ib_logfile1"
when: mysqld_installed.rc != 0
tags:
- percona-server-ib-logfile-remove
- name: ib logfile | stop service
service:
name: mysql
state: stopped
tags:
- percona-server-ib-logfile-stop-service

- name: ib logfile | start service
service:
name: mysql
state: started
when: mysqld_installed.rc != 0
tags:
- percona-server-ib-logfile-start-service
- name: ib logfile | remove ib_logfile(s)
file:
path: "{{ item }}"
state: absent
with_items:
- "{{ percona_server_datadir.rstrip('/') }}/ib_logfile0"
- "{{ percona_server_datadir.rstrip('/') }}/ib_logfile1"
tags:
- percona-server-ib-logfile-remove

- name: ib logfile | start service
service:
name: mysql
state: started
tags:
- percona-server-ib-logfile-start-service
when: _mysqld_installed.rc != 0
8 changes: 0 additions & 8 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@
tags:
- percona-server-install-dependencies

- name: install | dependencies | check service
service:
name: mysql
state: started
tags:
- percona-server-install-dependencies
- percona-server-install-dependencies-check

- name: install | additional
apt:
name: "{{ item }}"
Expand Down
13 changes: 13 additions & 0 deletions tasks/repository.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# tasks file for percona-server
---
- name: repository | install | dependencies
apt:
name: "{{ item }}"
state: "{{ apt_install_state | default('latest') }}"
update_cache: true
cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}"
with_items:
- dirmngr
when: ansible_distribution == 'Debian' and ansible_distribution_version | version_compare('9.0', '>=')
tags:
- percona-server-repository-install
- percona-server-repository-install-dependencies

- name: repository | add public key
apt_key:
id: 9334A25F8507EFA5
Expand Down
2 changes: 2 additions & 0 deletions tests/vagrant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
become: true
roles:
- ../../
vars:
percona_server_version: 5.7
1 change: 1 addition & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
percona_server_versions_supported:
- '5.5'
- '5.6'
- '5.7'

percona_server_repositories:
- type: deb
Expand Down

0 comments on commit 23956da

Please sign in to comment.