ansible.builtin.mysql_replication (v2.9.24) — module

Manage MySQL replication

| "added in version" 1.3 of ansible.builtin"

Authors: Balazs Pocze (@banyek)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.24

Description

Manages MySQL server replication, slave, master status get and change master host.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Stop mysql slave thread
- mysql_replication:
    mode: stopslave
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Get master binlog file name and binlog position
- mysql_replication:
    mode: getmaster
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Change master to master server 192.0.2.1 and use binary log 'mysql-bin.000009' with position 4578
- mysql_replication:
    mode: changemaster
    master_host: 192.0.2.1
    master_log_file: mysql-bin.000009
    master_log_pos: 4578
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Check slave status using port 3308
- mysql_replication:
    mode: getslave
    login_host: ansible.example.com
    login_port: 3308

Inputs

    
mode:
    choices:
    - getslave
    - getmaster
    - changemaster
    - stopslave
    - startslave
    - resetslave
    - resetslaveall
    default: getslave
    description:
    - module operating mode. Could be getslave (SHOW SLAVE STATUS), getmaster (SHOW MASTER
      STATUS), changemaster (CHANGE MASTER TO), startslave (START SLAVE), stopslave (STOP
      SLAVE), resetslave (RESET SLAVE), resetslaveall (RESET SLAVE ALL)
    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

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

master_ssl:
    description:
    - Same as mysql variable.
    type: bool

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

master_host:
    description:
    - Same as mysql variable.
    type: str

master_port:
    description:
    - Same as mysql variable.
    type: int

master_user:
    description:
    - Same as mysql variable.
    type: str

master_ssl_ca:
    description:
    - Same as mysql variable.
    type: str

relay_log_pos:
    description:
    - Same as mysql variable.
    type: int

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

master_log_pos:
    description:
    - Same as mysql variable.
    type: int

master_ssl_key:
    description:
    - Same as mysql variable.
    type: str

relay_log_file:
    description:
    - Same as mysql variable.
    type: str

connect_timeout:
    default: 30
    description:
    - The connection timeout when connecting to the MySQL server.
    type: int

master_log_file:
    description:
    - Same as mysql variable.
    type: str

master_password:
    description:
    - Same as mysql variable.
    type: str

master_ssl_cert:
    description:
    - Same as mysql variable.
    type: str

login_unix_socket:
    description:
    - The path to a Unix domain socket for local connections.
    type: str

master_ssl_capath:
    description:
    - Same as mysql variable.
    type: str

master_ssl_cipher:
    description:
    - Same as mysql variable.
    type: str

master_auto_position:
    description:
    - Whether the host uses GTID based replication or not.
    type: bool
    version_added: '2.0'
    version_added_collection: ansible.builtin

master_connect_retry:
    description:
    - Same as mysql variable.
    type: int