Test first stteps

This commit is contained in:
Fran Sanjuán 2024-08-26 10:26:36 +02:00
commit a5250f2374

View file

@ -545,49 +545,11 @@
register: result register: result
failed_when: result is success failed_when: result is success
# ============================================================ # ============================================================
# Test auth plugin change # Test auth plugin change
# #
- name: Cleanup user - name: Plugin auth | Test plugin auth switching which doesn't work on pymysql < 0.9
ansible.builtin.include_tasks: utils/remove_user.yml
vars:
user_name: "{{ test_user_name }}"
- name: Plugin auth | Create user with mysql_native_password
community.mysql.mysql_user:
<<: *mysql_params
name: "{{ test_user_name }}"
host: "%"
plugin: "{{ test_plugin_type }}"
password: "{{ test_plugin_auth_string }}"
priv: "{{ test_default_priv }}"
- name: Plugin auth | Check that the expected plugin type is set
ansible.builtin.include_tasks: utils/assert_plugin.yml
vars:
user_name: "{{ test_user_name }}"
plugin_type: "{{ test_plugin_type }}"
- name: Plugin auth | Connect with user and password
ansible.builtin.command: '{{ mysql_command }} -u {{ test_user_name }} -p{{ test_plugin_auth_string }} -e "SELECT 1"'
- name: Plugin auth | Change auth user plugin in check mode
community.mysql.mysql_user:
<<: *mysql_params
name: "{{ test_user_name }}"
host: '%'
plugin: caching_sha2_password
plugin_auth_string: "{{ test_plugin_auth_string }}"
salt: "{{ test_salt }}"
priv: "{{ test_default_priv }}"
check_mode: true
register: result
failed_when: result is not changed
when: when:
- > - >
connector_name != 'pymysql' connector_name != 'pymysql'
@ -595,73 +557,82 @@
connector_name == 'pymysql' connector_name == 'pymysql'
and connector_version is version('0.9', '>=') and connector_version is version('0.9', '>=')
) )
block:
- name: Plugin auth | Check that the expected plugin type is set (not changed) - name: Cleanup user
ansible.builtin.include_tasks: utils/assert_plugin.yml ansible.builtin.include_tasks: utils/remove_user.yml
vars: vars:
user_name: "{{ test_user_name }}" user_name: "{{ test_user_name }}"
plugin_type: "{{ test_plugin_type }}"
- name: Plugin auth | Change auth user plugin - name: Plugin auth | Create user with mysql_native_password
community.mysql.mysql_user: community.mysql.mysql_user:
<<: *mysql_params <<: *mysql_params
name: "{{ test_user_name }}" name: "{{ test_user_name }}"
host: '%' host: "%"
plugin: caching_sha2_password plugin: "{{ test_plugin_type }}"
plugin_auth_string: "{{ test_plugin_auth_string }}" password: "{{ test_plugin_auth_string }}"
salt: "{{ test_salt }}" priv: "{{ test_default_priv }}"
priv: "{{ test_default_priv }}"
register: result
failed_when: result is not changed
when:
- >
connector_name != 'pymysql'
or (
connector_name == 'pymysql'
and connector_version is version('0.9', '>=')
)
- name: Plugin auth | Check that the expected (new) plugin type is set - name: Plugin auth | Check that the expected plugin type is set
ansible.builtin.include_tasks: utils/assert_plugin.yml ansible.builtin.include_tasks: utils/assert_plugin.yml
vars: vars:
user_name: "{{ test_user_name }}" user_name: "{{ test_user_name }}"
plugin_type: caching_sha2_password plugin_type: "{{ test_plugin_type }}"
when:
- >
connector_name != 'pymysql'
or (
connector_name == 'pymysql'
and connector_version is version('0.9', '>=')
)
- name: Plugin auth | Change auth user plugin again (should not change) # - name: Plugin auth | Connect with user and password
community.mysql.mysql_user: # ansible.builtin.command: '{{ mysql_command }} -u {{ test_user_name }} -p{{ test_plugin_auth_string }} -e "SELECT 1"'
<<: *mysql_params
name: "{{ test_user_name }}"
host: '%'
plugin: caching_sha2_password
plugin_auth_string: "{{ test_plugin_auth_string }}"
salt: "{{ test_salt }}"
priv: "{{ test_default_priv }}"
register: result
failed_when: result is changed
when:
- >
connector_name != 'pymysql'
or (
connector_name == 'pymysql'
and connector_version is version('0.9', '>=')
)
- name: Plugin auth | Check that the expected (not changed) plugin type is set # - name: Plugin auth | Change auth user plugin in check mode
ansible.builtin.include_tasks: utils/assert_plugin.yml # community.mysql.mysql_user:
vars: # <<: *mysql_params
user_name: "{{ test_user_name }}" # name: "{{ test_user_name }}"
plugin_type: caching_sha2_password # host: '%'
when: # plugin: caching_sha2_password
- > # plugin_auth_string: "{{ test_plugin_auth_string }}"
connector_name != 'pymysql' # salt: "{{ test_salt }}"
or ( # priv: "{{ test_default_priv }}"
connector_name == 'pymysql' # check_mode: true
and connector_version is version('0.9', '>=') # register: result
) # failed_when: result is not changed
# - name: Plugin auth | Check that the expected plugin type is set (not changed)
# ansible.builtin.include_tasks: utils/assert_plugin.yml
# vars:
# user_name: "{{ test_user_name }}"
# plugin_type: "{{ test_plugin_type }}"
# - name: Plugin auth | Change auth user plugin
# community.mysql.mysql_user:
# <<: *mysql_params
# name: "{{ test_user_name }}"
# host: '%'
# plugin: caching_sha2_password
# plugin_auth_string: "{{ test_plugin_auth_string }}"
# salt: "{{ test_salt }}"
# priv: "{{ test_default_priv }}"
# register: result
# failed_when: result is not changed
# - name: Plugin auth | Check that the expected (new) plugin type is set
# ansible.builtin.include_tasks: utils/assert_plugin.yml
# vars:
# user_name: "{{ test_user_name }}"
# plugin_type: caching_sha2_password
# - name: Plugin auth | Change auth user plugin again (should not change)
# community.mysql.mysql_user:
# <<: *mysql_params
# name: "{{ test_user_name }}"
# host: '%'
# plugin: caching_sha2_password
# plugin_auth_string: "{{ test_plugin_auth_string }}"
# salt: "{{ test_salt }}"
# priv: "{{ test_default_priv }}"
# register: result
# failed_when: result is changed
# - name: Plugin auth | Check that the expected (not changed) plugin type is set
# ansible.builtin.include_tasks: utils/assert_plugin.yml
# vars:
# user_name: "{{ test_user_name }}"
# plugin_type: caching_sha2_password