community.proxysql.proxysql_scheduler 模块 – 在 ProxySQL 管理界面添加或删除调度

注意

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

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

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

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

概要

要求

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

  • PyMySQL

  • mysqlclient

参数

参数

注释

active

布尔值

将 *active* 设置为 False 的调度将被跟踪在数据库中,但永远不会加载到内存中的数据结构中。

选项

  • false

  • true ← (默认)

arg1

字符串

可以传递给作业的参数。

arg2

字符串

可以传递给作业的参数。

arg3

字符串

可以传递给作业的参数。

arg4

字符串

可以传递给作业的参数。

arg5

字符串

可以传递给作业的参数。

comment

字符串

可用于用户定义的任何用途的文本字段。

config_file

路径

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

默认值: ""

filename

字符串 / 必需

要执行的可执行文件的完整路径。

force_delete

布尔值

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

选项

  • false ← (默认)

  • true

interval_ms

整数

作业启动的频率(以毫秒为单位)。*interval_ms* 的最小值为 100 毫秒。

默认值: 10000

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 ← (默认)

state

字符串

present 时 - 添加调度,当 absent 时 - 删除调度。

选项

  • "present" ← (默认)

  • "absent"

备注

注意

  • 支持 check_mode

示例

---
# This example adds a schedule, it saves the scheduler config to disk, but
# avoids loading the scheduler config to runtime (this might be because
# several servers are being added and the user wants to push the config to
# runtime in a single batch using the community.general.proxysql_manage_config
# module).  It uses supplied credentials to connect to the proxysql admin
# interface.

- name: Add a schedule
  community.proxysql.proxysql_scheduler:
    login_user: 'admin'
    login_password: 'admin'
    interval_ms: 1000
    filename: "/opt/maintenance.py"
    state: present
    load_to_runtime: false

# This example removes a schedule, saves the scheduler config to disk, and
# dynamically loads the scheduler config to runtime.  It uses credentials
# in a supplied config file to connect to the proxysql admin interface.

- name: Remove a schedule
  community.proxysql.proxysql_scheduler:
    config_file: '~/proxysql.cnf'
    filename: "/opt/old_script.py"
    state: absent

返回值

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

描述

stdout

字典

从 ProxySQL 修改或删除的调度。

返回:在创建/更新时将返回新修改的调度,在删除时将返回已删除的记录。

示例: {"changed": true, "filename": "/opt/test.py", "msg": "已将计划添加到调度程序", "schedules": [{"active": "1", "arg1": null, "arg2": null, "arg3": null, "arg4": null, "arg5": null, "comment": "", "filename": "/opt/test.py", "id": "1", "interval_ms": "10000"}], "state": "present"}

作者

  • Ben Mildren (@bmildren)