diff --git a/molecule/pxc/pxc57-bootstrap-maj_upgrade/tasks/main.yml b/molecule/pxc/pxc57-bootstrap-maj_upgrade/tasks/main.yml index 499e5440f..97e1832d7 100644 --- a/molecule/pxc/pxc57-bootstrap-maj_upgrade/tasks/main.yml +++ b/molecule/pxc/pxc57-bootstrap-maj_upgrade/tasks/main.yml @@ -1,5 +1,5 @@ --- - - name: Fetch the vars from file for upgrade + - name: Fetch the vars from file ansible.builtin.include_vars: "{{ ENV_VAR_PATH }}" - set_fact: @@ -16,7 +16,7 @@ man_ip: "{{ PXC3_IP }}" when: - "'pxc3' in inventory_hostname" - + - debug: var=man_ip - name: include tasks for test env setup @@ -55,7 +55,17 @@ flush: yes when: ansible_os_family == "RedHat" - - name: install PXC 5.7 previous deb packages + - name: update apt cache debian + apt: + update_cache: yes + when: ansible_os_family == "Debian" + + - name: update rpm cache redhat + yum: + update_cache: yes + when: ansible_os_family == "RedHat" + + - name: install PXC 5.7 deb packages apt: name: "{{ packages }}" update_cache: yes @@ -95,7 +105,7 @@ - python3-pymysql when: (ansible_os_family == "Debian") and (ansible_distribution_release == "buster") - - name: install PXC 5.7 previous rpm packages + - name: install PXC 5.7 rpm packages yum: name: "{{ packages }}" state: latest @@ -103,12 +113,23 @@ packages: - Percona-XtraDB-Cluster-full-57 - Percona-XtraDB-Cluster-57 - when: ansible_os_family == "RedHat" + when: ansible_os_family == "RedHat" environment: PERCONA_TELEMETRY_URL: "https://check-dev.percona.com/v1/telemetry/GenericReport" PERCONA_TELEMETRY_DISABLE: "1" - - name: install python mysql rpm packages + - name: check telemetry (enabled) + command: /package-testing/check_telemetry.sh pxc -e + + - name: get telemetry_uuid content + command: cat /usr/local/percona/telemetry_uuid + register: t_uuid_output + + - name: output telemetry_uuid content + debug: + var: t_uuid_output + + - name: install python mysql rpm packages for CentOS 6 and 7 yum: name: "{{ packages }}" state: latest @@ -117,7 +138,7 @@ - MySQL-python when: ansible_os_family == "RedHat" and (ansible_distribution_major_version != "8" and ansible_distribution_major_version != "9") - - name: install python mysql rpm packages for OL8 and OL9 + - name: install python mysql rpm packages for CentOS 8 yum: name: "{{ packages }}" state: latest @@ -126,7 +147,7 @@ - python3-PyMySQL when: ansible_os_family == "RedHat" and (ansible_distribution_major_version == "8" or ansible_distribution_major_version == "9") - - name: stop mysql service + - name: stop mysql service with service command command: systemctl stop mysql - name: copy pxc config on centos 6 @@ -147,8 +168,8 @@ - name: bootstrap cluster on RHEL7 command: systemctl start mysql@bootstrap.service - when: ((ansible_os_family == "RedHat" and ansible_distribution_major_version >= "7") or (ansible_distribution == "Amazon")) - + when: ansible_os_family == "RedHat" + - name: run the bootstrap service on debian/ubuntu command: service mysql bootstrap-pxc when: ansible_os_family == "Debian" @@ -183,11 +204,14 @@ # other tests - name: install plugins command: /package-testing/plugins_test_57.sh pxc - - - name: register PXC version before upgrade + + - name: register PXC version shell: mysqld --version register: pxc_version - - name: print PXC version before upgrade + - name: print PXC version debug: var=pxc_version - + + - name: check PXC 5.7 version + command: /package-testing/version_check.sh pxc57 + when: lookup('env', 'check_version') == "yes" or lookup('env', 'check_version') == "" \ No newline at end of file diff --git a/molecule/pxc/pxc57-common-install/tasks/main.yml b/molecule/pxc/pxc57-common-install/tasks/main.yml index 6c82985db..919785b83 100644 --- a/molecule/pxc/pxc57-common-install/tasks/main.yml +++ b/molecule/pxc/pxc57-common-install/tasks/main.yml @@ -146,9 +146,9 @@ command: /package-testing/package_check.sh pxc57 when: lookup('env', 'check_version') == "yes" or lookup('env', 'check_version') == "" - - name: run bats tests for mysql init scripts - shell: "sleep {{ sleep_before_tests | default('0') }}; /usr/local/bin/bats /package-testing/bats/pxc-init-scripts.bats" - throttle: 1 +# - name: run bats tests for mysql init scripts +# shell: "sleep {{ sleep_before_tests | default('0') }}; /usr/local/bin/bats /package-testing/bats/pxc-init-scripts.bats" +# throttle: 1 - name: start mysql service command: systemctl start mysql diff --git a/molecule/pxc/pxc57-common-maj_upgrade/molecule/centos-7/molecule.yml b/molecule/pxc/pxc57-common-maj_upgrade/molecule/centos-7/molecule.yml index 152a3010a..5a6330699 100644 --- a/molecule/pxc/pxc57-common-maj_upgrade/molecule/centos-7/molecule.yml +++ b/molecule/pxc/pxc57-common-maj_upgrade/molecule/centos-7/molecule.yml @@ -33,7 +33,7 @@ provisioner: destroy: ../../../../playbooks/destroy.yml prepare: ../../../playbooks/prepare.yml converge: ../../playbooks/playbook.yml - side_effect: ../../../../../playbooks/pxc80_upgrade_bootstrap.yml + side_effect: ../../../../../playbooks/pxc80_upgrade_common.yml inventory: host_vars: pxc2-57-common-centos-7-maj_upgrade: diff --git a/molecule/pxc/pxc57-common-maj_upgrade/molecule/debian-10/molecule.yml b/molecule/pxc/pxc57-common-maj_upgrade/molecule/debian-10/molecule.yml index fa18faa39..d54bc3f55 100644 --- a/molecule/pxc/pxc57-common-maj_upgrade/molecule/debian-10/molecule.yml +++ b/molecule/pxc/pxc57-common-maj_upgrade/molecule/debian-10/molecule.yml @@ -33,7 +33,7 @@ provisioner: destroy: ../../../../playbooks/destroy.yml prepare: ../../../playbooks/prepare.yml converge: ../../playbooks/playbook.yml - side_effect: ../../../../../playbooks/pxc80_upgrade_bootstrap.yml + side_effect: ../../../../../playbooks/pxc80_upgrade_common.yml inventory: host_vars: pxc2-57-common-debian-10-maj_upgrade: diff --git a/molecule/pxc/pxc57-common-maj_upgrade/molecule/debian-11/molecule.yml b/molecule/pxc/pxc57-common-maj_upgrade/molecule/debian-11/molecule.yml index 2d2fa9c11..069f5794f 100644 --- a/molecule/pxc/pxc57-common-maj_upgrade/molecule/debian-11/molecule.yml +++ b/molecule/pxc/pxc57-common-maj_upgrade/molecule/debian-11/molecule.yml @@ -33,7 +33,7 @@ provisioner: destroy: ../../../../playbooks/destroy.yml prepare: ../../../playbooks/prepare.yml converge: ../../playbooks/playbook.yml - side_effect: ../../../../../playbooks/pxc80_upgrade_bootstrap.yml + side_effect: ../../../../../playbooks/pxc80_upgrade_common.yml inventory: host_vars: pxc2-57-common-debian-11-maj_upgrade: diff --git a/molecule/pxc/pxc57-common-maj_upgrade/molecule/debian-12/molecule.yml b/molecule/pxc/pxc57-common-maj_upgrade/molecule/debian-12/molecule.yml index 9e73f0d8f..026e91282 100644 --- a/molecule/pxc/pxc57-common-maj_upgrade/molecule/debian-12/molecule.yml +++ b/molecule/pxc/pxc57-common-maj_upgrade/molecule/debian-12/molecule.yml @@ -33,7 +33,7 @@ provisioner: destroy: ../../../../playbooks/destroy.yml prepare: ../../../playbooks/prepare.yml converge: ../../playbooks/playbook.yml - side_effect: ../../../../../playbooks/pxc80_upgrade_bootstrap.yml + side_effect: ../../../../../playbooks/pxc80_upgrade_common.yml inventory: host_vars: pxc2-57-common-debian-12-maj_upgrade: diff --git a/molecule/pxc/pxc57-common-maj_upgrade/molecule/min-amazon-2/molecule.yml b/molecule/pxc/pxc57-common-maj_upgrade/molecule/min-amazon-2/molecule.yml index 02e5b5516..f4793b2d0 100644 --- a/molecule/pxc/pxc57-common-maj_upgrade/molecule/min-amazon-2/molecule.yml +++ b/molecule/pxc/pxc57-common-maj_upgrade/molecule/min-amazon-2/molecule.yml @@ -33,7 +33,7 @@ provisioner: destroy: ../../../../playbooks/destroy.yml prepare: ../../../playbooks/prepare.yml converge: ../../playbooks/playbook.yml - side_effect: ../../../../../playbooks/pxc80_upgrade_bootstrap.yml + side_effect: ../../../../../playbooks/pxc80_upgrade_common.yml inventory: host_vars: pxc2-57-common-min-amazon-2-maj_upgrade: diff --git a/molecule/pxc/pxc57-common-maj_upgrade/molecule/ol-8/molecule.yml b/molecule/pxc/pxc57-common-maj_upgrade/molecule/ol-8/molecule.yml index 240d56587..abc66ffb8 100644 --- a/molecule/pxc/pxc57-common-maj_upgrade/molecule/ol-8/molecule.yml +++ b/molecule/pxc/pxc57-common-maj_upgrade/molecule/ol-8/molecule.yml @@ -33,7 +33,7 @@ provisioner: destroy: ../../../../playbooks/destroy.yml prepare: ../../../playbooks/prepare.yml converge: ../../playbooks/playbook.yml - side_effect: ../../../../../playbooks/pxc80_upgrade_bootstrap.yml + side_effect: ../../../../../playbooks/pxc80_upgrade_common.yml inventory: host_vars: pxc2-57-common-ol-8-maj_upgrade: diff --git a/molecule/pxc/pxc57-common-maj_upgrade/molecule/ol-9/molecule.yml b/molecule/pxc/pxc57-common-maj_upgrade/molecule/ol-9/molecule.yml index 8ddceb991..2aeaeed07 100644 --- a/molecule/pxc/pxc57-common-maj_upgrade/molecule/ol-9/molecule.yml +++ b/molecule/pxc/pxc57-common-maj_upgrade/molecule/ol-9/molecule.yml @@ -33,7 +33,7 @@ provisioner: destroy: ../../../../playbooks/destroy.yml prepare: ../../../playbooks/prepare.yml converge: ../../playbooks/playbook.yml - side_effect: ../../../../../playbooks/pxc80_upgrade_bootstrap.yml + side_effect: ../../../../../playbooks/pxc80_upgrade_common.yml inventory: host_vars: pxc2-57-common-ol-9-maj_upgrade: diff --git a/molecule/pxc/pxc57-common-maj_upgrade/molecule/ubuntu-bionic/molecule.yml b/molecule/pxc/pxc57-common-maj_upgrade/molecule/ubuntu-bionic/molecule.yml index 85069542b..f2d2d2a3a 100644 --- a/molecule/pxc/pxc57-common-maj_upgrade/molecule/ubuntu-bionic/molecule.yml +++ b/molecule/pxc/pxc57-common-maj_upgrade/molecule/ubuntu-bionic/molecule.yml @@ -33,7 +33,7 @@ provisioner: destroy: ../../../../playbooks/destroy.yml prepare: ../../../playbooks/prepare.yml converge: ../../playbooks/playbook.yml - side_effect: ../../../../../playbooks/pxc80_upgrade_bootstrap.yml + side_effect: ../../../../../playbooks/pxc80_upgrade_common.yml inventory: host_vars: pxc2-57-common-ubuntu-bionic-maj_upgrade: diff --git a/molecule/pxc/pxc57-common-maj_upgrade/molecule/ubuntu-focal/molecule.yml b/molecule/pxc/pxc57-common-maj_upgrade/molecule/ubuntu-focal/molecule.yml index 411cb4df2..032a4fa79 100644 --- a/molecule/pxc/pxc57-common-maj_upgrade/molecule/ubuntu-focal/molecule.yml +++ b/molecule/pxc/pxc57-common-maj_upgrade/molecule/ubuntu-focal/molecule.yml @@ -33,7 +33,7 @@ provisioner: destroy: ../../../../playbooks/destroy.yml prepare: ../../../playbooks/prepare.yml converge: ../../playbooks/playbook.yml - side_effect: ../../../../../playbooks/pxc80_upgrade_bootstrap.yml + side_effect: ../../../../../playbooks/pxc80_upgrade_common.yml inventory: host_vars: pxc2-57-common-ubuntu-focal-maj_upgrade: diff --git a/molecule/pxc/pxc57-common-maj_upgrade/molecule/ubuntu-jammy/molecule.yml b/molecule/pxc/pxc57-common-maj_upgrade/molecule/ubuntu-jammy/molecule.yml index 258915d54..5c4fa1c67 100644 --- a/molecule/pxc/pxc57-common-maj_upgrade/molecule/ubuntu-jammy/molecule.yml +++ b/molecule/pxc/pxc57-common-maj_upgrade/molecule/ubuntu-jammy/molecule.yml @@ -33,7 +33,7 @@ provisioner: destroy: ../../../../playbooks/destroy.yml prepare: ../../../playbooks/prepare.yml converge: ../../playbooks/playbook.yml - side_effect: ../../../../../playbooks/pxc80_upgrade_bootstrap.yml + side_effect: ../../../../../playbooks/pxc80_upgrade_common.yml inventory: host_vars: pxc2-57-common-ubuntu-jammy-maj_upgrade: diff --git a/molecule/pxc/pxc57-common-maj_upgrade/tasks/main.yml b/molecule/pxc/pxc57-common-maj_upgrade/tasks/main.yml index 9d841a6eb..a0a43a086 100644 --- a/molecule/pxc/pxc57-common-maj_upgrade/tasks/main.yml +++ b/molecule/pxc/pxc57-common-maj_upgrade/tasks/main.yml @@ -50,6 +50,16 @@ flush: yes when: ansible_os_family == "RedHat" + - name: update apt cache debian + apt: + update_cache: yes + when: ansible_os_family == "Debian" + + - name: update rpm cache redhat + yum: + update_cache: yes + when: ansible_os_family == "RedHat" +## - name: install PXC 5.7 new deb packages apt: name: "{{ packages }}" @@ -64,23 +74,25 @@ PERCONA_TELEMETRY_URL: "https://check-dev.percona.com/v1/telemetry/GenericReport" PERCONA_TELEMETRY_DISABLE: "1" - - name: install python mysql deb packages for Debian Buster + + - name: install python mysql deb packages apt: name: "{{ packages }}" update_cache: yes vars: packages: - python-mysqldb - when: (ansible_os_family == "Debian") and (ansible_distribution_release == "buster") + when: (ansible_os_family == "Debian") and (ansible_distribution_release != "focal" and ansible_distribution_release != "bionic" and ansible_distribution_release != "bullseye" and ansible_distribution_release != "jammy" and ansible_distribution_release != "bookworm") - - name: install python mysql deb packages except Debian Buster + - name: install python mysql deb packages for focal and bionic apt: name: "{{ packages }}" update_cache: yes vars: packages: - python3-mysqldb - when: (ansible_os_family == "Debian") and (ansible_distribution_release != "buster") + when: (ansible_os_family == "Debian") and (ansible_distribution_release == "focal" or ansible_distribution_release == "bionic" or ansible_distribution_release == "bullseye" or ansible_distribution_release == "jammy" or ansible_distribution_release == "bookworm") + - name: install PXC 5.7 new rpm packages yum: @@ -95,6 +107,9 @@ PERCONA_TELEMETRY_URL: "https://check-dev.percona.com/v1/telemetry/GenericReport" PERCONA_TELEMETRY_DISABLE: "1" + - name: check telemetry (disabled) + command: /package-testing/check_telemetry.sh pxc -d + - name: stop mysql service command: systemctl stop mysql @@ -118,11 +133,11 @@ command: systemctl start mysql throttle: 1 - - name: register PXC version before upgrade + - name: register PXC version shell: mysqld --version register: pxc_version - - name: print PXC version before upgrade + - name: print PXC version debug: var=pxc_version - name: check that PXC version is correct @@ -134,7 +149,7 @@ when: lookup('env', 'check_version') == "yes" or lookup('env', 'check_version') == "" # - name: run bats tests for mysql init scripts -# shell: sleep {{ sleep_before_tests | default('0') }}; /usr/local/bin/bats /package-testing/bats/pxc-init-scripts.bats +# shell: "sleep {{ sleep_before_tests | default('0') }}; /usr/local/bin/bats /package-testing/bats/pxc-init-scripts.bats" # throttle: 1 - name: start mysql service @@ -142,5 +157,14 @@ throttle: 1 - name: Check that the PXC Cluster is up and running - shell: mysql -e "SHOW GLOBAL STATUS LIKE 'wsrep_cluster_size';" | awk '{print$2}' | sed -n '2 p' | grep '3' + shell: mysql -e "SHOW GLOBAL STATUS LIKE 'wsrep_cluster_size';" | awk '{print$2}' | sed -n '2 p' + register: cluster_size_check + + - name: Passed the cluster size check + shell: echo "Passed" + when: cluster_size_check.stdout == "3" + - name: Check the cluster_size_check + ansible.builtin.fail: + msg: "The cluster is less than 3 nodes FAILING the play" + when: cluster_size_check.stdout != "3" \ No newline at end of file diff --git a/playbooks/blank-playbook.yml b/playbooks/blank-playbook.yml new file mode 100644 index 000000000..a6bf73c85 --- /dev/null +++ b/playbooks/blank-playbook.yml @@ -0,0 +1,11 @@ +--- +# This playbook installs PS/PXC client package and checks that it works correctly + +- hosts: all + name: Blank Run + become: true + become_method: sudo + tasks: + - name: Blank Run + debug: + msg: "Blank Run" diff --git a/playbooks/pxc80_upgrade_bootstrap.yml b/playbooks/pxc80_upgrade_bootstrap.yml index 8ee497656..09aae870b 100644 --- a/playbooks/pxc80_upgrade_bootstrap.yml +++ b/playbooks/pxc80_upgrade_bootstrap.yml @@ -6,8 +6,67 @@ become_method: sudo environment: PERCONA_TELEMETRY_URL: "https://check-dev.percona.com/v1/telemetry/GenericReport" - + vars: + ENV_VAR_PATH: "{{ lookup('env', 'MOLECULE_ENV_FILE') }}" tasks: + + - name: Fetch the vars from file for upgrade + ansible.builtin.include_vars: "{{ ENV_VAR_PATH }}" + + - set_fact: + man_ip: "{{ PXC1_IP }}" + when: + - "'pxc1' in inventory_hostname" + + - set_fact: + man_ip: "{{ PXC2_IP }}" + when: + - "'pxc2' in inventory_hostname" + + - set_fact: + man_ip: "{{ PXC3_IP }}" + when: + - "'pxc3' in inventory_hostname" + + - debug: var=man_ip + + - name: Stop PXC bootstrap service RHEL + command: systemctl stop mysql@bootstrap.service + when: ansible_os_family == "RedHat" + ignore_errors: yes + + - name: stop mysql service DEBIAN + command: systemctl stop mysql + when: ansible_os_family == "Debian" + ignore_errors: yes + + - name: sleep for 60 seconds before starting mysql service + shell: sleep 60 + + - name: Start PXC MYSQLD service + command: systemctl start mysqld + when: ansible_os_family == "RedHat" + + - name: start mysql service DEBIAN + command: systemctl start mysql + when: ansible_os_family == "Debian" + + - name: sleep for 60 seconds after starting mysqld service + shell: sleep 60 + + - name: Check that the PXC Cluster is up and running Store in Variable + shell: mysql -e "SHOW GLOBAL STATUS LIKE 'wsrep_cluster_size';" | awk '{print$2}' | sed -n '2 p' | grep '3' + + - name: Stop PXC service RHEL + command: systemctl stop mysqld + when: ansible_os_family == "RedHat" + ignore_errors: yes + + - name: stop mysql service DEBIAN + command: systemctl stop mysql + when: ansible_os_family == "Debian" + ignore_errors: yes + - name: include tasks for removing old PXC 5.7 RHEL yum: name: "{{ packages }}" @@ -15,7 +74,6 @@ vars: packages: - Percona-XtraDB-Cluster* - - percona-xtrabackup* when: ansible_os_family == "RedHat" - name: include tasks for removing old PXC 5.7 deb @@ -27,13 +85,20 @@ - percona-xtradb-cluster* - percona-xtrabackup* when: ansible_os_family == "Debian" +## - - name: remove eol 5.7 repo file + - name: remove eol 5.7 repo file DEB file: - path: /etc/apt/sources.list.d/percona-release.list + path: /etc/apt/sources.list.d/post-eol.list state: absent when: ansible_os_family == "Debian" + - name: remove eol 5.7 repo file RHEL + file: + path: /etc/yum.repos.d/post-eol.repo + state: absent + when: ansible_os_family == "RedHat" + - name: disable old repos command: percona-release disable all @@ -105,9 +170,47 @@ - name: Sleep for 60 seconds shell: sleep 60 + + - name: Remove old config + file: + path: /etc/my.cnf + state: absent + when: ansible_os_family == "RedHat" + + - name: copy pxc config on centos + template: src=../templates/rhel_maj_upgrade_57_80.j2 + dest=/etc/my.cnf + when: ansible_os_family == "RedHat" + + - name: copy pxc config on debian/ubuntu + template: src=../templates/deb_maj_upgrade_57_80.j2 + dest=/etc/mysql/my.cnf + mode=0640 owner=mysql group=root + when: ansible_os_family == "Debian" + + - name: copy pxc certs + copy: + src: ../support-files/certs/ + dest: /etc/mysql/certs/ + +# - name: edit the grastat.dat file for safe bootstrap +# lineinfile: +# path: /var/lib/mysql/grastate.dat +# regexp: 'safe_to_bootstrap: 0' +# line: 'safe_to_bootstrap: 1' + + - name: Start PXC RHEL + service: + name: mysqld + state: started + when: ansible_os_family == "RedHat" + + - name: start mysqld service DEBIAN + command: systemctl start mysql + when: ansible_os_family == "Debian" - - name: install plugins - command: /package-testing/plugins_test_80.sh pxc +# - name: install plugins +# command: /package-testing/plugins_test_80.sh pxc - name: register PXC version Side Effect shell: mysqld --version @@ -116,10 +219,11 @@ - name: print PXC version Side Effect debug: var=pxc_version - - name: check that PXC version is correct Side Effect - command: /package-testing/version_check.sh pxc80 - when: lookup('env', 'check_version') == "yes" or lookup('env', 'check_version') == "" +# - name: check that PXC version is correct Side Effect +# command: /package-testing/version_check.sh pxc80 +# when: lookup('env', 'check_version') == "yes" or lookup('env', 'check_version') == "" - - name: check that PXC package versions are correct Side Effect - command: /package-testing/package_check.sh pxc80 - when: lookup('env', 'check_version') == "yes" or lookup('env', 'check_version') == "" +# - name: check that PXC package versions are correct Side Effect +# command: /package-testing/package_check.sh pxc80 +# when: lookup('env', 'check_version') == "yes" or lookup('env', 'check_version') == "" + diff --git a/playbooks/pxc80_upgrade_common.yml b/playbooks/pxc80_upgrade_common.yml index 1ac78530c..4e15cb040 100644 --- a/playbooks/pxc80_upgrade_common.yml +++ b/playbooks/pxc80_upgrade_common.yml @@ -6,9 +6,66 @@ become_method: sudo environment: PERCONA_TELEMETRY_URL: "https://check-dev.percona.com/v1/telemetry/GenericReport" - + vars: + ENV_VAR_PATH: "{{ lookup('env', 'MOLECULE_ENV_FILE') }}" tasks: + - name: Fetch the vars from file for upgrade + ansible.builtin.include_vars: "{{ ENV_VAR_PATH }}" + + - set_fact: + man_ip: "{{ PXC1_IP }}" + when: + - "'pxc1' in inventory_hostname" + + - set_fact: + man_ip: "{{ PXC2_IP }}" + when: + - "'pxc2' in inventory_hostname" + + - set_fact: + man_ip: "{{ PXC3_IP }}" + when: + - "'pxc3' in inventory_hostname" + + - debug: var=man_ip + + - name: Stop PXC mysqld service RHEL on Node PXC2 + command: systemctl stop mysqld + when: + - ansible_os_family == "RedHat" + - "'pxc2' in inventory_hostname" + ignore_errors: yes + + - name: Sleep for 30 seconds on RHEL + shell: sleep 30 + when: ansible_os_family == "RedHat" + + - name: Stop PXC mysqld service RHEL on Node PXC3 + command: systemctl stop mysqld + when: + - ansible_os_family == "RedHat" + - "'pxc3' in inventory_hostname" + ignore_errors: yes + + - name: stop mysql service DEBIAN on Node PXC2 + command: systemctl stop mysql + when: + - ansible_os_family == "Debian" + - "'pxc2' in inventory_hostname" + ignore_errors: yes + + - name: Sleep 30 seconds on Debian + shell: sleep 30 + when: ansible_os_family == "Debian" + + - name: stop mysql service DEBIAN on Node PXC3 + command: systemctl stop mysql + when: + - ansible_os_family == "Debian" + - "'pxc3' in inventory_hostname" + ignore_errors: yes + - name: include tasks for removing old PXC 5.7 RHEL yum: name: "{{ packages }}" @@ -16,7 +73,6 @@ vars: packages: - Percona-XtraDB-Cluster* - - percona-xtrabackup* when: ansible_os_family == "RedHat" - name: include tasks for removing old PXC 5.7 deb @@ -29,12 +85,24 @@ - percona-xtrabackup* when: ansible_os_family == "Debian" - - name: remove eol 5.7 repo file + - name: Remove old config file: - path: /etc/apt/sources.list.d/percona-release.list + path: /etc/my.cnf + state: absent + when: ansible_os_family == "RedHat" + + - name: remove eol 5.7 repo file DEB + file: + path: /etc/apt/sources.list.d/post-eol.list state: absent when: ansible_os_family == "Debian" + - name: remove eol 5.7 repo file RHEL + file: + path: /etc/yum.repos.d/post-eol.repo + state: absent + when: ansible_os_family == "RedHat" + - name: disable old repos command: percona-release disable all @@ -109,13 +177,52 @@ packages: - percona-xtradb-cluster-shared-compat when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "7" + + - name: copy pxc config on RHEL + template: src=../templates/rhel_maj_upgrade_57_80.j2 + dest=/etc/my.cnf + when: ansible_os_family == "RedHat" + + - name: copy pxc config on DEBIAN + template: src=../templates/deb_maj_upgrade_57_80.j2 + dest=/etc/mysql/my.cnf + mode=0640 owner=mysql group=root + when: ansible_os_family == "Debian" - name: Sleep for 60 seconds shell: sleep 60 - - name: start mysql service - service: name=mysql state=restarted - throttle: 1 + - name: start mysqld service on PXC2 Node RHEL + service: name=mysqld state=started + when: + - ansible_os_family == "RedHat" + - "'pxc2' in inventory_hostname" + + - name: Sleep 30 seconds on RHEL + shell: sleep 30 + when: ansible_os_family == "RedHat" + + - name: start mysqld service on PXC3 Node RHEL + service: name=mysqld state=started + when: + - ansible_os_family == "RedHat" + - "'pxc3' in inventory_hostname" + + - name: start mysql service DEBIAN PXC2 Node + command: systemctl start mysql + when: + - ansible_os_family == "Debian" + - "'pxc2' in inventory_hostname" + + - name: Sleep 30 seconds on DEBIAN + shell: sleep 30 + when: ansible_os_family == "Debian" + + - name: start mysql service DEBIAN PXC3 NODE + command: systemctl start mysql + when: + - ansible_os_family == "Debian" + - "'pxc3' in inventory_hostname" - name: register PXC version Side Effect shell: mysqld --version diff --git a/tasks/enable_pxc57_eol_tools_repo.yml b/tasks/enable_pxc57_eol_tools_repo.yml index c9b845ffa..6fb1d49be 100644 --- a/tasks/enable_pxc57_eol_tools_repo.yml +++ b/tasks/enable_pxc57_eol_tools_repo.yml @@ -16,7 +16,7 @@ vars: client_id: "{{ lookup('env', 'USERNAME') }}" client_token: "{{ lookup('env', 'PASSWORD') }}" - repo: "testing" + repo: "main" when: - ansible_os_family == "Debian" @@ -26,7 +26,7 @@ vars: client_id: "{{ lookup('env', 'USERNAME') }}" client_token: "{{ lookup('env', 'PASSWORD') }}" - repo: "testing" + repo: "release" when: - ansible_os_family == "RedHat" diff --git a/templates/deb_maj_upgrade_57_80.j2 b/templates/deb_maj_upgrade_57_80.j2 new file mode 100644 index 000000000..35c2adcba --- /dev/null +++ b/templates/deb_maj_upgrade_57_80.j2 @@ -0,0 +1,73 @@ +# Template my.cnf for PXC +# Edit to your requirements. +[client] +socket=/var/run/mysqld/mysqld.sock + +[mysqld] +server-id=1 +datadir=/var/lib/mysql +socket=/var/run/mysqld/mysqld.sock +log-error=/var/log/mysql/error.log +pid-file=/var/run/mysqld/mysqld.pid +expire_logs_days=7 +log_error_verbosity=3 + +# Disabling symbolic-links is recommended to prevent assorted security risks +symbolic-links=0 + +######## wsrep ############### +# Path to Galera library +wsrep_provider=/usr/lib/galera4/libgalera_smm.so + +# Cluster connection URL contains IPs of nodes +#If no IP is found, this implies that a new cluster needs to be created, +#in order to do that you need to bootstrap this node +wsrep_cluster_address=gcomm://{{ lookup('env', "PXC1_IP") | default("192.168.70.61", true) }},{{ lookup('env', "PXC2_IP") | default("192.168.70.62", true) }},{{ lookup('env', "PXC3_IP") | default("192.168.70.63", true) }} + +# Disable encryption +pxc_encrypt_cluster_traffic=OFF + +# In order for Galera to work correctly binlog format should be ROW +binlog_format=ROW + +# Slave thread to use +wsrep_slave_threads= 8 + +wsrep_log_conflicts + +# This changes how InnoDB autoincrement locks are managed and is a requirement for Galera +innodb_autoinc_lock_mode=2 + +# Node IP address +wsrep_node_address={{ man_ip }} + +# Cluster name +wsrep_cluster_name=my_ubuntu_cluster + +#If wsrep_node_name is not specified, then system hostname will be used +wsrep_node_name={{ man_ip }} + +#pxc_strict_mode allowed values: DISABLED,PERMISSIVE,ENFORCING,MASTER +pxc_strict_mode=PERMISSIVE + +# SST method +wsrep_sst_method=xtrabackup-v2 + +#Certs + +[mysqld] +ssl-ca = /etc/mysql/certs/ca.pem +ssl-cert = /etc/mysql/certs/server-cert.pem +ssl-key = /etc/mysql/certs/server-key.pem + +[client] +ssl-ca = /etc/mysql/certs/ca.pem +ssl-cert = /etc/mysql/certs/client-cert.pem +ssl-key = /etc/mysql/certs/client-key.pem + +########################################### + +[mysqld_safe] +pid-file = /var/run/mysqld/mysqld.pid +socket = /var/run/mysqld/mysqld.sock +nice = 0 diff --git a/templates/my.j2 b/templates/my.j2 index 9aebb25c2..775d6a097 100644 --- a/templates/my.j2 +++ b/templates/my.j2 @@ -23,7 +23,7 @@ innodb_autoinc_lock_mode=2 # Node address wsrep_node_address={{ man_ip }} - +wsrep_node_name={{ man_ip }} # SST method wsrep_sst_method=xtrabackup-v2 diff --git a/templates/my_rpm_7.j2 b/templates/my_rpm_7.j2 index c363c698c..eaf43c2bf 100644 --- a/templates/my_rpm_7.j2 +++ b/templates/my_rpm_7.j2 @@ -25,7 +25,7 @@ innodb_autoinc_lock_mode=2 # Node address wsrep_node_address={{ man_ip }} - +wsrep_node_name={{ man_ip }} # SST method wsrep_sst_method=xtrabackup-v2 diff --git a/templates/rhel_maj_upgrade_57_80.j2 b/templates/rhel_maj_upgrade_57_80.j2 new file mode 100644 index 000000000..6f29738ab --- /dev/null +++ b/templates/rhel_maj_upgrade_57_80.j2 @@ -0,0 +1,46 @@ +# Edit to your requirements. +[client] +socket=/var/lib/mysql/mysql.sock +[mysqld] +upgrade=FORCE +skip-log-bin +server-id=1 +datadir=/var/lib/mysql +socket=/var/lib/mysql/mysql.sock +log-error=/var/log/mysqld.log +pid-file=/var/run/mysqld/mysqld.pid +# Binary log expiration period is 604800 seconds, which equals 7 days +binlog_expire_logs_seconds=604800 +######## wsrep ############### +# Path to Galera library +wsrep_provider=/usr/lib64/galera4/libgalera_smm.so +# Cluster connection URL contains IPs of nodes +#If no IP is found, this implies that a new cluster needs to be created, +#in order to do that you need to bootstrap this node +wsrep_cluster_address=gcomm://{{ lookup('env', "PXC1_IP") | default("192.168.70.61") }},{{ lookup('env', "PXC2_IP") | default("192.168.70.62") }},{{ lookup('env', "PXC3_IP") | default("192.168.70.63") }} +# In order for Galera to work correctly binlog format should be ROW +binlog_format=ROW +# Slave thread to use +wsrep_slave_threads=8 +wsrep_log_conflicts +# This changes how InnoDB autoincrement locks are managed and is a requirement for Galera +innodb_autoinc_lock_mode=2 +# Node IP address +wsrep_node_address={{ man_ip }} +# Cluster name +wsrep_cluster_name=my_ubuntu_cluster +#If wsrep_node_name is not specified, then system hostname will be used +wsrep_node_name={{ man_ip }} +#pxc_strict_mode allowed values: DISABLED,PERMISSIVE,ENFORCING,MASTER +pxc_strict_mode=DISABLED +pxc_encrypt_cluster_traffic=OFF +# SST method +wsrep_sst_method=xtrabackup-v2 +[mysqld] +ssl-ca = /etc/mysql/certs/ca.pem +ssl-cert = /etc/mysql/certs/server-cert.pem +ssl-key = /etc/mysql/certs/server-key.pem +[client] +ssl-ca = /etc/mysql/certs/ca.pem +ssl-cert = /etc/mysql/certs/client-cert.pem +ssl-key = /etc/mysql/certs/client-key.pem