mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
142 lines
3.5 KiB
YAML
142 lines
3.5 KiB
YAML
|
- name: mysql_info - create mysql user {{ user_name }}
|
||
|
mysql_user:
|
||
|
name: '{{ user_name }}'
|
||
|
password: '{{ user_pass }}'
|
||
|
state: present
|
||
|
priv: '*.*:ALL'
|
||
|
login_unix_socket: '{{ mysql_socket }}'
|
||
|
- name: mysql_info - create default config file
|
||
|
template:
|
||
|
src: my.cnf.j2
|
||
|
dest: /root/.my.cnf
|
||
|
mode: '0400'
|
||
|
- name: mysql_info - create non-default config file
|
||
|
template:
|
||
|
src: my.cnf.j2
|
||
|
dest: /root/non-default_my.cnf
|
||
|
mode: '0400'
|
||
|
- name: mysql_info - collect default cred file
|
||
|
mysql_info:
|
||
|
login_user: '{{ user_name }}'
|
||
|
register: result
|
||
|
- assert:
|
||
|
that:
|
||
|
- result.changed == false
|
||
|
- result.version != {}
|
||
|
- result.settings != {}
|
||
|
- result.global_status != {}
|
||
|
- result.databases != {}
|
||
|
- result.engines != {}
|
||
|
- result.users != {}
|
||
|
- name: mysql_info - check non-default cred file
|
||
|
mysql_info:
|
||
|
login_user: '{{ user_name }}'
|
||
|
config_file: /root/non-default_my.cnf
|
||
|
register: result
|
||
|
- assert:
|
||
|
that:
|
||
|
- result.changed == false
|
||
|
- result.version != {}
|
||
|
- name: mysql_info - remove cred files
|
||
|
file:
|
||
|
path: '{{ item }}'
|
||
|
state: absent
|
||
|
with_items:
|
||
|
- /root/.my.cnf
|
||
|
- /root/non-default_my.cnf
|
||
|
- name: mysql_info - check access with password
|
||
|
mysql_info:
|
||
|
login_user: '{{ user_name }}'
|
||
|
login_password: '{{ user_pass }}'
|
||
|
register: result
|
||
|
- assert:
|
||
|
that:
|
||
|
- result.changed == false
|
||
|
- result.version != {}
|
||
|
- name: Collect all info except settings and users
|
||
|
mysql_info:
|
||
|
login_user: '{{ user_name }}'
|
||
|
login_password: '{{ user_pass }}'
|
||
|
filter: '!settings,!users'
|
||
|
register: result
|
||
|
- assert:
|
||
|
that:
|
||
|
- result.changed == false
|
||
|
- result.version != {}
|
||
|
- result.global_status != {}
|
||
|
- result.databases != {}
|
||
|
- result.engines != {}
|
||
|
- result.settings is not defined
|
||
|
- result.users is not defined
|
||
|
- name: Collect info only about version and databases
|
||
|
mysql_info:
|
||
|
login_user: '{{ user_name }}'
|
||
|
login_password: '{{ user_pass }}'
|
||
|
filter:
|
||
|
- version
|
||
|
- databases
|
||
|
register: result
|
||
|
- assert:
|
||
|
that:
|
||
|
- result.changed == false
|
||
|
- result.version != {}
|
||
|
- result.databases != {}
|
||
|
- result.engines is not defined
|
||
|
- result.settings is not defined
|
||
|
- result.global_status is not defined
|
||
|
- result.users is not defined
|
||
|
- name: Collect info about databases excluding their sizes
|
||
|
mysql_info:
|
||
|
login_user: '{{ user_name }}'
|
||
|
login_password: '{{ user_pass }}'
|
||
|
filter:
|
||
|
- databases
|
||
|
exclude_fields:
|
||
|
- db_size
|
||
|
- unsupported
|
||
|
register: result
|
||
|
- assert:
|
||
|
that:
|
||
|
- result.changed == false
|
||
|
- result.databases != {}
|
||
|
- result.databases.mysql == {}
|
||
|
- name: Create empty database acme
|
||
|
mysql_db:
|
||
|
login_user: '{{ user_name }}'
|
||
|
login_password: '{{ user_pass }}'
|
||
|
name: acme
|
||
|
- name: Collect info about databases
|
||
|
mysql_info:
|
||
|
login_user: '{{ user_name }}'
|
||
|
login_password: '{{ user_pass }}'
|
||
|
filter:
|
||
|
- databases
|
||
|
return_empty_dbs: true
|
||
|
register: result
|
||
|
- assert:
|
||
|
that:
|
||
|
- result.changed == false
|
||
|
- result.databases.acme.size == 0
|
||
|
- result.databases.mysql != {}
|
||
|
- name: Collect info about databases excluding their sizes
|
||
|
mysql_info:
|
||
|
login_user: '{{ user_name }}'
|
||
|
login_password: '{{ user_pass }}'
|
||
|
filter:
|
||
|
- databases
|
||
|
exclude_fields:
|
||
|
- db_size
|
||
|
return_empty_dbs: true
|
||
|
register: result
|
||
|
- assert:
|
||
|
that:
|
||
|
- result.changed == false
|
||
|
- result.databases.acme == {}
|
||
|
- result.databases.mysql == {}
|
||
|
- name: Remove acme database
|
||
|
mysql_db:
|
||
|
login_user: '{{ user_name }}'
|
||
|
login_password: '{{ user_pass }}'
|
||
|
name: acme
|
||
|
state: absent
|