mysql modules: fix failing when \!include_dir is in config file (#47)

* mysql modules: fix failing when \!include_dir is in .my.cnf

* Add changelog fragment

* fix CI

* fix CI

* Fix CI

* Fix CI

* Fix comment
This commit is contained in:
Andrew Klychkov 2020-10-13 16:05:39 +03:00 committed by GitHub
parent 8c79011dbd
commit 82ad06e072
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 9 deletions

View file

@ -3,6 +3,7 @@
config_file: "/root/.my1.cnf"
fake_port: 9999
fake_host: "blahblah.local"
include_dir: "/root/mycnf.d"
- name: Create custom config file
shell: 'echo "[client]" > {{ config_file }}'
@ -10,6 +11,28 @@
- name: Add fake port to config file
shell: 'echo "port = {{ fake_port }}" >> {{ config_file }}'
- name: Get pymysql version
shell: pip show pymysql | awk '/Version/ {print $2}'
register: pymysql_version
- name: Add blank line
shell: 'echo "" >> {{ config_file }}'
when: (pymysql_version.stdout | default('1000', true)) is version('0.9.3', '>=')
- name: Create include_dir
file:
path: '{{ include_dir }}'
state: directory
mode: '0777'
when: (pymysql_version.stdout | default('1000', true)) is version('0.9.3', '>=')
- name: Add include_dir
lineinfile:
path: '{{ config_file }}'
line: '!includedir {{ include_dir }}'
insertafter: EOF
when: (pymysql_version.stdout | default('1000', true)) is version('0.9.3', '>=')
- name: Create database using fake port to connect to, must fail
mysql_db:
login_user: '{{ mysql_user }}'