mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-27 04:41:28 -07:00
Refactor to remove useless variables
This commit is contained in:
parent
7fa1bf890b
commit
85f24bd8c6
3 changed files with 299 additions and 324 deletions
|
@ -3,18 +3,3 @@ mysql_user: root
|
|||
mysql_password: msandbox
|
||||
mysql_host: '{{ gateway_addr }}'
|
||||
mysql_primary_port: 3307
|
||||
|
||||
test_db: test_db
|
||||
test_table: test_table
|
||||
test_db1: test_db1
|
||||
test_db2: test_db2
|
||||
|
||||
user0: user0
|
||||
user1: user1
|
||||
user2: user2
|
||||
nonexistent: user3
|
||||
|
||||
role0: role0
|
||||
role1: role1
|
||||
role2: role2
|
||||
role3: role3
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -11,20 +11,18 @@
|
|||
- name: Create test databases
|
||||
mysql_db:
|
||||
<<: *mysql_params
|
||||
name: '{{ item }}'
|
||||
name: data1
|
||||
state: present
|
||||
loop:
|
||||
- data1
|
||||
|
||||
- name: Create a role with an initial set of privileges
|
||||
mysql_role:
|
||||
<<: *mysql_params
|
||||
name: '{{ role2 }}'
|
||||
name: 'role2'
|
||||
priv: 'data1.*:SELECT,INSERT'
|
||||
state: present
|
||||
|
||||
- name: Run command to show privileges for role (expect privileges in stdout)
|
||||
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ role2 }}'\""
|
||||
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR 'role2'\""
|
||||
register: result
|
||||
|
||||
- name: Assert that the initial set of privileges matches what is expected
|
||||
|
@ -35,7 +33,7 @@
|
|||
- name: Subtract privileges that are not in the current privileges, which should be a no-op
|
||||
mysql_role:
|
||||
<<: *mysql_params
|
||||
name: '{{ role2 }}'
|
||||
name: 'role2'
|
||||
priv: 'data1.*:DELETE'
|
||||
subtract_privs: yes
|
||||
state: present
|
||||
|
@ -48,7 +46,7 @@
|
|||
- result is not changed
|
||||
|
||||
- name: Run command to show privileges for role (expect privileges in stdout)
|
||||
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ role2 }}'\""
|
||||
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR 'role2'\""
|
||||
register: result
|
||||
|
||||
- name: Assert that the permissions still match what was originally granted
|
||||
|
@ -59,7 +57,7 @@
|
|||
- name: Subtract existing and not-existing privileges, but not all
|
||||
mysql_role:
|
||||
<<: *mysql_params
|
||||
name: '{{ role2 }}'
|
||||
name: 'role2'
|
||||
priv: 'data1.*:INSERT,DELETE'
|
||||
subtract_privs: yes
|
||||
state: present
|
||||
|
@ -72,7 +70,7 @@
|
|||
- result is changed
|
||||
|
||||
- name: Run command to show privileges for role (expect privileges in stdout)
|
||||
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ role2 }}'\""
|
||||
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR 'role2'\""
|
||||
register: result
|
||||
|
||||
- name: Assert that the permissions were not changed if check_mode is set to 'yes'
|
||||
|
@ -90,7 +88,7 @@
|
|||
- name: Try to subtract invalid privileges
|
||||
mysql_role:
|
||||
<<: *mysql_params
|
||||
name: '{{ role2 }}'
|
||||
name: 'role2'
|
||||
priv: 'data1.*:INVALID'
|
||||
subtract_privs: yes
|
||||
state: present
|
||||
|
@ -103,7 +101,7 @@
|
|||
- result is not changed
|
||||
|
||||
- name: Run command to show privileges for role (expect privileges in stdout)
|
||||
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ role2 }}'\""
|
||||
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR 'role2'\""
|
||||
register: result
|
||||
|
||||
- name: Assert that the permissions were not changed with check_mode=='yes'
|
||||
|
@ -121,7 +119,7 @@
|
|||
- name: trigger failure by trying to subtract and append privileges at the same time
|
||||
mysql_role:
|
||||
<<: *mysql_params
|
||||
name: '{{ role2 }}'
|
||||
name: 'role2'
|
||||
priv: 'data1.*:SELECT'
|
||||
subtract_privs: yes
|
||||
append_privs: yes
|
||||
|
@ -136,7 +134,7 @@
|
|||
- result is failed
|
||||
|
||||
- name: Run command to show privileges for role (expect privileges in stdout)
|
||||
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR '{{ role2 }}'\""
|
||||
command: "{{ mysql_command }} -e \"SHOW GRANTS FOR 'role2'\""
|
||||
register: result
|
||||
|
||||
- name: Assert that the permissions stayed the same, with check_mode=='yes'
|
||||
|
@ -156,13 +154,11 @@
|
|||
- name: Drop test databases
|
||||
mysql_db:
|
||||
<<: *mysql_params
|
||||
name: '{{ item }}'
|
||||
name: 'data1'
|
||||
state: present
|
||||
loop:
|
||||
- data1
|
||||
|
||||
- name: Drop test role
|
||||
mysql_role:
|
||||
<<: *mysql_params
|
||||
name: '{{ role2 }}'
|
||||
name: 'role2'
|
||||
state: absent
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue