mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
dd1bb708d3
* mysql_user: add resource_limits parameter * add CI test * added changelog fragment * skip opensuse * remove skip/suse
112 lines
2.9 KiB
YAML
112 lines
2.9 KiB
YAML
# test code for resource_limits parameter
|
|
|
|
- block:
|
|
|
|
- name: Drop mysql user {{ user_name_1 }} if exists
|
|
mysql_user:
|
|
name: '{{ user_name_1 }}'
|
|
state: absent
|
|
login_unix_socket: '{{ mysql_socket }}'
|
|
|
|
- name: Create mysql user {{ user_name_1 }} with resource limits in check_mode
|
|
mysql_user:
|
|
name: '{{ user_name_1 }}'
|
|
password: '{{ user_password_1 }}'
|
|
state: present
|
|
login_unix_socket: '{{ mysql_socket }}'
|
|
resource_limits:
|
|
MAX_QUERIES_PER_HOUR: 10
|
|
MAX_CONNECTIONS_PER_HOUR: 5
|
|
check_mode: yes
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: Create mysql user {{ user_name_1 }} with resource limits in actual mode
|
|
mysql_user:
|
|
name: '{{ user_name_1 }}'
|
|
password: '{{ user_password_1 }}'
|
|
state: present
|
|
login_unix_socket: '{{ mysql_socket }}'
|
|
resource_limits:
|
|
MAX_QUERIES_PER_HOUR: 10
|
|
MAX_CONNECTIONS_PER_HOUR: 5
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: Check
|
|
mysql_query:
|
|
query: >
|
|
SELECT User FROM mysql.user WHERE User = '{{ user_name_1 }}' AND Host = 'localhost'
|
|
AND max_questions = 10 AND max_connections = 5
|
|
login_unix_socket: '{{ mysql_socket }}'
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result.rowcount[0] == 1
|
|
|
|
- name: Try to set the same limits again in check mode
|
|
mysql_user:
|
|
name: '{{ user_name_1 }}'
|
|
password: '{{ user_password_1 }}'
|
|
state: present
|
|
login_unix_socket: '{{ mysql_socket }}'
|
|
resource_limits:
|
|
MAX_QUERIES_PER_HOUR: 10
|
|
MAX_CONNECTIONS_PER_HOUR: 5
|
|
check_mode: yes
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result is not changed
|
|
|
|
- name: Try to set the same limits again in actual mode
|
|
mysql_user:
|
|
name: '{{ user_name_1 }}'
|
|
password: '{{ user_password_1 }}'
|
|
state: present
|
|
login_unix_socket: '{{ mysql_socket }}'
|
|
resource_limits:
|
|
MAX_QUERIES_PER_HOUR: 10
|
|
MAX_CONNECTIONS_PER_HOUR: 5
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result is not changed
|
|
|
|
- name: Change limits
|
|
mysql_user:
|
|
name: '{{ user_name_1 }}'
|
|
password: '{{ user_password_1 }}'
|
|
state: present
|
|
login_unix_socket: '{{ mysql_socket }}'
|
|
resource_limits:
|
|
MAX_QUERIES_PER_HOUR: 5
|
|
MAX_CONNECTIONS_PER_HOUR: 5
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: Check
|
|
mysql_query:
|
|
query: >
|
|
SELECT User FROM mysql.user WHERE User = '{{ user_name_1 }}' AND Host = 'localhost'
|
|
AND max_questions = 5 AND max_connections = 5
|
|
login_unix_socket: '{{ mysql_socket }}'
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result.rowcount[0] == 1
|
|
|
|
when: (ansible_distribution == 'Ubuntu' and ansible_distribution_major_version >= '18') or (ansible_distribution == 'CentOS' and ansible_distribution_major_version >= '8')
|