community.proxysql.proxysql_pgsql_servers module – Adds or removes pgsql hosts from proxysql admin interface
Note
This module is part of the community.proxysql collection (version 1.8.0).
You might already have this collection installed if you are using the ansible package.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.proxysql.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.proxysql.proxysql_pgsql_servers.
New in community.proxysql 1.8.0
Synopsis
The community.proxysql.proxysql_pgsql_servers module adds or removes pgsql hosts using the proxysql admin interface.
Requirements
The below requirements are needed on the host that executes this module.
PyMySQL
mysqlclient
Parameters
Parameter |
Comments |
|---|---|
Text field that can be used for any purposes defined by the user. Could be a description of what the host stores, a reminder of when the host was added or disabled, or a JSON processed by some checker script. Default: |
|
If compression is set to |
|
Specify a config file from which login_user and login_password are to be read. Default: |
|
The hostgroup in which this PostgreSQL instance is included. An instance can be part of one or more hostgroups. Default: |
|
The hostname or ip address at which the PostgreSQL instance can be contacted. |
|
Dynamically load config to runtime memory. Choices:
|
|
The host used to connect to ProxySQL admin interface. Default: |
|
The password used to authenticate to ProxySQL admin interface. |
|
The port used to connect to ProxySQL admin interface. Default: |
|
The socket used to connect to ProxySQL admin interface. |
|
The username used to authenticate to ProxySQL admin interface. |
|
The maximum number of connections ProxySQL will open to this backend server. If omitted the proxysql database default for max_connections is 1000. |
|
Ping time is monitored regularly. If a host has a ping time greater than max_latency_ms it is excluded from the connection pool (although the server stays ONLINE). If omitted the proxysql database default for max_latency_ms is 0. |
|
If greater than 0, ProxySQL will regularly monitor replication lag. If replication lag goes above max_replication_lag, proxysql will temporarily shun the server until replication catches up. If omitted the proxysql database default for max_replication_lag is 0. |
|
The port at which the PostgreSQL instance can be contacted. Default: |
|
Save config to sqlite db on disk to persist the configuration. Choices:
|
|
When Choices:
|
|
ONLINE - Backend server is fully operational. SHUNNED - The server is temporarily taken out of use because either too many connection errors happened in a short time, or replication lag exceeded the allowed threshold. OFFLINE_SOFT - When a server is put into Choices:
|
|
If use_ssl is set to Choices:
|
|
The bigger the weight of a server relative to other weights, the higher the probability of the server being chosen from the hostgroup. If omitted the proxysql database default for weight is 1. |
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: full |
Do not make any changes to memory, disk, or runtime. |
Examples
---
# This example adds a server, it saves the pgsql server config to disk, but
# avoids loading the pgsql server 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.proxysql.proxysql_manage_config
# module). It uses supplied credentials to connect to the proxysql admin
# interface.
- name: Add a server
community.proxysql.proxysql_pgsql_servers:
login_user: 'admin'
login_password: 'admin'
hostname: 'pgsql01'
state: present
load_to_runtime: false
# This example removes a server, saves the pgsql server config to disk, and
# dynamically loads the pgsql server config to runtime. It uses credentials
# in a supplied config file to connect to the proxysql admin interface.
- name: Remove a server
community.proxysql.proxysql_pgsql_servers:
config_file: '~/proxysql.cnf'
hostname: 'pgsql02'
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
The pgsql host modified or removed from proxysql Returned: On create/update will return the newly modified host, on delete it will return the deleted record. Sample: |