mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-07-22 12:50:24 -07:00
Disable hostname check (#38)
* Add changelog fragment * Add check_hostname option * Propagate check_hostname option across the collection * Update documentation fragment * Propagate test to all other plugins * Remove stray line * Give test user privileges to run test operations * Extend integration tests job matrix * Add caution note to documentation fragment. * Update matrix job name * Rearrange job matrix * Fix sanity issues * Fix issue with mysqldb silently failing to update out of range variables * Fix variable overwrite * Ignore `check_hostname` when using MySQLdb * Update plugins/doc_fragments/mysql.py Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Update plugins/doc_fragments/mysql.py Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Update changelogs/fragments/35-disable-hostname-check.yml Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
This commit is contained in:
parent
dc98327483
commit
8c79011dbd
32 changed files with 680 additions and 135 deletions
86
tests/integration/targets/test_mysql_user/tasks/issue-28.yml
Normal file
86
tests/integration/targets/test_mysql_user/tasks/issue-28.yml
Normal file
|
@ -0,0 +1,86 @@
|
|||
---
|
||||
- vars:
|
||||
mysql_parameters: &mysql_params
|
||||
login_user: '{{ mysql_user }}'
|
||||
login_password: '{{ mysql_password }}'
|
||||
login_host: 127.0.0.1
|
||||
login_port: '{{ mysql_primary_port }}'
|
||||
|
||||
block:
|
||||
|
||||
# ============================================================
|
||||
- shell: pip show pymysql | awk '/Version/ {print $2}'
|
||||
register: pymysql_version
|
||||
|
||||
- name: 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'\") }}"
|
||||
dest: /tmp/cert.pem
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Drop mysql user if exists
|
||||
mysql_user:
|
||||
<<: *mysql_params
|
||||
name: '{{ user_name_1 }}'
|
||||
state: absent
|
||||
ignore_errors: yes
|
||||
|
||||
- name: create user with ssl requirement
|
||||
mysql_user:
|
||||
<<: *mysql_params
|
||||
name: "{{ user_name_1 }}"
|
||||
password: "{{ user_password_1 }}"
|
||||
priv: '*.*:ALL,GRANT'
|
||||
tls_requires:
|
||||
SSL:
|
||||
|
||||
- name: attempt connection with newly created user (expect failure)
|
||||
mysql_user:
|
||||
name: "{{ user_name_2 }}"
|
||||
password: "{{ user_password_2 }}"
|
||||
host: 127.0.0.1
|
||||
login_user: '{{ user_name_1 }}'
|
||||
login_password: '{{ user_password_1 }}'
|
||||
login_host: 127.0.0.1
|
||||
login_port: '{{ mysql_primary_port }}'
|
||||
ca_cert: /tmp/cert.pem
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is failed
|
||||
when: pymysql_version.stdout != ""
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is succeeded
|
||||
when: pymysql_version.stdout == ""
|
||||
|
||||
- name: attempt connection with newly created user ignoring hostname
|
||||
mysql_user:
|
||||
name: "{{ user_name_2 }}"
|
||||
password: "{{ user_password_2 }}"
|
||||
host: 127.0.0.1
|
||||
login_user: '{{ user_name_1 }}'
|
||||
login_password: '{{ user_password_1 }}'
|
||||
login_host: 127.0.0.1
|
||||
login_port: '{{ mysql_primary_port }}'
|
||||
ca_cert: /tmp/cert.pem
|
||||
check_hostname: no
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is succeeded or 'pymysql >= 0.7.11 is required' in result.msg
|
||||
|
||||
- name: Drop mysql user
|
||||
mysql_user:
|
||||
<<: *mysql_params
|
||||
name: '{{ item }}'
|
||||
host: 127.0.0.1
|
||||
state: absent
|
||||
with_items:
|
||||
- "{{ user_name_1 }}"
|
||||
- "{{ user_name_2 }}"
|
|
@ -37,6 +37,8 @@
|
|||
|
||||
block:
|
||||
|
||||
- include: issue-28.yml
|
||||
|
||||
- include: create_user.yml user_name={{user_name_1}} user_password={{ user_password_1 }}
|
||||
|
||||
- include: resource_limits.yml
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue