- AnsibleFest
- Products
- Community
- Webinars & Training
- Blog

Documentation

# proxysql_scheduler – Adds or removes schedules from proxysql admin interface

- Synopsis

- Requirements

- Parameters

- Examples

- Return Values

- Status

## Synopsis

- The proxysql_scheduler module adds or removes schedules using the proxysql admin interface.

## Requirements

The below requirements are needed on the host that executes this module.

- PyMySQL (Python 2.7 and Python 3.X), or

- MySQLdb (Python 2.x)

## Parameters

Parameter | Choices/Defaults | Comments
--- | --- | ---
active boolean | Choices: no yes ← | A schedule with active set to `False` will be tracked in the database, but will be never loaded in the in-memory data structures.
arg1 - |  | Argument that can be passed to the job.
arg2 - |  | Argument that can be passed to the job.
arg3 - |  | Argument that can be passed to the job.
arg4 - |  | Argument that can be passed to the job.
arg5 - |  | Argument that can be passed to the job.
comment - |  | Text field that can be used for any purposed defined by the user.
config_file path | Default: "" | Specify a config file from which login_user and login_password are to be read.
filename - / required |  | Full path of the executable to be executed.
force_delete boolean | Choices: no ← yes | By default we avoid deleting more than one schedule in a single batch, however if you need this behaviour and you're not concerned about the schedules deleted, you can set force_delete to `True`.
interval_ms - | Default: 10000 | How often (in millisecond) the job will be started. The minimum value for interval_ms is 100 milliseconds.
load_to_runtime boolean | Choices: no yes ← | Dynamically load config to runtime memory.
login_host string | Default: "127.0.0.1" | The host used to connect to ProxySQL admin interface.
login_password string |  | The password used to authenticate to ProxySQL admin interface.
login_port integer | Default: 6032 | The port used to connect to ProxySQL admin interface.
login_user string |  | The username used to authenticate to ProxySQL admin interface.
save_to_disk boolean | Choices: no yes ← | Save config to sqlite db on disk to persist the configuration.
state - | Choices: present ← absent | When `present` - adds the schedule, when `absent` - removes the schedule.

## Examples

    ---
    # 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 M(proxysql_manage_config) module).  It
    # uses supplied credentials to connect to the proxysql admin interface.

    - 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.

    - proxysql_scheduler:
        config_file: '~/proxysql.cnf'
        filename: "/opt/old_script.py"
        state: absent

## Return Values

Common return values are documented here, the following are the fields unique to this module:

Key | Returned | Description
--- | --- | ---
stdout dictionary | On create/update will return the newly modified schedule, on delete it will return the deleted record. | The schedule modified or removed from proxysql Sample: {'changed': True, 'filename': '/opt/test.py', 'msg': 'Added schedule to scheduler', 'schedules': [{'active': '1', 'arg1': None, 'arg2': None, 'arg3': None, 'arg4': None, 'arg5': None, 'comment': '', 'filename': '/opt/test.py', 'id': '1', 'interval_ms': '10000'}], 'state': 'present'}

## Status

- This module is guaranteed to have backward compatible interface changes going forward. [stableinterface]

- This module is maintained by the Ansible Community. [community]

### Authors

- Ben Mildren (@bmildren)

Hint

If you notice any issues in this documentation, you can edit this document to improve it.