community.proxysql.proxysql_manage_config 模块 – 在层之间写入 proxysql 配置设置

注意

此模块是 community.proxysql 集合 (版本 1.6.0) 的一部分。

如果您正在使用 ansible 包,则您可能已安装此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.proxysql。您需要其他要求才能使用此模块,请参阅 需求 以了解详细信息。

要在剧本中使用它,请指定:community.proxysql.proxysql_manage_config

概要

  • community.proxysql.proxysql_global_variables 模块在层之间写入 proxysql 配置设置。目前此模块将始终报告已更改状态,因此通常应与 WHEN 一起使用,但是当所有表在 proxysql 中都可用 CHECKSUM 表命令时,这将在未来版本中更改。

需求

执行此模块的主机需要以下需求。

  • PyMySQL

  • mysqlclient

参数

参数

注释

action

字符串 / 必需

提供的 action 与提供的 direction 结合使用,以提供我们希望如何在 config_layers 之间移动 config_settings 的语义。

选项

  • "LOAD"

  • "SAVE"

config_file

路径

指定一个配置文件,从中读取 login_userlogin_password

默认值: ""

config_layer

字符串 / 必需

RUNTIME - 代表 ProxySQL 的内存中数据结构,由处理请求的线程使用。MEMORY - (有时也称为主内存)代表内存中的 SQLite3 数据库。DISK - 代表磁盘上的 SQLite3 数据库。CONFIG - 是经典的配置文件。您只能从配置文件中加载 LOAD。

选项

  • "MEMORY"

  • "DISK"

  • "RUNTIME"

  • "CONFIG"

config_settings

字符串 / 必需

config_settings 指定我们要写入哪个配置。

选项

  • "MYSQL USERS"

  • "MYSQL SERVERS"

  • "MYSQL QUERY RULES"

  • "MYSQL VARIABLES"

  • "ADMIN VARIABLES"

  • "SCHEDULER"

direction

字符串 / 必需

FROM - 表示我们正在从提供的 config_layer 读取值并写入下一层。TO - 表示我们正在从前一层读取并写入提供的 config_layer。”

选项

  • "FROM"

  • "TO"

login_host

字符串

用于连接到 ProxySQL 管理界面的主机。

默认值: "127.0.0.1"

login_password

字符串

用于对 ProxySQL 管理界面进行身份验证的密码。

login_port

整数

用于连接到 ProxySQL 管理界面的端口。

默认值: 6032

login_unix_socket

字符串

用于连接到 ProxySQL 管理界面的套接字。

login_user

字符串

用于对 ProxySQL 管理界面进行身份验证的用户名。

备注

注意

  • 支持 check_mode

示例

---
# This example saves the mysql users config from memory to disk. It uses
# supplied credentials to connect to the proxysql admin interface.

- name: Save the mysql users config from memory to disk
  community.proxysql.proxysql_manage_config:
    login_user: 'admin'
    login_password: 'admin'
    action: "SAVE"
    config_settings: "MYSQL USERS"
    direction: "FROM"
    config_layer: "MEMORY"

# This example loads the mysql query rules config from memory to runtime. It
# uses supplied credentials to connect to the proxysql admin interface.

- name: Load the mysql query rules config from memory to runtime
  community.proxysql.proxysql_manage_config:
    config_file: '~/proxysql.cnf'
    action: "LOAD"
    config_settings: "MYSQL QUERY RULES"
    direction: "TO"
    config_layer: "RUNTIME"

返回值

常见返回值已在 此处 记录,以下是此模块特有的字段

描述

stdout

字典

仅报告操作是否报告了更改。

已返回:当前返回的值将始终为 changed=True。

示例: {"changed": true}

作者

  • Ben Mildren (@bmildren)