Skip to content

Commit

Permalink
Merge pull request #47 from Oefenweb/pr-33
Browse files Browse the repository at this point in the history
Add support Percona Server 8.0
  • Loading branch information
tersmitten authored Mar 24, 2023
2 parents 2739aa0 + 26cee57 commit 5175937
Show file tree
Hide file tree
Showing 28 changed files with 159 additions and 86 deletions.
4 changes: 2 additions & 2 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
warn_list:
- role-name
- name[play]
- name[casing]
- '204'
- '306'
- risky-shell-pipe
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ jobs:
python-version: '3.x'

- name: Install test dependencies
run: pip install ansible-lint[community,yamllint]
run: |
pip install ansible-lint
ansible-galaxy install -r requirements.yml
- name: Lint code
run: |
Expand All @@ -43,11 +45,8 @@ jobs:
matrix:
include:
- distro: debian8
ansible-version: '<2.10'
- distro: debian9
- distro: debian10
- distro: ubuntu1604
ansible-version: '>=2.9, <2.10'
- distro: ubuntu1604
ansible-version: '>=2.10, <2.11'
- distro: ubuntu1604
Expand Down
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
FROM ubuntu:16.04
FROM ubuntu:18.04
MAINTAINER Mischa ter Smitten <[email protected]>

ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

# python
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y python-minimal python-dev curl && \
DEBIAN_FRONTEND=noninteractive apt-get install -y python3-minimal python3-dev curl && \
apt-get clean
RUN curl -sL https://bootstrap.pypa.io/pip/2.7/get-pip.py | python -
RUN curl -sL https://bootstrap.pypa.io/pip/3.6/get-pip.py | python3 -
RUN rm -rf $HOME/.cache

# ansible
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gcc libffi-dev libssl-dev && \
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python3-apt && \
apt-get clean
RUN pip install ansible==2.9.15
RUN pip3 install ansible==2.10.7
RUN rm -rf $HOME/.cache

# provision
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Set up a [percona-server](https://www.percona.com/software/mysql-database/percon

* `percona_server_user_root_cnf_manage`: [default: `true`]: Whether or not to manage `~root/.my.cnf`
* `percona_server_user_root_cnf`: [default: `percona_server_user_root_cnf_preset`, see `defaults/main.yml`]: Root user configuration declarations
* `percona_server_use_legacy_auth_method`: [default: `false`]: Use legacy authentication method **_(only Percona Server 8.0)_**

##### SSL

Expand Down
4 changes: 4 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ percona_server_version: 5.7

percona_server_root_password: '+eswuw9uthUteFreyAqu'

percona_server_use_legacy_auth_method: false

percona_server_etc_my_cnf: []

percona_server_user_root_cnf_manage: true
Expand All @@ -21,6 +23,8 @@ percona_server_user_root_cnf: "{{ percona_server_user_root_cnf_preset }}"
percona_server_install:
- "percona-xtrabackup{{ '-80' if percona_server_version is version('8', '>=') else '-24' if percona_server_version is version('5.7', '>=') else '' }}"

percona_server_restart_handler_state: restarted

percona_server_ssl_map: {}

percona_server_plugins_present: []
Expand Down
4 changes: 2 additions & 2 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# handlers file
---
- name: restart percona-server

Check warning on line 3 in handlers/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
service:
ansible.builtin.service:
name: mysql
state: restarted
state: "{{ percona_server_restart_handler_state }}"
when: service_default_state | default('started') == 'started'
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ galaxy_info:
company: Oefenweb.nl B.V.
description: Set up percona-server server in Debian-like systems
license: MIT
min_ansible_version: 2.9.0
min_ansible_version: 2.10.0
platforms:
- name: Ubuntu
versions:
Expand Down
6 changes: 6 additions & 0 deletions molecule/default/collections.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
collections:
- name: community.docker
version: '>=1.2.0,<2'
- name: community.general
version: '>=2,<3'
2 changes: 1 addition & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
become: true
pre_tasks:
- name: include vars

Check warning on line 6 in molecule/default/converge.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
include_vars: "{{ playbook_dir }}/../../tests/vars/main.yml"
ansible.builtin.include_vars: "{{ playbook_dir }}/../../tests/vars/main.yml"
roles:
- ../../../
4 changes: 3 additions & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ platforms:
image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu1604}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /sys/fs/cgroup:/sys/fs/cgroup:rw
- /var/lib/containerd
cgroupns_mode: host
privileged: true
pre_build_image: true
provisioner:
Expand Down
4 changes: 4 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# requirements file
---
collections:
- name: community.mysql
30 changes: 16 additions & 14 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# tasks file
---
- name: configure | copy certificate files

Check warning on line 3 in tasks/configure.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
copy:
ansible.builtin.copy:
src: "{{ item.value.src }}"
dest: "{{ item.value.dest }}"
owner: "{{ item.value.owner | default('root') }}"
Expand All @@ -12,29 +12,30 @@
tags:
- percona-server-configure-copy-certificate-files

- block:
- name: configure | service

Check warning on line 15 in tasks/configure.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
when: _mysqld_installed.rc != 0
tags:
- percona-server-configure-first-run
block:
- name: configure | service | stop

Check warning on line 20 in tasks/configure.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
service:
ansible.builtin.service:
name: mysql
state: stopped
tags:
- percona-server-configure-first-run-service-stop

- name: configure | remove (excessive) configuration files

Check warning on line 27 in tasks/configure.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
file:
ansible.builtin.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

Check warning on line 37 in tasks/configure.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
template:
ansible.builtin.template:
src: "{{ percona_server_etc_mysql_my_cnf.lstrip('/') }}.j2"
dest: "{{ percona_server_etc_mysql_my_cnf }}"
owner: root
Expand All @@ -44,19 +45,20 @@
tags:
- percona-server-configure-global-my-cnf

- block:
- name: configure | service

Check warning on line 48 in tasks/configure.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
when: _mysqld_installed.rc != 0
tags:
- percona-server-configure-first-run
block:
- name: configure | service | start

Check warning on line 53 in tasks/configure.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
service:
ansible.builtin.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:
ansible.builtin.template:
src: root/.my.cnf.j2
dest: '~root/.my.cnf'
owner: root
Expand Down
4 changes: 2 additions & 2 deletions tasks/databases.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# tasks file
---
- name: databases | create
mysql_db:
community.mysql.mysql_db:
name: "{{ item.name }}"
collation: "{{ item.collation | default('utf8_general_ci') }}"
encoding: "{{ item.encoding | default('utf8') }}"
Expand All @@ -11,7 +11,7 @@
- percona-server-databases-create

- name: databases | drop
mysql_db:
community.mysql.mysql_db:
name: "{{ item.name }}"
state: absent
with_items: "{{ percona_server_databases_absent }}"
Expand Down
4 changes: 2 additions & 2 deletions tasks/first-run.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# tasks file
---
- name: first-run | check
shell: >
dpkg-query -W -f='${Status}' percona-server-server-{{ percona_server_version }} | grep -q 'install ok installed'
ansible.builtin.shell: >
dpkg-query -W -f='${Status}' percona-server-server{{ percona_server_version_deb }} | grep -q 'install ok installed'
register: _mysqld_installed
check_mode: no
changed_when: false
Expand Down
17 changes: 9 additions & 8 deletions tasks/ib-logfile.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
# tasks file
---
- name: ib logfile | get datadir
mysql_variables:
community.mysql.mysql_variables:
variable: datadir
register: _datadir_value
tags:
- percona-server-store-datadir
- percona-server-store-datadir-retrieve

- name: ib logfile | store datadir
set_fact:
ansible.builtin.set_fact:
percona_server_datadir: "{{ _datadir_value.msg }}"
tags:
- percona-server-store-datadir
- percona-server-store-datadir-set-fact

# Instead of doing this in main.yml we do it here because of a bug in 2.2.0.0
- block:
- name: ib logfile | first run
when: _mysqld_installed.rc != 0
block:
- name: ib logfile | set InnoDB shutdown mode
mysql_variables:
community.mysql.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 | stop service
service:
ansible.builtin.service:
name: mysql
state: stopped
tags:
- percona-server-ib-logfile-stop-service

- name: ib logfile | remove ib_logfile(s)
file:
ansible.builtin.file:
path: "{{ item }}"
state: absent
with_items:
Expand All @@ -43,9 +45,8 @@
- percona-server-ib-logfile-remove

- name: ib logfile | start service
service:
ansible.builtin.service:
name: mysql
state: started
tags:
- percona-server-ib-logfile-start-service
when: _mysqld_installed.rc != 0
19 changes: 16 additions & 3 deletions tasks/install.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# tasks file
---
- name: install | configure debconf
debconf:
ansible.builtin.debconf:
name: "{{ item.name }}"
question: "{{ item.question }}"
value: "{{ item.value }}"
Expand All @@ -11,15 +11,28 @@
tags:
- percona-server-install-configure-debconf

- name: install | configure debconf for version 8.0 (Use Legacy Authentication Method)
ansible.builtin.debconf:
name: 'percona-server-server'
question: 'percona-server-server/default-auth-override'
value: 'Use Legacy Authentication Method (Retain MySQL 5.x Compatibility)'
vtype: select
changed_when: false
when:
- percona_server_version is version('8.0', '==')
- percona_server_use_legacy_auth_method | bool
tags:
- percona-server-install-configure-debconf

- name: install | dependencies
apt:
ansible.builtin.apt:
name: "{{ percona_server_dependencies }}"
state: "{{ apt_install_state | default('latest') }}"
tags:
- percona-server-install-dependencies

- name: install | additional
apt:
ansible.builtin.apt:
name: "{{ percona_server_install }}"
state: "{{ apt_install_state | default('latest') }}"
tags:
Expand Down
Loading

0 comments on commit 5175937

Please sign in to comment.