From 1249a76a7bd3ea1f851b0e1c159a351dd7fec0b0 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Thu, 19 Apr 2018 14:04:04 +0200 Subject: [PATCH 1/5] Add support for Percona 5.7 --- .travis.yml | 1 + Vagrantfile | 7 ++++ meta/main.yml | 1 + tasks/ib-logfile.yml | 3 +- tasks/install.yml | 17 +++++++++ tasks/main.yml | 86 ++++++++++++++++++++++---------------------- tasks/repository.yml | 13 +++++++ tests/vagrant.yml | 2 ++ vars/main.yml | 1 + 9 files changed, 86 insertions(+), 45 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1f35403..30774ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Vagrantfile b/Vagrantfile index 640b861..0697955 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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| diff --git a/meta/main.yml b/meta/main.yml index 3ed9828..1de64b3 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -16,6 +16,7 @@ galaxy_info: versions: - wheezy - jessie + - stretch galaxy_tags: - system - database diff --git a/tasks/ib-logfile.yml b/tasks/ib-logfile.yml index fbb8075..e65d9fd 100644 --- a/tasks/ib-logfile.yml +++ b/tasks/ib-logfile.yml @@ -8,10 +8,9 @@ - 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 diff --git a/tasks/install.yml b/tasks/install.yml index 4aab74c..4831ad4 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -19,6 +19,23 @@ tags: - percona-server-install-dependencies +- block: + - name: install | service | stop + service: + name: mysql + state: stopped + + - name: install | service | cleanup + file: + path: "{{ item }}" + state: absent + with_items: + - /etc/mysql/percona-server.conf.d/mysqld_safe.cnf + - /etc/mysql/percona-server.conf.d/mysqld.cnf + - /etc/mysql/percona-server.cnf + + when: mysqld_installed.rc != 0 + - name: install | dependencies | check service service: name: mysql diff --git a/tasks/main.yml b/tasks/main.yml index 9a7f362..593b83f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -30,49 +30,49 @@ - percona-server - percona-server-configure -- include: toolkit-udfs.yml - tags: - - configuration - - percona-server - - percona-server-toolkit-udfs - -- include: zoneinfo.yml - tags: - - configuration - - percona-server - - percona-server-zoneinfo - when: percona_server_zoneinfo_manage | bool - -- include: databases.yml - tags: - - configuration - - percona-server - - percona-server-databases - -- include: users.yml - tags: - - configuration - - percona-server - - percona-server-users - -- include: plugins.yml - tags: - - configuration - - percona-server - - percona-server-plugins - -- include: queries.yml - tags: - - configuration - - percona-server - - percona-server-queries - -- include: ib-logfile.yml - tags: - - configuration - - percona-server - - percona-server-ib-logfile - +#- include: toolkit-udfs.yml +# tags: +# - configuration +# - percona-server +# - percona-server-toolkit-udfs +# +#- include: zoneinfo.yml +# tags: +# - configuration +# - percona-server +# - percona-server-zoneinfo +# when: percona_server_zoneinfo_manage | bool +# +#- include: databases.yml +# tags: +# - configuration +# - percona-server +# - percona-server-databases +# +#- include: users.yml +# tags: +# - configuration +# - percona-server +# - percona-server-users +# +#- include: plugins.yml +# tags: +# - configuration +# - percona-server +# - percona-server-plugins +# +#- include: queries.yml +# tags: +# - configuration +# - percona-server +# - percona-server-queries +# +#- include: ib-logfile.yml +# tags: +# - configuration +# - percona-server +# - percona-server-ib-logfile +# - name: start and enable service service: name: mysql diff --git a/tasks/repository.yml b/tasks/repository.yml index b16709e..1dc4ff6 100644 --- a/tasks/repository.yml +++ b/tasks/repository.yml @@ -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 diff --git a/tests/vagrant.yml b/tests/vagrant.yml index d97c872..fa08688 100644 --- a/tests/vagrant.yml +++ b/tests/vagrant.yml @@ -5,3 +5,5 @@ become: true roles: - ../../ + vars: + percona_server_version: 5.7 diff --git a/vars/main.yml b/vars/main.yml index 68519a6..873c2d3 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -3,6 +3,7 @@ percona_server_versions_supported: - '5.5' - '5.6' + - '5.7' percona_server_repositories: - type: deb From 1233034e41ac48c70fa2abff4776800a48069306 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Fri, 20 Apr 2018 11:45:41 +0200 Subject: [PATCH 2/5] Improved configuration logic --- tasks/configure.yml | 31 +++++++++++++++++++++++++++++++ tasks/install.yml | 25 ------------------------- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/tasks/configure.yml b/tasks/configure.yml index ccdea6c..e6034ab 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -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 @@ -23,6 +44,16 @@ tags: - percona-server-configure-global-my-cnf +- block: + - name: configure | service | start + service: + name: mysql + state: started + when: mysqld_installed.rc != 0 + tags: + - percona-server-configure-first-run + - percona-server-configure-first-run-service-start + - name: configure | update (root) configuration file template: src: root/.my.cnf.j2 diff --git a/tasks/install.yml b/tasks/install.yml index 4831ad4..7e62400 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -19,31 +19,6 @@ tags: - percona-server-install-dependencies -- block: - - name: install | service | stop - service: - name: mysql - state: stopped - - - name: install | service | cleanup - file: - path: "{{ item }}" - state: absent - with_items: - - /etc/mysql/percona-server.conf.d/mysqld_safe.cnf - - /etc/mysql/percona-server.conf.d/mysqld.cnf - - /etc/mysql/percona-server.cnf - - when: mysqld_installed.rc != 0 - -- 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 }}" From ee60863124709a910fad3f1fa77364f15afa8745 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Fri, 20 Apr 2018 11:56:00 +0200 Subject: [PATCH 3/5] (Re)enable all other tasks --- tasks/ib-logfile.yml | 11 ++++-- tasks/main.yml | 87 ++++++++++++++++++++++---------------------- 2 files changed, 52 insertions(+), 46 deletions(-) diff --git a/tasks/ib-logfile.yml b/tasks/ib-logfile.yml index e65d9fd..d95ac0b 100644 --- a/tasks/ib-logfile.yml +++ b/tasks/ib-logfile.yml @@ -15,11 +15,18 @@ - percona-server-store-datadir - percona-server-store-datadir-set-fact +- 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 | stop service service: name: mysql state: stopped - when: mysqld_installed.rc != 0 tags: - percona-server-ib-logfile-stop-service @@ -30,7 +37,6 @@ 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 @@ -38,6 +44,5 @@ service: name: mysql state: started - when: mysqld_installed.rc != 0 tags: - percona-server-ib-logfile-start-service diff --git a/tasks/main.yml b/tasks/main.yml index 593b83f..1edf691 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -30,49 +30,50 @@ - percona-server - percona-server-configure -#- include: toolkit-udfs.yml -# tags: -# - configuration -# - percona-server -# - percona-server-toolkit-udfs -# -#- include: zoneinfo.yml -# tags: -# - configuration -# - percona-server -# - percona-server-zoneinfo -# when: percona_server_zoneinfo_manage | bool -# -#- include: databases.yml -# tags: -# - configuration -# - percona-server -# - percona-server-databases -# -#- include: users.yml -# tags: -# - configuration -# - percona-server -# - percona-server-users -# -#- include: plugins.yml -# tags: -# - configuration -# - percona-server -# - percona-server-plugins -# -#- include: queries.yml -# tags: -# - configuration -# - percona-server -# - percona-server-queries -# -#- include: ib-logfile.yml -# tags: -# - configuration -# - percona-server -# - percona-server-ib-logfile -# +- include: toolkit-udfs.yml + tags: + - configuration + - percona-server + - percona-server-toolkit-udfs + +- include: zoneinfo.yml + tags: + - configuration + - percona-server + - percona-server-zoneinfo + when: percona_server_zoneinfo_manage | bool + +- include: databases.yml + tags: + - configuration + - percona-server + - percona-server-databases + +- include: users.yml + tags: + - configuration + - percona-server + - percona-server-users + +- include: plugins.yml + tags: + - configuration + - percona-server + - percona-server-plugins + +- include: queries.yml + tags: + - configuration + - percona-server + - percona-server-queries + +- include: ib-logfile.yml + tags: + - configuration + - percona-server + - percona-server-ib-logfile + when: mysqld_installed.rc != 0 + - name: start and enable service service: name: mysql From 110043d12833fe64ce15126633c704668669c1db Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Fri, 20 Apr 2018 13:23:34 +0200 Subject: [PATCH 4/5] Consistency changes --- tasks/configure.yml | 7 ++++--- tasks/first-run.yml | 5 +++-- tasks/main.yml | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tasks/configure.yml b/tasks/configure.yml index e6034ab..370d97f 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -29,7 +29,7 @@ - /etc/mysql/percona-server.conf.d tags: - percona-server-configure-first-run-cleanup - when: mysqld_installed.rc != 0 + when: _mysqld_installed.rc != 0 tags: - percona-server-configure-first-run @@ -49,10 +49,11 @@ service: name: mysql state: started - when: mysqld_installed.rc != 0 + tags: + - percona-server-configure-first-run-service-start + when: _mysqld_installed.rc != 0 tags: - percona-server-configure-first-run - - percona-server-configure-first-run-service-start - name: configure | update (root) configuration file template: diff --git a/tasks/first-run.yml b/tasks/first-run.yml index 7dbea87..0fe1b84 100644 --- a/tasks/first-run.yml +++ b/tasks/first-run.yml @@ -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: diff --git a/tasks/main.yml b/tasks/main.yml index 1edf691..a1c4b02 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -72,7 +72,7 @@ - configuration - percona-server - percona-server-ib-logfile - when: mysqld_installed.rc != 0 + when: _mysqld_installed.rc != 0 - name: start and enable service service: From 31cd1a0568532ecd40ffb3d55ba7b4a536d5c708 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Fri, 20 Apr 2018 14:11:21 +0200 Subject: [PATCH 5/5] Fix idempotentency in 2.2.0.0 --- tasks/ib-logfile.yml | 61 +++++++++++++++++++++++--------------------- tasks/main.yml | 1 - 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/tasks/ib-logfile.yml b/tasks/ib-logfile.yml index d95ac0b..8f3ce98 100644 --- a/tasks/ib-logfile.yml +++ b/tasks/ib-logfile.yml @@ -10,39 +10,42 @@ - name: ib logfile | store datadir set_fact: - percona_server_datadir: "{{ datadir_value.msg }}" + percona_server_datadir: "{{ datadir_value.msg }}" tags: - percona-server-store-datadir - percona-server-store-datadir-set-fact -- 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 +# 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 | stop service - service: - name: mysql - state: stopped - tags: - - percona-server-ib-logfile-stop-service + - name: ib logfile | stop service + service: + name: mysql + state: stopped + tags: + - percona-server-ib-logfile-stop-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 | 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 + - name: ib logfile | start service + service: + name: mysql + state: started + tags: + - percona-server-ib-logfile-start-service + when: _mysqld_installed.rc != 0 diff --git a/tasks/main.yml b/tasks/main.yml index a1c4b02..9a7f362 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -72,7 +72,6 @@ - configuration - percona-server - percona-server-ib-logfile - when: _mysqld_installed.rc != 0 - name: start and enable service service: