community / community.general / 0.1.4 / module / mysql_info Gather information about MySQL servers Authors: Andrew Klychkov (@Andersson007)community.general.mysql_info (0.1.4) — module
Install with ansible-galaxy collection install community.general:==0.1.4
collections: - name: community.general version: 0.1.4
Gathers information about MySQL servers.
# 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 - version
- name: Collect info about databases including empty and excluding their sizes become: yes mysql_info: config_file: /home/alice/.my.cnf filter: - databases exclude_fields: db_size return_empty_dbs: yes
filter: description: - Limit the collected information by comma separated string or YAML list. - Allowable values are C(version), C(databases), C(settings), C(global_status), C(users), C(engines), C(master_status), C(slave_status), C(slave_hosts). - By default, collects all subsets. - You can use '!' before value (for example, C(!settings)) to exclude it from the information. - If you pass including and excluding values to the filter, for example, I(filter=!settings,version), the excluding values, C(!settings) in this case, will be ignored. elements: str type: list ca_cert: aliases: - ssl_ca description: - The path to a Certificate Authority (CA) certificate. This option, if used, must specify the same certificate as used by the server. type: path login_db: description: - Database name to connect to. - It makes sense if I(login_user) is allowed to connect to a specific database only. type: str client_key: aliases: - ssl_key description: - The path to the client private key. type: path login_host: default: localhost description: - Host running the database. - In some cases for local connections the I(login_unix_socket=/path/to/mysqld/socket), that is usually C(/var/run/mysqld/mysqld.sock), needs to be used instead of I(login_host=localhost). type: str login_port: default: 3306 description: - Port of the MySQL server. Requires I(login_host) be defined as other than localhost if login_port is used. type: int login_user: description: - The username used to authenticate with. type: str client_cert: aliases: - ssl_cert description: - The path to a client public key certificate. type: path config_file: default: ~/.my.cnf description: - Specify a config file from which user and password are to be read. type: path exclude_fields: description: - List of fields which are not needed to collect. - 'Supports elements: C(db_size). Unsupported elements will be ignored' elements: str type: list version_added: 0.2.0 version_added_collection: community.general login_password: description: - The password used to authenticate with. type: str connect_timeout: default: 30 description: - The connection timeout when connecting to the MySQL server. type: int return_empty_dbs: default: false description: - Includes names of empty databases to returned dictionary. type: bool login_unix_socket: description: - The path to a Unix domain socket for local connections. type: str
databases: contains: size: description: Database size in bytes. returned: if not excluded by filter sample: size: 656594 type: dict description: Information about databases. returned: if not excluded by filter sample: - information_schema: size: 73728 mysql: size: 656594 type: dict engines: description: Information about the server's storage engines. returned: if not excluded by filter sample: - CSV: Comment: CSV storage engine Savepoints: 'NO' Support: 'YES' Transactions: 'NO' XA: 'NO' type: dict global_status: description: Global status information. returned: if not excluded by filter sample: - Innodb_buffer_pool_read_requests: 123 Innodb_buffer_pool_reads: 32 type: dict master_status: description: Master status information. returned: if master sample: - Binlog_Do_DB: '' Binlog_Ignore_DB: mysql File: mysql-bin.000001 Position: 769 type: dict settings: description: Global settings (variables) information. returned: if not excluded by filter sample: - innodb_open_files: 300 innodb_page_size": 16384 type: dict slave_hosts: description: Slave status information. returned: if master sample: - '2': Host: '' Master_id: 1 Port: 3306 type: dict slave_status: description: Slave status information. returned: if standby sample: - 192.168.1.101: '3306': replication_user: Connect_Retry: 60 Exec_Master_Log_Pos: 769 Last_Errno: 0 type: dict users: description: Users information. returned: if not excluded by filter sample: - localhost: root: Alter_priv: Y Alter_routine_priv: Y type: dict version: contains: major: description: Major server version. returned: if not excluded by filter sample: 5 type: int minor: description: Minor server version. returned: if not excluded by filter sample: 5 type: int release: description: Release server version. returned: if not excluded by filter sample: 60 type: int description: Database server version. returned: if not excluded by filter sample: version: major: 5 minor: 5 release: 60 type: dict