New in version 2.9.
The below requirements are needed on the host that executes this module.
| Parameter | Choices/Defaults | Comments |
|---|---|---|
| ca_cert path | The path to a Certificate Authority (CA) certificate. This option, if used, must specify the same certificate as used by the server. aliases: ssl_ca | |
| client_cert path | The path to a client public key certificate. aliases: ssl_cert | |
| client_key path | The path to the client private key. aliases: ssl_key | |
| config_file path | Default: "~/.my.cnf" | Specify a config file from which user and password are to be read. |
| connect_timeout integer | Default: 30 | The connection timeout when connecting to the MySQL server. |
| filter list / elements=string | Limit the collected information by comma separated string or YAML list. Allowable values are version, databases, settings, users, slave_status, slave_hosts, master_status, engines.By default, collects all subsets. You can use '!' before value (for example, !settings) to exclude it from the information.If you pass including and excluding values to the filter, for example, filter=!settings,version, the excluding values, !settings in this case, will be ignored. | |
| login_db string | Database name to connect to. It makes sense if login_user is allowed to connect to a specific database only. | |
| login_host string | Default: "localhost" | Host running the database. |
| login_password string | The password used to authenticate with. | |
| login_port integer | Default: 3306 | Port of the MySQL server. Requires login_host be defined as other than localhost if login_port is used. |
| login_unix_socket string | The path to a Unix domain socket for local connections. | |
| login_user string | The username used to authenticate with. |
Note
login_password and login_user are required when you are passing credentials. If none are present, the module will attempt to read the credentials from ~/.my.cnf, and finally fall back to using the MySQL default login of ‘root’ with no password.# Display info from mysql-hosts group (using creds from ~/.my.cnf to connect):
# ansible mysql-hosts -m mysql_info
# Display only databases and users info:
# ansible mysql-hosts -m mysql_info -a 'filter=databases,users'
# Display only slave status:
# ansible standby -m mysql_info -a 'filter=slave_status'
# Display all info from databases group except settings:
# ansible databases -m mysql_info -a 'filter=!settings'
- name: Collect all possible information using passwordless root access
mysql_info:
login_user: root
- name: Get MySQL version with non-default credentials
mysql_info:
login_user: mysuperuser
login_password: mysuperpass
filter: version
- name: Collect all info except settings and users by root
mysql_info:
login_user: root
login_password: rootpass
filter: "!settings,!users"
- name: Collect info about databases and version using ~/.my.cnf as a credential file
become: yes
mysql_info:
filter:
- databases
- version
- name: Collect info about databases and version using ~alice/.my.cnf as a credential file
become: yes
mysql_info:
config_file: /home/alice/.my.cnf
filter:
- databases
Common return values are documented here, the following are the fields unique to this module:
| Key | Returned | Description | |
|---|---|---|---|
| databases dictionary | if not excluded by filter | Information about databases. Sample: [{'mysql': {'size': 656594}, 'information_schema': {'size': 73728}}] | |
| size dictionary | if not excluded by filter | Database size in bytes. Sample: {'size': 656594} | |
| engines dictionary | if not excluded by filter | Information about the server's storage engines. Sample: [{'CSV': {'Comment': 'CSV storage engine', 'Savepoints': 'NO', 'Support': 'YES', 'Transactions': 'NO', 'XA': 'NO'}}] | |
| master_status dictionary | if master | Master status information. Sample: [{'Binlog_Do_DB': '', 'Binlog_Ignore_DB': 'mysql', 'File': 'mysql-bin.000001', 'Position': 769}] | |
| settings dictionary | if not excluded by filter | Global settings (variables) information. Sample: [{'innodb_open_files': 300, 'innodb_page_size"': 16384}] | |
| slave_hosts dictionary | if master | Slave status information. Sample: [{'2': {'Host': '', 'Master_id': 1, 'Port': 3306}}] | |
| slave_status dictionary | if standby | Slave status information. Sample: [{'192.168.1.101': {'3306': {'replication_user': {'Connect_Retry': 60, 'Exec_Master_Log_Pos': 769, 'Last_Errno': 0}}}}] | |
| users dictionary | if not excluded by filter | Users information. Sample: [{'localhost': {'root': {'Alter_priv': 'Y', 'Alter_routine_priv': 'Y'}}}] | |
| version dictionary | if not excluded by filter | Database server version. Sample: {'version': {'major': 5, 'minor': 5, 'release': 60}} | |
| major integer | if not excluded by filter | Major server version. Sample: 5 | |
| minor integer | if not excluded by filter | Minor server version. Sample: 5 | |
| release integer | if not excluded by filter | Release server version. Sample: 60 | |
Hint
If you notice any issues in this documentation, you can edit this document to improve it.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.9/modules/mysql_info_module.html