community.proxysql.proxysql_query_rules_fast_routing 模块 – 使用 proxysql 管理界面修改快速路由策略的查询规则

注意

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

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

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

要在 playbook 中使用它,请指定:community.proxysql.proxysql_query_rules_fast_routing

community.proxysql 1.1.0 中的新增功能

概要

要求

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

  • PyMySQL

  • mysqlclient

参数

参数

注释

comment

字符串

自由文本字段,可用于查询规则的描述性注释。

默认值: ""

config_file

路径

指定一个配置文件,从中读取 *login_user* 和 *login_password*。

默认值: ""

destination_hostgroup

整数 / 必需

将匹配的查询路由到此主机组。除非存在已启动的事务并且登录用户将 *transaction_persistent* 设置为 True(请参考 community.proxysql.proxysql_mysql_users),否则会发生这种情况。

flagIN

整数

评估方式与 **mysql_query_rules** 中的 *flagIN* 相同,并与 **mysql_query_rules** 表中指定的 *flagOUT/apply* 相关。(参见 community.proxysql.proxysql_query_rules)。

默认值: 0

force_delete

布尔值

默认情况下,我们避免在单个批次中删除多个计划;但是,如果您需要此行为并且不关心已删除的计划,可以将 *force_delete* 设置为 True

选项

  • false ← (默认)

  • true

load_to_runtime

布尔值

动态加载配置到运行时内存。

选项

  • false

  • true ← (默认)

login_host

字符串

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

默认值: "127.0.0.1"

login_password

字符串

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

login_port

整数

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

默认值: 6032

login_unix_socket

字符串

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

login_user

字符串

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

save_to_disk

布尔值

将配置保存到磁盘上的 sqlite 数据库以持久化配置。

选项

  • false

  • true ← (默认)

schemaname

字符串 / 必需

匹配 schemaname 的筛选条件,只有当连接使用 schemaname 作为其默认模式时,查询才会匹配。

state

字符串

present 时,添加规则。当 absent 时,移除规则。

选项

  • "present" ← (默认)

  • "absent"

用户名

字符串 / 必需

匹配用户名的过滤条件,只有在使用正确的用户名建立连接时,查询才会匹配。

备注

注意

  • 支持 check_mode

示例

---
# This example adds a rule for fast routing
- name: Add a rule
  community.proxysql.proxysql_query_rules_fast_routing:
    login_user: admin
    login_password: admin
    username: 'user_ro'
    schemaname: 'default'
    destination_hostgroup: 1
    comment: 'fast route user_ro to default schema'
    state: present
    save_to_disk: true
    load_to_runtime: true

返回值

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

描述

标准输出

字典

从 Proxysql 中修改或删除的 MySQL 用户。

返回:在创建/更新时,将返回新修改的规则;在所有其他情况下,将返回与提供的条件匹配的规则列表。

示例: {"changed": true, "msg": "Added rule to mysql_query_rules_fast_routing", "rules": [{"comment": "", "destination_hostgroup": 1, "flagIN": "0", "schemaname": "default", "username": "user_ro"}], "state": "present"}

作者

  • Akim Lindberg (@akimrx)