Created
December 21, 2017 12:20
-
-
Save jappievw/5af9e62ca62771a948bdd556d8eab180 to your computer and use it in GitHub Desktop.
`mysql_user` validation for different database engines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
mysql55: | |
image: mysql:5.5.58 | |
ports: | |
- "3305:3306" | |
environment: | |
MYSQL_ROOT_PASSWORD: "root" | |
mysql56: | |
image: mysql:5.6.38 | |
ports: | |
- "3306:3306" | |
environment: | |
MYSQL_ROOT_PASSWORD: "root" | |
mysql57: | |
image: mysql:5.7.20 | |
ports: | |
- "3307:3306" | |
environment: | |
MYSQL_ROOT_PASSWORD: "root" | |
# mysql80: | |
# image: mysql:8.0.3 | |
# ports: | |
# - "3308:3306" | |
# environment: | |
# MYSQL_ROOT_PASSWORD: "root" | |
mariadb55: | |
image: mariadb:5.5.58 | |
ports: | |
- "3309:3306" | |
environment: | |
MYSQL_ROOT_PASSWORD: "root" | |
mariadb100: | |
image: mariadb:10.0.33 | |
ports: | |
- "3310:3306" | |
environment: | |
MYSQL_ROOT_PASSWORD: "root" | |
mariadb101: | |
image: mariadb:10.1.29 | |
ports: | |
- "3311:3306" | |
environment: | |
MYSQL_ROOT_PASSWORD: "root" | |
mariadb102: | |
image: mariadb:10.2.11 | |
ports: | |
- "3312:3306" | |
environment: | |
MYSQL_ROOT_PASSWORD: "root" | |
# mariadb103: | |
# image: mariadb:10.3.2 | |
# ports: | |
# - "3313:3306" | |
# environment: | |
# MYSQL_ROOT_PASSWORD: "root" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: | |
hosts: | |
mysql55: | |
mysql_port: 3305 | |
mysql56: | |
mysql_port: 3306 | |
mysql57: | |
mysql_port: 3307 | |
# mysql80: | |
# mysql_port: 3308 | |
mariadb55: | |
mysql_port: 3309 | |
mariadb100: | |
mysql_port: 3310 | |
mariadb101: | |
mysql_port: 3311 | |
mariadb102: | |
mysql_port: 3312 | |
# mariadb103: | |
# mysql_port: 3313 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
connection: local | |
tasks: | |
- mysql_user: | |
name: testuser | |
password: testpassword | |
host: "%" | |
priv: "*.*:SELECT,REQUIRESSL" | |
login_host: "127.0.0.1" | |
login_user: "root" | |
login_password: "root" | |
login_port: "{{ mysql_port }}" | |
state: present | |
- command: "mysql --host=127.0.0.1 --user=root --password=root --port={{ mysql_port }} -e \"SHOW GRANTS FOR 'testuser'@'%'\"" | |
changed_when: False | |
register: users | |
- debug: var=users.stdout_lines | |
- command: "mysql --host=127.0.0.1 --user=root --password=root --port={{ mysql_port }} -e \"SELECT Ssl_Type FROM mysql.user WHERE User='testuser' and Host='%'\"" | |
changed_when: False | |
register: users | |
- debug: var=users.stdout_lines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment