community / community.mysql / 3.9.0 / module / mysql_variables Manage MySQL global variables Authors: Balazs Pocze (@banyek)community.mysql.mysql_variables (3.9.0) — module
Install with ansible-galaxy collection install community.mysql:==3.9.0
collections: - name: community.mysql version: 3.9.0
Query / Set MySQL variables.
# If you encounter the "Please explicitly state intended protocol" error, # use the login_unix_socket argument - name: Check for sync_binlog setting community.mysql.mysql_variables: variable: sync_binlog login_unix_socket: /run/mysqld/mysqld.sock
- name: Set read_only variable to 1 persistently community.mysql.mysql_variables: variable: read_only value: 1 mode: persist
mode: choices: - global - persist - persist_only default: global description: - C(global) assigns C(value) to a global system variable which will be changed at runtime but won't persist across server restarts. - C(persist) assigns C(value) to a global system variable and persists it to the mysqld-auto.cnf option file in the data directory (the variable will survive service restarts). - C(persist_only) persists C(value) to the mysqld-auto.cnf option file in the data directory but without setting the global variable runtime value (the value will be changed after the next service restart). - Supported by MySQL 8.0 or later. - For more information see U(https://dev.mysql.com/doc/refman/8.0/en/set-variable.html). type: str version_added: 0.1.0 version_added_collection: community.mysql value: description: - If set, then sets variable value to this. type: str 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 variable: description: - Variable name to operate. required: true 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. - The default config file, C(~/.my.cnf), if it exists, will be read, even if I(config_file) is not specified. - The default config file, C(~/.my.cnf), if it exists, must contain a C([client]) section as a MySQL connector requirement. - To prevent the default config file from being read, set I(config_file) to be an empty string. type: path check_hostname: description: - Whether to validate the server host name when an SSL connection is required. Corresponds to MySQL CLIs C(--ssl) switch. - Setting this to C(false) disables hostname verification. Use with caution. - Requires pymysql >= 0.7.11. - This option has no effect on MySQLdb. type: bool version_added: 1.1.0 version_added_collection: community.mysql 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 login_unix_socket: description: - The path to a Unix domain socket for local connections. - Use this parameter to avoid the C(Please explicitly state intended protocol) error. type: str
queries: description: List of executed queries which modified DB's state. returned: if executed sample: - SET GLOBAL `read_only` = 1 type: list version_added: 0.1.0 version_added_collection: community.mysql