1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/tests/integration/targets/mysql_db/tasks/config_overrides_defaults.yml
Andrew Klychkov 1d1f7ec582
mysql_db: add config_overrides_defaults parameter (#513)
* mysql_db: add config_overrides_defaults parameter

* Add CI tests

* Add changelog fragment

* add more tests

* improve tests

* fix CI

* fix feature
2020-06-18 11:24:23 +03:00

71 lines
1.9 KiB
YAML

- set_fact:
db_to_create=testdb1
config_file="/root/.my1.cnf"
fake_port=9999
fake_host="blahblah.local"
- name: Create custom config file
shell: 'echo "[client]" > {{ config_file }}'
- name: Add fake port to config file
shell: 'echo "port = {{ fake_port }}" >> {{ config_file }}'
- name: Create database using fake port to connect to, must fail
mysql_db:
name: '{{ db_to_create }}'
state: present
check_implicit_admin: yes
config_file: '{{ config_file }}'
config_overrides_defaults: yes
ignore_errors: yes
register: result
- name: Must fail because login_port default has beed overriden by wrong value from config file
assert:
that:
- result is failed
- result.msg is search("unable to connect to database")
- name: Create database using default port
mysql_db:
name: '{{ db_to_create }}'
state: present
check_implicit_admin: yes
config_file: '{{ config_file }}'
config_overrides_defaults: no
login_unix_socket: '{{ mysql_socket }}'
register: result
- name: Must not fail because of the default of login_port is correct
assert:
that:
- result is changed
- name: Reinit custom config file
shell: 'echo "[client]" > {{ config_file }}'
- name: Add fake host to config file
shell: 'echo "host = {{ fake_host }}" >> {{ config_file }}'
- name: Remove database using fake login_host
mysql_db:
name: '{{ db_to_create }}'
state: absent
config_file: '{{ config_file }}'
config_overrides_defaults: yes
register: result
ignore_errors: yes
- name: Must fail because login_host default has beed overriden by wrong value from config file
assert:
that:
- result is failed
- result.msg is search("Can't connect to MySQL server on '{{ fake_host }}'")
# Clean up
- name: Remove test db
mysql_db:
name: '{{ db_to_create }}'
state: absent
check_implicit_admin: yes
login_unix_socket: '{{ mysql_socket }}'