mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-08-27 08:21:46 -07:00
Backport small diff from main
This commit is contained in:
parent
5d140d8a01
commit
fa3dad6a45
3 changed files with 22 additions and 26 deletions
|
@ -31,10 +31,10 @@
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Get user information
|
- name: Get user information
|
||||||
command: "{{ mysql_command }} -e \"SHOW CREATE USER '{{ test_user_name }}'@'localhost'\""
|
command: "{{ mysql_command }} -e \"SELECT user, host, plugin FROM mysql.user WHERE user = '{{ test_user_name }}' and host = 'localhost'\""
|
||||||
register: show_create_user
|
register: show_create_user
|
||||||
|
|
||||||
- name: Check that the module made a change and that the expected plugin type is set
|
- name: Check that the module made a change
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
@ -107,10 +107,10 @@
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Get user information
|
- name: Get user information
|
||||||
command: "{{ mysql_command }} -e \"SHOW CREATE USER '{{ test_user_name }}'@'localhost'\""
|
command: "{{ mysql_command }} -e \"SELECT user, host, plugin FROM mysql.user WHERE user = '{{ test_user_name }}' and host = 'localhost'\""
|
||||||
register: show_create_user
|
register: show_create_user
|
||||||
|
|
||||||
- name: Check that the module made a change and that the expected plugin type is set
|
- name: Check that the module made a change
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
@ -145,6 +145,7 @@
|
||||||
plugin_hash_string: '{{ test_plugin_hash }}'
|
plugin_hash_string: '{{ test_plugin_hash }}'
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
# FIXME: on mariadb 10.2 there's always a change
|
||||||
- name: Check that the module doesn't make a change when the same hash is passed in
|
- name: Check that the module doesn't make a change when the same hash is passed in
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
|
@ -201,7 +202,7 @@
|
||||||
command: "{{ mysql_command }} -e \"SHOW CREATE USER '{{ test_user_name }}'@'localhost'\""
|
command: "{{ mysql_command }} -e \"SHOW CREATE USER '{{ test_user_name }}'@'localhost'\""
|
||||||
register: show_create_user
|
register: show_create_user
|
||||||
|
|
||||||
- name: Check that the module made a change and that the expected plugin type is set
|
- name: Check that the module made a change
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
@ -210,6 +211,7 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "'{{ test_plugin_type }}' in show_create_user.stdout"
|
- "'{{ test_plugin_type }}' in show_create_user.stdout"
|
||||||
|
when: install_type == 'mysql' or (install_type == 'mariadb' and mariadb_version is version('10.3', '>='))
|
||||||
|
|
||||||
- include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }}
|
- include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }}
|
||||||
|
|
||||||
|
@ -290,7 +292,7 @@
|
||||||
command: "{{ mysql_command }} -e \"SHOW CREATE USER '{{ test_user_name }}'@'localhost'\""
|
command: "{{ mysql_command }} -e \"SHOW CREATE USER '{{ test_user_name }}'@'localhost'\""
|
||||||
register: show_create_user
|
register: show_create_user
|
||||||
|
|
||||||
- name: Check that the module made a change and that the expected plugin type is set
|
- name: Check that the module made a change
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
@ -401,7 +403,7 @@
|
||||||
command: "{{ mysql_command }} -e \"SHOW CREATE USER '{{ test_user_name }}'@'localhost'\""
|
command: "{{ mysql_command }} -e \"SHOW CREATE USER '{{ test_user_name }}'@'localhost'\""
|
||||||
register: show_create_user
|
register: show_create_user
|
||||||
|
|
||||||
- name: Check that the module made a change and that the expected plugin type is set
|
- name: Check that the module made a change
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
issuer: '/CN=org/O=MyDom, Inc./C=US/ST=Oregon/L=Portland'
|
issuer: '/CN=org/O=MyDom, Inc./C=US/ST=Oregon/L=Portland'
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: retrieve TLS requiremets for users in old database version
|
- name: retrieve TLS requirements for users in old database version
|
||||||
command: "{{ mysql_command }} -L -N -s -e \"SHOW GRANTS for '{{ item }}'@'localhost'\""
|
command: "{{ mysql_command }} -L -N -s -e \"SHOW GRANTS for '{{ item }}'@'localhost'\""
|
||||||
register: old_result
|
register: old_result
|
||||||
with_items: ['{{ user_name_1 }}', '{{ user_name_2 }}', '{{ user_name_3 }}']
|
with_items: ['{{ user_name_1 }}', '{{ user_name_2 }}', '{{ user_name_3 }}']
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
when: db_version.version.major <= 5 and db_version.version.minor <= 6 or db_version.version.major == 10 and db_version.version.minor < 2
|
when: db_version.version.major <= 5 and db_version.version.minor <= 6 or db_version.version.major == 10 and db_version.version.minor < 2
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: retrieve TLS requiremets for users in new database version
|
- name: retrieve TLS requirements for users in new database version
|
||||||
command: "{{ mysql_command }} -L -N -s -e \"SHOW CREATE USER '{{ item }}'@'localhost'\""
|
command: "{{ mysql_command }} -L -N -s -e \"SHOW CREATE USER '{{ item }}'@'localhost'\""
|
||||||
register: new_result
|
register: new_result
|
||||||
with_items: ['{{ user_name_1 }}', '{{ user_name_2 }}', '{{ user_name_3 }}']
|
with_items: ['{{ user_name_1 }}', '{{ user_name_2 }}', '{{ user_name_3 }}']
|
||||||
|
@ -119,12 +119,12 @@
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: retrieve TLS requiremets for users in old database version
|
- name: retrieve TLS requirements for users in old database version
|
||||||
command: "{{ mysql_command }} -L -N -s -e \"SHOW GRANTS for '{{ user_name_1 }}'@'localhost'\""
|
command: "{{ mysql_command }} -L -N -s -e \"SHOW GRANTS for '{{ user_name_1 }}'@'localhost'\""
|
||||||
register: old_result
|
register: old_result
|
||||||
when: db_version.version.major <= 5 and db_version.version.minor <= 6 or db_version.version.major == 10 and db_version.version.minor < 2
|
when: db_version.version.major <= 5 and db_version.version.minor <= 6 or db_version.version.major == 10 and db_version.version.minor < 2
|
||||||
|
|
||||||
- name: retrieve TLS requiremets for users in new database version
|
- name: retrieve TLS requirements for users in new database version
|
||||||
command: "{{ mysql_command }} -L -N -s -e \"SHOW CREATE USER '{{ user_name_1 }}'@'localhost'\""
|
command: "{{ mysql_command }} -L -N -s -e \"SHOW CREATE USER '{{ user_name_1 }}'@'localhost'\""
|
||||||
register: new_result
|
register: new_result
|
||||||
when: db_version.version.major == 5 and db_version.version.minor >= 7 or db_version.version.major > 5 and db_version.version.major < 10 or db_version.version.major == 10 and db_version.version.minor >= 2
|
when: db_version.version.major == 5 and db_version.version.minor >= 7 or db_version.version.major > 5 and db_version.version.major < 10 or db_version.version.major == 10 and db_version.version.minor >= 2
|
||||||
|
@ -143,12 +143,12 @@
|
||||||
tls_requires:
|
tls_requires:
|
||||||
X509:
|
X509:
|
||||||
|
|
||||||
- name: retrieve TLS requiremets for users in old database version
|
- name: retrieve TLS requirements for users in old database version
|
||||||
command: "{{ mysql_command }} -L -N -s -e \"SHOW GRANTS for '{{ user_name_1 }}'@'localhost'\""
|
command: "{{ mysql_command }} -L -N -s -e \"SHOW GRANTS for '{{ user_name_1 }}'@'localhost'\""
|
||||||
register: old_result
|
register: old_result
|
||||||
when: db_version.version.major <= 5 and db_version.version.minor <= 6 or db_version.version.major == 10 and db_version.version.minor < 2
|
when: db_version.version.major <= 5 and db_version.version.minor <= 6 or db_version.version.major == 10 and db_version.version.minor < 2
|
||||||
|
|
||||||
- name: retrieve TLS requiremets for users in new database version
|
- name: retrieve TLS requirements for users in new database version
|
||||||
command: "{{ mysql_command }} -L -N -s -e \"SHOW CREATE USER '{{ user_name_1 }}'@'localhost'\""
|
command: "{{ mysql_command }} -L -N -s -e \"SHOW CREATE USER '{{ user_name_1 }}'@'localhost'\""
|
||||||
register: new_result
|
register: new_result
|
||||||
when: db_version.version.major == 5 and db_version.version.minor >= 7 or db_version.version.major > 5 and db_version.version.major < 10 or db_version.version.major == 10 and db_version.version.minor >= 2
|
when: db_version.version.major == 5 and db_version.version.minor >= 7 or db_version.version.major > 5 and db_version.version.major < 10 or db_version.version.major == 10 and db_version.version.minor >= 2
|
||||||
|
@ -159,28 +159,21 @@
|
||||||
vars:
|
vars:
|
||||||
- reqs: "{{(old_result is skipped | ternary(new_result, old_result)).stdout.split('REQUIRE')[1].split(separator)[0].strip()}}"
|
- reqs: "{{(old_result is skipped | ternary(new_result, old_result)).stdout.split('REQUIRE')[1].split(separator)[0].strip()}}"
|
||||||
|
|
||||||
- name: remove TLS requiremets from user (expect changed=true)
|
- name: remove TLS requirements from user (expect changed=true)
|
||||||
mysql_user:
|
mysql_user:
|
||||||
<<: *mysql_params
|
<<: *mysql_params
|
||||||
name: '{{ user_name_1 }}'
|
name: '{{ user_name_1 }}'
|
||||||
password: '{{ user_password_1 }}'
|
password: '{{ user_password_1 }}'
|
||||||
tls_requires:
|
tls_requires:
|
||||||
|
|
||||||
- name: retrieve TLS requiremets for users in old database version
|
- name: retrieve TLS requirements for users
|
||||||
command: "{{ mysql_command }} -L -N -s -e \"SHOW GRANTS for '{{ user_name_1 }}'@'localhost'\""
|
command: "{{ mysql_command }} -L -N -s -e \"SHOW GRANTS for '{{ user_name_1 }}'@'localhost'\""
|
||||||
register: old_result
|
register: result
|
||||||
when: db_version.version.major <= 5 and db_version.version.minor <= 6 or db_version.version.major == 10 and db_version.version.minor < 2
|
|
||||||
|
|
||||||
- name: retrieve TLS requiremets for users in new database version
|
|
||||||
command: "{{ mysql_command }} -L -N -s -e \"SHOW CREATE USER '{{ user_name_1 }}'@'localhost'\""
|
|
||||||
register: new_result
|
|
||||||
when: db_version.version.major == 5 and db_version.version.minor >= 7 or db_version.version.major > 5 and db_version.version.major < 10 or db_version.version.major == 10 and db_version.version.minor >= 2
|
|
||||||
|
|
||||||
- name: assert user1 TLS requirements
|
- name: assert user1 TLS requirements
|
||||||
assert:
|
assert:
|
||||||
that: "'NONE' in reqs"
|
that: "'REQUIRE ' not in result.stdout or 'REQUIRE NONE' in result.stdout"
|
||||||
vars:
|
|
||||||
- reqs: "{{(old_result is skipped | ternary(new_result, old_result)).stdout.split('REQUIRE')[1].split(separator)[0].strip() | default('NONE') }}"
|
|
||||||
|
|
||||||
- include: remove_user.yml user_name={{user_name_1}} user_password={{ user_password_1 }}
|
- include: remove_user.yml user_name={{user_name_1}} user_password={{ user_password_1 }}
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,6 @@
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Verify mysql_variable fails when setting an incorrect value (out of range)
|
# Verify mysql_variable fails when setting an incorrect value (out of range)
|
||||||
#
|
#
|
||||||
|
|
||||||
- name: set mysql variable value to a number out of range
|
- name: set mysql variable value to a number out of range
|
||||||
mysql_variables:
|
mysql_variables:
|
||||||
<<: *mysql_params
|
<<: *mysql_params
|
||||||
|
@ -360,7 +359,9 @@
|
||||||
|
|
||||||
- include: assert_var.yml changed=true output={{ result }} var_name={{ set_name }} var_value='{{ def_val }}'
|
- include: assert_var.yml changed=true output={{ result }} var_name={{ set_name }} var_value='{{ def_val }}'
|
||||||
|
|
||||||
when: mysql_version is not version('8.0', '<')
|
when:
|
||||||
|
- mysql_version is version('8.0', '>=')
|
||||||
|
- install_type == 'mysql'
|
||||||
|
|
||||||
# Bugfix of https://github.com/ansible/ansible/issues/54239
|
# Bugfix of https://github.com/ansible/ansible/issues/54239
|
||||||
# - name: set variable containing dot
|
# - name: set variable containing dot
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue