diff --git a/CHANGELOG.md b/CHANGELOG.md index 075dd44a9..40b881ce0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +- [Apt] Add Mysql 8.4 support +- [Apt] Add Galera 4.21 and MySQL wsrep 8.4.3 repositories +- [MySQL] Mysql 8.4 support +- [MySQL] Change `manala_mysql_install_python_packages` from `python3-mysqldb` to `python3-pymysql`. (See https://github.com/ansible-collections/community.mysql/pull/655 and https://github.com/ansible-collections/community.mysql/issues/659) ## [4.3.0] - 2024-10-09 ### Added diff --git a/molecule/mysql.8.0/converge.yml b/molecule/mysql.8.0/converge.yml index 480d125f4..9a291047f 100644 --- a/molecule/mysql.8.0/converge.yml +++ b/molecule/mysql.8.0/converge.yml @@ -6,9 +6,7 @@ - name: Default tags: [default] - hosts: - - debian.buster - - debian.bullseye + hosts: debian tasks: - block: # noqa: name[missing] - name: Role @@ -34,353 +32,3 @@ cmd: goss --gossfile - validate stdin: "{{ lookup('ansible.builtin.template', 'goss/default.yaml.j2') }}" changed_when: false - -########## -# Client # -########## - -- name: Client - tags: [client] - hosts: - - debian.buster - - debian.bullseye - tasks: - - name: Packages absent - ansible.builtin.apt: - name: - - mysql-server - - mysql-client - state: absent - - block: # noqa: name[missing] - - name: Role - ansible.builtin.import_role: - name: manala.roles.mysql - vars: - manala_mysql_server: false - always: - - name: Goss - ansible.builtin.command: - cmd: goss --gossfile - validate - stdin: "{{ lookup('ansible.builtin.template', 'goss/client.yaml.j2') }}" - changed_when: false - -########## -# Config # -########## - -- name: Config - tags: [config] - hosts: - - debian.buster - - debian.bullseye - vars: - tests_dir: /molecule/mysql/config - tasks: - - name: Clean tests dir - ansible.builtin.file: # noqa: risky-file-permissions - path: "{{ tests_dir }}" - state: "{{ item }}" - loop: [absent, directory] - - block: # noqa: name[missing] - - name: Role - Dict - ansible.builtin.import_role: - # Play role fully on first run, so that handlers don't breaks - name: manala.roles.mysql - vars: - manala_mysql_config_file: "{{ tests_dir }}/dict" - manala_mysql_config_template: ~ - manala_mysql_config: - mysqld: - bind-address: 1.2.3.4 - pid-file: /var/run/mysqld/mysqld.pid - - name: Role - Content - ansible.builtin.import_role: - name: manala.roles.mysql - tasks_from: config - vars: - manala_mysql_config_file: "{{ tests_dir }}/content" - manala_mysql_config_template: ~ - manala_mysql_config: | - Content - - name: Role - Template - ansible.builtin.import_role: - name: manala.roles.mysql - tasks_from: config - vars: - manala_mysql_config_file: "{{ tests_dir }}/template" - manala_mysql_config_template: fixtures/template.j2 - manala_mysql_config: ~ - always: - - name: Goss - ansible.builtin.command: - cmd: goss --gossfile - validate - stdin: "{{ lookup('ansible.builtin.template', 'goss/config.yaml.j2') }}" - changed_when: false - -########### -# Configs # -########### - -- name: Configs - tags: [configs] - hosts: - - debian.buster - - debian.bullseye - vars: - tests_dir: /molecule/mysql/configs - tasks: - - name: Clean tests dir - ansible.builtin.file: # noqa: risky-file-permissions - path: "{{ tests_dir }}/{{ item.0 }}" - state: "{{ item.1 }}" - loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" - - name: Touch existing files - ansible.builtin.file: # noqa: risky-file-permissions - path: "{{ tests_dir }}/{{ item }}" - state: touch - loop: [ - default/state_absent_existing, default/state_ignore_existing, - exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, - ] - - block: # noqa: name[missing] - - name: Role - Default - ansible.builtin.import_role: - # Play role fully on first run, so that handlers don't breaks - name: manala.roles.mysql - vars: - manala_mysql_configs_exclusive: false - manala_mysql_configs_dir: "{{ tests_dir }}/default" - manala_mysql_configs_defaults: {} - manala_mysql_configs: - # Dict - - file: dict - config: - mysqld: - user: mysql - query_cache_size: 0 - gtid_mode: true - enforce_gtid_consistency: false - # Content - - file: content - config: | - Content - # Template - - file: template - template: fixtures/template.j2 - - template: fixtures/template_file.j2 - # Flatten - - - - file: flatten - # State - - file: state_present_implicit - - file: state_present - state: present - - file: state_absent - state: absent - - file: state_absent_existing - state: absent - - file: state_ignore - state: ignore - - file: state_ignore_existing - state: ignore - - name: Role - Defaults - ansible.builtin.import_role: - name: manala.roles.mysql - tasks_from: configs - vars: - manala_mysql_configs_exclusive: false - manala_mysql_configs_dir: "{{ tests_dir }}/defaults" - manala_mysql_configs_defaults: - template: fixtures/template.j2 - manala_mysql_configs: - - file: template - - template: fixtures/template_file.j2 - - file: template_overwrite - template: fixtures/template_file.j2 - - name: Role - Exclusive - ansible.builtin.import_role: - name: manala.roles.mysql - tasks_from: configs - vars: - manala_mysql_configs_exclusive: true - manala_mysql_configs_dir: "{{ tests_dir }}/exclusive" - manala_mysql_configs_defaults: {} - manala_mysql_configs: - - file: existing_present - - file: existing_ignore - state: ignore - - file: ignore - state: ignore - always: - - name: Goss - ansible.builtin.command: - cmd: goss --gossfile - validate - stdin: "{{ lookup('ansible.builtin.template', 'goss/configs.yaml.j2') }}" - changed_when: false - -######## -# Data # -######## - -- name: Data - tags: [data] - hosts: - - debian.buster - - debian.bullseye - vars: - tests_dir: /molecule/mysql/data - tasks: - - name: Clean tests dir - ansible.builtin.file: # noqa: risky-file-permissions - path: "{{ tests_dir }}" - state: "{{ item }}" - loop: [absent, directory] - - block: # noqa: name[missing] - - name: Role - ansible.builtin.import_role: - name: manala.roles.mysql - vars: - manala_mysql_config: | - [mysqld] - pid-file = /var/run/mysqld/mysqld.pid - socket = /var/run/mysqld/mysqld.sock - log-error = /var/log/mysql/error.log - datadir = {{ tests_dir }}/data - # Use native authentication plugin - default-authentication-plugin = mysql_native_password - manala_mysql_data_dir: "{{ tests_dir }}/data" - manala_mysql_data_dir_user: mysql - manala_mysql_data_dir_group: root - manala_mysql_data_dir_mode: "0700" - always: - - name: Goss - ansible.builtin.command: - cmd: goss --gossfile - validate - stdin: "{{ lookup('ansible.builtin.template', 'goss/data.yaml.j2') }}" - changed_when: false - -######### -# Users # -######### - -- name: Users - tags: [users] - hosts: - - debian.buster - - debian.bullseye - tasks: - - name: Role - Default - ansible.builtin.import_role: - # Play role fully on first run, to install python modules - name: manala.roles.mysql - vars: - manala_mysql_configs: - # Use native authentication plugin - - file: auth.cnf - config: - mysqld: - default-authentication-plugin: mysql_native_password - manala_mysql_users: - - name: bar - state: absent - - name: Create users to absent/ignore later - community.mysql.mysql_user: - user: "{{ item }}" - state: present - loop: [ - state_absent_existing, state_ignore_existing, - ] - - block: # noqa: name[missing] - - name: Role - ansible.builtin.import_role: - name: manala.roles.mysql - vars: - manala_mysql_users: - # Privileges and password - - name: foo - password: foo - host: localhost - priv: "*.*:ALL,GRANT" - # States - - name: state_present_implicit - - name: state_present - state: present - - name: state_absent - state: absent - - name: state_absent_existing - state: absent - - name: state_ignored - state: ignore - - name: state_ignore_existing - state: ignore - # Flatten - - - - name: baz - password: baz - host: localhost - priv: "*.*:ALL,GRANT" - always: - - name: Goss - ansible.builtin.command: - cmd: goss --gossfile - validate - stdin: "{{ lookup('ansible.builtin.template', 'goss/users.yaml.j2') }}" - changed_when: false - -############# -# Databases # -############# - -- name: Databases - tags: [databases] - hosts: - - debian.buster - - debian.bullseye - tasks: - - name: Role - Default - ansible.builtin.import_role: - # Play role fully on first run, to install python modules - name: manala.roles.mysql - vars: - manala_mysql_configs: - # Use native authentication plugin - - file: auth.cnf - config: - mysqld: - default-authentication-plugin: mysql_native_password - manala_mysql_databases: - - name: bar - state: absent - - name: Create databases to absent/ignore later - community.mysql.mysql_db: - name: "{{ item }}" - state: present - loop: [ - state_absent_existing, state_ignore_existing, - ] - - block: # noqa: name[missing] - - name: Role - ansible.builtin.import_role: - name: manala.roles.mysql - vars: - manala_mysql_databases: - # States - - name: state_present_implicit - - name: state_present - state: present - - name: state_absent - state: absent - - name: state_absent_existing - state: absent - - name: state_ignored - state: ignore - - name: state_ignore_existing - state: ignore - # Flatten - - - - name: baz - always: - - name: Goss - ansible.builtin.command: - cmd: goss --gossfile - validate - stdin: "{{ lookup('ansible.builtin.template', 'goss/databases.yaml.j2') }}" - changed_when: false diff --git a/molecule/mysql.8.0/prepare.yml b/molecule/mysql.8.0/prepare.yml index f7b8a554d..368b4b4b5 100644 --- a/molecule/mysql.8.0/prepare.yml +++ b/molecule/mysql.8.0/prepare.yml @@ -2,9 +2,7 @@ - name: Prepare tags: [always] - hosts: - - debian.buster - - debian.bullseye + hosts: debian tasks: - name: Apt ansible.builtin.import_role: diff --git a/molecule/mysql.8.4/converge.yml b/molecule/mysql.8.4/converge.yml new file mode 100644 index 000000000..6d6e76a0a --- /dev/null +++ b/molecule/mysql.8.4/converge.yml @@ -0,0 +1,417 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian + - "!debian.buster" + tasks: + - block: # noqa: name[missing] + - name: Role + ansible.builtin.import_role: + name: manala.roles.mysql + vars: + manala_mysql_configs: + # Use native authentication plugin + - file: auth.cnf + config: + mysqld: + mysql_native_password: 'ON' + manala_mysql_users: + - name: foo + password: foo + host: localhost + priv: "*.*:ALL,GRANT" + login_unix_socket: /var/run/mysqld/mysqld.sock + manala_mysql_databases: + - name: foo + login_unix_socket: /var/run/mysqld/mysqld.sock + always: + - name: Goss + ansible.builtin.command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('ansible.builtin.template', 'goss/default.yaml.j2') }}" + changed_when: false + +########## +# Client # +########## + +- name: Client + tags: [client] + hosts: + - debian + - "!debian.buster" + tasks: + - name: Packages absent + ansible.builtin.apt: + name: + - mysql-server + - mysql-client + state: absent + - block: # noqa: name[missing] + - name: Role + ansible.builtin.import_role: + name: manala.roles.mysql + vars: + manala_mysql_server: false + always: + - name: Goss + ansible.builtin.command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('ansible.builtin.template', 'goss/client.yaml.j2') }}" + changed_when: false + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: + - debian + - "!debian.buster" + vars: + tests_dir: /molecule/mysql/config + tasks: + - name: Clean tests dir + ansible.builtin.file: # noqa: risky-file-permissions + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: # noqa: name[missing] + - name: Role - Dict + ansible.builtin.import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.mysql + vars: + manala_mysql_config_file: "{{ tests_dir }}/dict" + manala_mysql_config_template: ~ + manala_mysql_config: + mysqld: + bind-address: 1.2.3.4 + pid-file: /var/run/mysqld/mysqld.pid + - name: Role - Content + ansible.builtin.import_role: + name: manala.roles.mysql + tasks_from: config + vars: + manala_mysql_config_file: "{{ tests_dir }}/content" + manala_mysql_config_template: ~ + manala_mysql_config: | + Content + - name: Role - Template + ansible.builtin.import_role: + name: manala.roles.mysql + tasks_from: config + vars: + manala_mysql_config_file: "{{ tests_dir }}/template" + manala_mysql_config_template: fixtures/template.j2 + manala_mysql_config: ~ + always: + - name: Goss + ansible.builtin.command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('ansible.builtin.template', 'goss/config.yaml.j2') }}" + changed_when: false + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: + - debian + - "!debian.buster" + vars: + tests_dir: /molecule/mysql/configs + tasks: + - name: Clean tests dir + ansible.builtin.file: # noqa: risky-file-permissions + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files + ansible.builtin.file: # noqa: risky-file-permissions + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: # noqa: name[missing] + - name: Role - Default + ansible.builtin.import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.mysql + vars: + manala_mysql_configs_exclusive: false + manala_mysql_configs_dir: "{{ tests_dir }}/default" + manala_mysql_configs_defaults: {} + manala_mysql_configs: + # Dict + - file: dict + config: + mysqld: + user: mysql + query_cache_size: 0 + gtid_mode: true + enforce_gtid_consistency: false + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + ansible.builtin.import_role: + name: manala.roles.mysql + tasks_from: configs + vars: + manala_mysql_configs_exclusive: false + manala_mysql_configs_dir: "{{ tests_dir }}/defaults" + manala_mysql_configs_defaults: + template: fixtures/template.j2 + manala_mysql_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + ansible.builtin.import_role: + name: manala.roles.mysql + tasks_from: configs + vars: + manala_mysql_configs_exclusive: true + manala_mysql_configs_dir: "{{ tests_dir }}/exclusive" + manala_mysql_configs_defaults: {} + manala_mysql_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + ansible.builtin.command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('ansible.builtin.template', 'goss/configs.yaml.j2') }}" + changed_when: false + +######## +# Data # +######## + +- name: Data + tags: [data] + hosts: + - debian + - "!debian.buster" + vars: + tests_dir: /molecule/mysql/data + tasks: + - name: Clean tests dir + ansible.builtin.file: # noqa: risky-file-permissions + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: # noqa: name[missing] + - name: Role + ansible.builtin.import_role: + name: manala.roles.mysql + vars: + manala_mysql_config: | + [mysqld] + pid-file = /var/run/mysqld/mysqld.pid + socket = /var/run/mysqld/mysqld.sock + log-error = /var/log/mysql/error.log + datadir = {{ tests_dir }}/data + manala_mysql_data_dir: "{{ tests_dir }}/data" + manala_mysql_data_dir_user: mysql + manala_mysql_data_dir_group: root + manala_mysql_data_dir_mode: "0700" + always: + - name: Goss + ansible.builtin.command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('ansible.builtin.template', 'goss/data.yaml.j2') }}" + changed_when: false + +######### +# Users # +######### + +- name: Users + tags: [users] + hosts: + - debian + - "!debian.buster" + tasks: + - name: Role - Default + ansible.builtin.import_role: + # Play role fully on first run, to install python modules + name: manala.roles.mysql + vars: + manala_mysql_configs: + # Use native authentication plugin + - file: auth.cnf + config: + mysqld: + mysql_native_password: 'ON' + manala_mysql_users: + - name: bar + state: absent + login_unix_socket: /var/run/mysqld/mysqld.sock + - name: Create users to absent/ignore later + community.mysql.mysql_user: + name: "{{ item }}" + state: present + login_unix_socket: /var/run/mysqld/mysqld.sock + loop: [ + state_absent_existing, state_ignore_existing, + ] + - block: # noqa: name[missing] + - name: Role + ansible.builtin.import_role: + name: manala.roles.mysql + vars: + manala_mysql_configs: + # Use native authentication plugin + - file: auth.cnf + config: + mysqld: + mysql_native_password: 'ON' + manala_mysql_users: + # Privileges and password + - name: foo + password: foo + host: localhost + priv: "*.*:ALL,GRANT" + login_unix_socket: /var/run/mysqld/mysqld.sock + # States + - name: state_present_implicit + login_unix_socket: /var/run/mysqld/mysqld.sock + - name: state_present + state: present + login_unix_socket: /var/run/mysqld/mysqld.sock + - name: state_absent + state: absent + login_unix_socket: /var/run/mysqld/mysqld.sock + - name: state_absent_existing + state: absent + login_unix_socket: /var/run/mysqld/mysqld.sock + - name: state_ignored + state: ignore + login_unix_socket: /var/run/mysqld/mysqld.sock + - name: state_ignore_existing + state: ignore + login_unix_socket: /var/run/mysqld/mysqld.sock + # Flatten + - + - name: baz + password: baz + host: localhost + priv: "*.*:ALL,GRANT" + login_unix_socket: /var/run/mysqld/mysqld.sock + always: + - name: Goss + ansible.builtin.command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('ansible.builtin.template', 'goss/users.yaml.j2') }}" + changed_when: false + +############# +# Databases # +############# + +- name: Databases + tags: [databases] + hosts: + - debian + - "!debian.buster" + tasks: + - name: Role - Default + ansible.builtin.import_role: + # Play role fully on first run, to install python modules + name: manala.roles.mysql + vars: + manala_mysql_configs: + # Use native authentication plugin + - file: auth.cnf + config: + mysqld: + mysql_native_password: 'ON' + manala_mysql_databases: + - name: bar + state: absent + login_unix_socket: /var/run/mysqld/mysqld.sock + - name: Create databases to absent/ignore later + community.mysql.mysql_db: + name: "{{ item }}" + state: present + login_unix_socket: /var/run/mysqld/mysqld.sock + loop: [ + state_absent_existing, state_ignore_existing, + ] + - block: # noqa: name[missing] + - name: Role + ansible.builtin.import_role: + name: manala.roles.mysql + vars: + manala_mysql_configs: + # Use native authentication plugin + - file: auth.cnf + config: + mysqld: + mysql_native_password: 'ON' + manala_mysql_databases: + # States + - name: state_present_implicit + login_unix_socket: /var/run/mysqld/mysqld.sock + - name: state_present + state: present + login_unix_socket: /var/run/mysqld/mysqld.sock + - name: state_absent + state: absent + login_unix_socket: /var/run/mysqld/mysqld.sock + - name: state_absent_existing + state: absent + login_unix_socket: /var/run/mysqld/mysqld.sock + - name: state_ignored + state: ignore + login_unix_socket: /var/run/mysqld/mysqld.sock + - name: state_ignore_existing + state: ignore + login_unix_socket: /var/run/mysqld/mysqld.sock + # Flatten + - + - name: baz + login_unix_socket: /var/run/mysqld/mysqld.sock + always: + - name: Goss + ansible.builtin.command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('ansible.builtin.template', 'goss/databases.yaml.j2') }}" + changed_when: false diff --git a/molecule/mysql.8.4/fixtures/template.j2 b/molecule/mysql.8.4/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/mysql.8.4/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/mysql.8.4/fixtures/template_file.j2 b/molecule/mysql.8.4/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/mysql.8.4/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/mysql.8.4/goss/client.yaml.j2 b/molecule/mysql.8.4/goss/client.yaml.j2 new file mode 100644 index 000000000..010adceae --- /dev/null +++ b/molecule/mysql.8.4/goss/client.yaml.j2 @@ -0,0 +1,7 @@ +--- + +package: + mysql-server: + installed: false + mysql-client: + installed: true diff --git a/molecule/mysql.8.4/goss/config.yaml.j2 b/molecule/mysql.8.4/goss/config.yaml.j2 new file mode 100644 index 000000000..4dc00b983 --- /dev/null +++ b/molecule/mysql.8.4/goss/config.yaml.j2 @@ -0,0 +1,29 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contents: | + [mysqld] + bind-address = 1.2.3.4 + pid-file = /var/run/mysqld/mysqld.pid + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contents: | + Content + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contents: | + Template diff --git a/molecule/mysql.8.4/goss/configs.yaml.j2 b/molecule/mysql.8.4/goss/configs.yaml.j2 new file mode 100644 index 000000000..d7a6ce6a9 --- /dev/null +++ b/molecule/mysql.8.4/goss/configs.yaml.j2 @@ -0,0 +1,112 @@ +--- + +file: + + # Default - Dict + {{ tests_dir }}/default/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contents: | + [mysqld] + enforce_gtid_consistency = OFF + gtid_mode = ON + query_cache_size = 0 + user = mysql + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contents: | + Content + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contents: | + Template + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contents: | + Template file + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contents: | + Template + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contents: | + Template file + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contents: | + Template file + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/mysql.8.4/goss/data.yaml.j2 b/molecule/mysql.8.4/goss/data.yaml.j2 new file mode 100644 index 000000000..7fadbbc74 --- /dev/null +++ b/molecule/mysql.8.4/goss/data.yaml.j2 @@ -0,0 +1,18 @@ +--- + +file: + {{ tests_dir }}/data: + exists: true + filetype: directory + owner: mysql + group: root + mode: "0700" + {{ tests_dir }}/data/ibdata1: + exists: true + filetype: file + +command: + mysql -BNe "SELECT @@GLOBAL.datadir": + exit-status: 0 + stdout: + - "{{ tests_dir }}/data" diff --git a/molecule/mysql.8.4/goss/data_dir.yaml.j2 b/molecule/mysql.8.4/goss/data_dir.yaml.j2 new file mode 100644 index 000000000..7fadbbc74 --- /dev/null +++ b/molecule/mysql.8.4/goss/data_dir.yaml.j2 @@ -0,0 +1,18 @@ +--- + +file: + {{ tests_dir }}/data: + exists: true + filetype: directory + owner: mysql + group: root + mode: "0700" + {{ tests_dir }}/data/ibdata1: + exists: true + filetype: file + +command: + mysql -BNe "SELECT @@GLOBAL.datadir": + exit-status: 0 + stdout: + - "{{ tests_dir }}/data" diff --git a/molecule/mysql.8.4/goss/databases.yaml.j2 b/molecule/mysql.8.4/goss/databases.yaml.j2 new file mode 100644 index 000000000..3f293f947 --- /dev/null +++ b/molecule/mysql.8.4/goss/databases.yaml.j2 @@ -0,0 +1,12 @@ +--- + +command: + mysql -u root --execute "show databases": + exit-status: 0 + stdout: + - state_present + - state_present_implicit + - "!state_absent" + - "!state_absent_existing" + - "!state_ignored" + - state_ignore_existing diff --git a/molecule/mysql.8.4/goss/default.yaml.j2 b/molecule/mysql.8.4/goss/default.yaml.j2 new file mode 100644 index 000000000..f6e26ecea --- /dev/null +++ b/molecule/mysql.8.4/goss/default.yaml.j2 @@ -0,0 +1,30 @@ +--- + +package: + mysql-server: + installed: true + mysql-client: + installed: true + +command: + mysql --version: + exit-status: 0 + stdout: + - "/mysql(.)*Ver 8.4/" + mysql -u root --execute "select user from mysql.user": + exit-status: 0 + stdout: + - foo + mysqladmin --user=foo --password=foo ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysql -u root --execute "show databases": + exit-status: 0 + stdout: + - foo + +service: + mysql: + enabled: true + running: true diff --git a/molecule/mysql.8.4/goss/users.yaml.j2 b/molecule/mysql.8.4/goss/users.yaml.j2 new file mode 100644 index 000000000..d2a410460 --- /dev/null +++ b/molecule/mysql.8.4/goss/users.yaml.j2 @@ -0,0 +1,22 @@ +--- + +command: + mysql -u root --execute "select user from mysql.user": + exit-status: 0 + stdout: + - foo + - baz + - state_present + - state_present_implicit + - "!state_absent" + - "!state_absent_existing" + - "!state_ignored" + - state_ignore_existing + mysqladmin --user=foo --password=foo ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysqladmin --user=baz --password=baz ping: + exit-status: 0 + stdout: + - "mysqld is alive" diff --git a/molecule/mysql.8.4/molecule.yml b/molecule/mysql.8.4/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/mysql.8.4/prepare.yml b/molecule/mysql.8.4/prepare.yml new file mode 100644 index 000000000..231b5786b --- /dev/null +++ b/molecule/mysql.8.4/prepare.yml @@ -0,0 +1,14 @@ +--- + +- name: Prepare + tags: [always] + hosts: + - debian + - "!debian.buster" + tasks: + - name: Apt + ansible.builtin.import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - mysql@mysql_8_4 diff --git a/molecule/mysql.galera.4.21.mysql_wsrep.8.4.3/converge.yml b/molecule/mysql.galera.4.21.mysql_wsrep.8.4.3/converge.yml new file mode 100644 index 000000000..af3732e97 --- /dev/null +++ b/molecule/mysql.galera.4.21.mysql_wsrep.8.4.3/converge.yml @@ -0,0 +1,60 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.bullseye + - debian.bookworm + tasks: + - block: # noqa: name[missing] + - name: Role + ansible.builtin.import_role: + name: manala.roles.mysql + vars: + manala_mysql_configs: + # Use native authentication plugin + - file: auth.cnf + config: + mysqld: + mysql_native_password: 'ON' + manala_mysql_install_packages: + - galera-4 + - galera-arbitrator-4 + - mysql-wsrep-server + - mysql-wsrep-client + manala_mysql_users: + - name: foo + password: foo + host: localhost + priv: "*.*:ALL,GRANT" + login_unix_socket: /var/run/mysqld/mysqld.sock + - name: bar + state: ignore + login_unix_socket: /var/run/mysqld/mysqld.sock + # Flatten + - + - name: baz + password: baz + host: localhost + priv: "*.*:ALL,GRANT" + login_unix_socket: /var/run/mysqld/mysqld.sock + manala_mysql_databases: + - name: foo + login_unix_socket: /var/run/mysqld/mysqld.sock + - name: bar + state: ignore + login_unix_socket: /var/run/mysqld/mysqld.sock + # Flatten + - + - name: baz + login_unix_socket: /var/run/mysqld/mysqld.sock + always: + - name: Goss + ansible.builtin.command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('ansible.builtin.template', 'goss/default.yaml.j2') }}" + changed_when: false diff --git a/molecule/mysql.galera.4.21.mysql_wsrep.8.4.3/goss/default.yaml.j2 b/molecule/mysql.galera.4.21.mysql_wsrep.8.4.3/goss/default.yaml.j2 new file mode 100644 index 000000000..328ad3dc8 --- /dev/null +++ b/molecule/mysql.galera.4.21.mysql_wsrep.8.4.3/goss/default.yaml.j2 @@ -0,0 +1,42 @@ +--- + +package: + galera-4: + installed: true + galera-arbitrator-4: + installed: true + mysql-wsrep-server: + installed: true + mysql-wsrep-client: + installed: true + +command: + mysql --version: + exit-status: 0 + stdout: + - "/mysql(.)*Ver 8.4.3/" + mysql -u root --execute "select user from mysql.user": + exit-status: 0 + stdout: + - foo + - "!bar" + - baz + mysqladmin --user=foo --password=foo ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysqladmin --user=baz --password=baz ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysql -u root --execute "show databases": + exit-status: 0 + stdout: + - foo + - "!bar" + - baz + +service: + mysql: + enabled: true + running: true diff --git a/molecule/mysql.galera.4.21.mysql_wsrep.8.4.3/molecule.yml b/molecule/mysql.galera.4.21.mysql_wsrep.8.4.3/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/mysql.galera.4.21.mysql_wsrep.8.4.3/prepare.yml b/molecule/mysql.galera.4.21.mysql_wsrep.8.4.3/prepare.yml new file mode 100644 index 000000000..bcf8a5d8d --- /dev/null +++ b/molecule/mysql.galera.4.21.mysql_wsrep.8.4.3/prepare.yml @@ -0,0 +1,15 @@ +--- + +- name: Prepare + tags: [always] + hosts: + - debian.bullseye + - debian.bookworm + tasks: + - name: Apt + ansible.builtin.import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - galera@galera_4_21 + - mysql@mysql_wsrep_8_4_3 diff --git a/roles/apt/vars/main.yaml b/roles/apt/vars/main.yaml index 791f80f8d..7cb17fd54 100644 --- a/roles/apt/vars/main.yaml +++ b/roles/apt/vars/main.yaml @@ -160,6 +160,12 @@ manala_apt_repositories_patterns: components: mysql-8.0 key: mysql legacy_file: repo_mysql_com_apt_{{ ansible_facts.distribution | lower }}.list + mysql_8_4: + uris: http://repo.mysql.com/apt/{{ ansible_facts.distribution | lower }}/ + suites: "{{ ansible_facts.distribution_release }}" + components: mysql-8.4-lts + key: mysql + legacy_file: repo_mysql_com_apt_{{ ansible_facts.distribution | lower }}.list mariadb_10_2: uris: https://downloads.mariadb.com/MariaDB/mariadb-10.2/repo/debian suites: "{{ ansible_facts.distribution_release }}" @@ -302,6 +308,11 @@ manala_apt_repositories_patterns: components: main key: galera_legacy legacy_file: releases_galeracluster_com_galera_4_10_{{ ansible_facts.distribution | lower }}.list + galera_4_21: + uris: https://releases.galeracluster.com/galera-4.21/{{ ansible_facts.distribution | lower }} + suites: "{{ ansible_facts.distribution_release }}" + components: main + key: galera mysql_wsrep_8_0: uris: https://releases.galeracluster.com/mysql-wsrep-8.0/{{ ansible_facts.distribution | lower }} suites: "{{ ansible_facts.distribution_release }}" @@ -326,6 +337,11 @@ manala_apt_repositories_patterns: components: main key: galera_legacy legacy_file: releases_galeracluster_com_mysql_wsrep_8_0_26_26_8_{{ ansible_facts.distribution | lower }}.list + mysql_wsrep_8_4_3: + uris: https://releases.galeracluster.com/mysql-wsrep-8.4.3-26.21/{{ ansible_facts.distribution | lower }} + suites: "{{ ansible_facts.distribution_release }}" + components: main + key: galera grafana: uris: https://apt.grafana.com suites: stable diff --git a/roles/mysql/defaults/main.yaml b/roles/mysql/defaults/main.yaml index 8e4cb18bb..fc578a8e8 100644 --- a/roles/mysql/defaults/main.yaml +++ b/roles/mysql/defaults/main.yaml @@ -12,8 +12,8 @@ manala_mysql_install_packages_default: | manala_mysql_install_python_packages: | {{ (ansible_facts.python.version.major == 2) | ternary( - ['python-mysqldb'], - ['python3-mysqldb'] + ['python-pymysql'], + ['python3-pymysql'] ) }}