mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-08-07 06:34:25 -07:00
Refactor test_mysql_user to work with other host than localhost
This commit is contained in:
parent
978676a6dc
commit
9da866a7bf
27 changed files with 675 additions and 758 deletions
|
@ -1,75 +1,73 @@
|
|||
---
|
||||
|
||||
- vars:
|
||||
mysql_parameters: &mysql_params
|
||||
login_user: '{{ mysql_user }}'
|
||||
login_password: '{{ mysql_password }}'
|
||||
login_host: '{{ gateway_addr }}'
|
||||
login_host: '{{ mysql_host }}'
|
||||
login_port: '{{ mysql_primary_port }}'
|
||||
|
||||
block:
|
||||
|
||||
# ============================================================
|
||||
|
||||
- name: get server certificate
|
||||
- name: Issue-121 | Setup | Get server certificate
|
||||
copy:
|
||||
content: "{{ lookup('pipe', \"openssl s_client -starttls mysql -connect localhost:3307 -showcerts 2>/dev/null </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'\") }}"
|
||||
content: "{{ lookup('pipe', \"openssl s_client -starttls mysql -connect {{ mysql_host }}:3307 -showcerts 2>/dev/null </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'\") }}"
|
||||
dest: /tmp/cert.pem
|
||||
delegate_to: localhost
|
||||
|
||||
- name: get server version
|
||||
mysql_info:
|
||||
<<: *mysql_params
|
||||
filter: version
|
||||
register: db_version
|
||||
|
||||
- set_fact:
|
||||
old_user_mgmt: "{{ db_version.version.major <= 5 and db_version.version.minor <= 6 or db_version.version.major == 10 and db_version.version.minor < 2 | bool }}"
|
||||
|
||||
- name: Drop mysql user if exists
|
||||
- name: Issue-121 | Drop mysql user if exists
|
||||
mysql_user:
|
||||
<<: *mysql_params
|
||||
name: '{{ item }}'
|
||||
host_all: true
|
||||
state: absent
|
||||
ignore_errors: yes
|
||||
with_items:
|
||||
ignore_errors: true
|
||||
loop:
|
||||
- "{{ user_name_1 }}"
|
||||
- "{{ user_name_2 }}"
|
||||
|
||||
- name: create user with REQUIRESSL privilege (expect failure)
|
||||
- name: Issue-121 | Create user with REQUIRESSL privilege (expect failure)
|
||||
mysql_user:
|
||||
<<: *mysql_params
|
||||
name: "{{ user_name_1 }}"
|
||||
password: "{{ user_password_1 }}"
|
||||
priv: '*.*:SELECT,CREATE USER,REQUIRESSL,GRANT'
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
ignore_errors: true
|
||||
|
||||
- assert:
|
||||
- name: Issue-121 | Assert error granting privileges
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- result.msg is search('Error granting privileges')
|
||||
|
||||
- name: create user with both REQUIRESSL privilege and an incompatible tls_requires option
|
||||
- name: >-
|
||||
Issue-121 | Create user with both REQUIRESSL privilege and an incompatible
|
||||
tls_requires option
|
||||
mysql_user:
|
||||
<<: *mysql_params
|
||||
name: "{{ user_name_1 }}"
|
||||
host: '{{ gateway_addr }}'
|
||||
password: "{{ user_password_1 }}"
|
||||
priv: '*.*:SELECT,CREATE USER,REQUIRESSL,GRANT'
|
||||
tls_requires:
|
||||
X509:
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
ignore_errors: true
|
||||
|
||||
- assert:
|
||||
- name: >-
|
||||
Issue-121 | Assert error granting privileges with incompatible tls_requires
|
||||
option
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- result.msg is search('Error granting privileges')
|
||||
|
||||
- name: Drop mysql user
|
||||
- name: Issue-121 | Teardown | Drop mysql user
|
||||
mysql_user:
|
||||
<<: *mysql_params
|
||||
name: '{{ item }}'
|
||||
host: '{{ gateway_addr }}'
|
||||
host_all: true
|
||||
state: absent
|
||||
with_items:
|
||||
- "{{ user_name_1 }}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue