community.general.proxysql_mysql_users (0.2.1) — module

Adds or removes mysql users from proxysql admin interface.

Authors: Ben Mildren (@bmildren)

Install collection

Install with ansible-galaxy collection install community.general:==0.2.1


Add to requirements.yml

  collections:
    - name: community.general
      version: 0.2.1

Description

The M(proxysql_mysql_users) module adds or removes mysql users using the proxysql admin interface.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
---
# This example adds a user, it saves the mysql user config to disk, but
# avoids loading the mysql user config to runtime (this might be because
# several users are being added and the user wants to push the config to
# runtime in a single batch using the M(proxysql_manage_config) module).  It
# uses supplied credentials to connect to the proxysql admin interface.

- name: Add a user
  proxysql_mysql_users:
    login_user: 'admin'
    login_password: 'admin'
    username: 'productiondba'
    state: present
    load_to_runtime: False
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# This example removes a user, saves the mysql user config to disk, and
# dynamically loads the mysql user config to runtime.  It uses credentials
# in a supplied config file to connect to the proxysql admin interface.

- name: Remove a user
  proxysql_mysql_users:
    config_file: '~/proxysql.cnf'
    username: 'mysqlboy'
    state: absent

Inputs

    
state:
    choices:
    - present
    - absent
    default: present
    description:
    - When C(present) - adds the user, when C(absent) - removes the user.

active:
    description:
    - A user with I(active) set to C(False) will be tracked in the database, but will
      be never loaded in the in-memory data structures. If omitted the proxysql database
      default for I(active) is C(True).
    type: bool

backend:
    default: true
    description:
    - If I(backend) is set to C(True), this (username, password) pair is used for authenticating
      to the ProxySQL instance.
    type: bool

use_ssl:
    description:
    - If I(use_ssl) is set to C(True), connections by this user will be made using SSL
      connections. If omitted the proxysql database default for I(use_ssl) is C(False).
    type: bool

frontend:
    default: true
    description:
    - If I(frontend) is set to C(True), this (username, password) pair is used for authenticating
      to the mysqld servers against any hostgroup.
    type: bool

password:
    description:
    - Password of the user connecting to the mysqld or ProxySQL instance.

username:
    description:
    - Name of the user connecting to the mysqld or ProxySQL instance.
    required: true

login_host:
    default: 127.0.0.1
    description:
    - The host used to connect to ProxySQL admin interface.
    type: str

login_port:
    default: 6032
    description:
    - The port used to connect to ProxySQL admin interface.
    type: int

login_user:
    description:
    - The username used to authenticate to ProxySQL admin interface.
    type: str

config_file:
    default: ''
    description:
    - Specify a config file from which I(login_user) and I(login_password) are to be read.
    type: path

fast_forward:
    description:
    - If I(fast_forward) is set to C(True), I(fast_forward) will bypass the query processing
      layer (rewriting, caching) and pass through the query directly as is to the backend
      server. If omitted the proxysql database default for I(fast_forward) is C(False).
    type: bool

save_to_disk:
    default: 'yes'
    description:
    - Save config to sqlite db on disk to persist the configuration.
    type: bool

default_schema:
    description:
    - The schema to which the connection should change to by default.

login_password:
    description:
    - The password used to authenticate to ProxySQL admin interface.
    type: str

load_to_runtime:
    default: 'yes'
    description:
    - Dynamically load config to runtime memory.
    type: bool

max_connections:
    description:
    - The maximum number of connections ProxySQL will open to the backend for this user.
      If omitted the proxysql database default for I(max_connections) is 10000.

default_hostgroup:
    description:
    - If there is no matching rule for the queries sent by this user, the traffic it generates
      is sent to the specified hostgroup. If omitted the proxysql database default for
      I(use_ssl) is 0.

transaction_persistent:
    description:
    - If this is set for the user with which the MySQL client is connecting to ProxySQL
      (thus a "frontend" user), transactions started within a hostgroup will remain within
      that hostgroup regardless of any other rules. If omitted the proxysql database default
      for I(transaction_persistent) is C(False).
    type: bool

Outputs

stdout:
  description: The mysql user modified or removed from proxysql
  returned: On create/update will return the newly modified user, on delete it will
    return the deleted record.
  sample:
    changed: true
    msg: Added user to mysql_users
    state: present
    user:
      active: 1
      backend: 1
      default_hostgroup: 1
      default_schema: null
      fast_forward: 0
      frontend: 1
      max_connections: 10000
      password: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
      schema_locked: 0
      transaction_persistent: 0
      use_ssl: 0
      username: guest_ro
    username: guest_ro
  type: dict