Version information
This version is compatible with:
- Puppet Enterprise 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
- Puppet >= 4.6.1 < 5.0.0
Start using this module
Add this module to your Puppetfile:
mod 'puppet-proxysql', '1.1.0'
Learn more about managing modules with a PuppetfileDocumentation
Table of Contents
- Overview
- Setup - The basics of getting started with proxysql
- Usage - Configuration options and additional functionality
- Reference - An under-the-hood peek at what the module is doing and how
- Limitations - OS compatibility, etc.
- Development - Guide for contributing to the module
Overview
The proxysql module installs, configures and manages the ProxySQL service.
This module will install the ProxySQL and manage it's configuration. It also extends Puppet to be able to manage mysql_users
, mysql_servers
, mysql_replication_hostgroups
, mysql_query_rules
, scheduler
and global_variables
.
Setup
Setup Requirements OPTIONAL
The module requires Puppet 4.x and currently supports only Debian 8 "Jessie" (and possibly Debian 7 "Wheezy").
Note: the ProxySQL-package is currently not in any public upstream package manager. So you should consider uploading it to a private package manager and manage that before calling the proxysql-class.
Beginning with proxysql
To install the ProxySQL software with all the default options:
include ::proxysql
You can customize options such as (but not limited to) listen_port
, admin_password
, monitor_password
, ...
class { '::proxysql':
listen_port => 3306,
admin_password => '654321',
monitor_password => '123456',
override_config_settings => $override_settings,
repo => {
'debs_proxysql_repo' => {
comment => 'ProxySQL repo',
location => 'http://debs.example.tld/debian',
repos => 'proxsql',
},
},
}
Usage
Configuration is done by the proxysql
class.
Customize config settings
You can override any configuration setting by using the override_config_settings
hash. This hash resembles the structure of the proxysql.cnf
file
{
admin_variables => {
refresh_interval => 2000,
...
},
mysql_variables => {
monitor_writer_is_also_reader => false,
...
},
mysql_servers => {
'mysql1' => {
'address' => '127.0.0.1',
'port' => 33061,
},
'mysql2' => {
'address' => '127.0.0.1',
'port' => 33062,
},
...
},
mysql_users => { ... },
mysql_query_rules => { ... },
scheduler => { ... },
mysql_replication_hostgroups => { ... },
}
Reference
Public classes
proxysql
: Installs and configures ProxySQL
Private classes
proxysql::install
: Installs the package(s)proxysql::config
: Manages the configuration files andglobal_variables
proxysql::repo
: Manages the repo's where ProxySQL might be in.proxysql::service
: Manages the service
parameters
proxysql
package_name
The name of the ProxySQL package in your package manager. Defaults to 'proxysql'
service_name
The name of the ProxySQL service resource. Defaults to 'proxysql'
datadir
The directory where ProxySQL will store it's data. defaults to '/var/lib/proxysql'
listen_ip
The ip where the ProxySQL service will listen on. Defaults to '0.0.0.0' aka all configured IP's on the machine
listen_port
The port where the ProxySQL service will listen on. Defaults to '6033'
listen_socket
The socket where the ProxySQL service will listen on. Defaults to '/tmp/proxysql.sock'
admin_username
The username to connect to the ProxySQL admin interface. Defaults to 'admin'
admin_password
The password to connect to the ProxySQL admin interface. Defaults to 'admin'
admin_listen_ip
The ip where the ProxySQL admin interface will listen on. Defaults to '127.0.0.1'
admin_listen_port
The port where the ProxySQL admin interface will listen on. Defaults to '6032'
admin_listen_socket
The socket where the ProxySQL admin interface will listen on. Defaults to '/tmp/proxysql_admin.sock'
monitor_username
The username ProxySQL will use to connect to the configured mysql_servers. Defaults to 'monitor'
monitor_password
The password ProxySQL will use to connect to the configured mysql_servers. Defaults to 'monitor'
config_file
The file where the ProxySQL configuration is saved. This will only be configured if manage_config_file
is set to true
.
Defaults to '/etc/proxysql.cnf'
manage_config_file
Determines wheter this module will configure the ProxySQL configuration file. Defaults to 'true'
mycnf_file_name
Path of the my.cnf file where the connections details for the admin interface is save. This is required for the providers to work.
This will only be configured if manage_mycnf_file
is set to true
. Defaults to '/root/.my.cnf'
manage_mycnf_file
Determines wheter this module will configure the my.cnf file to connect to the admin interface. Defaults to 'true'
restart
Determines wheter this module will restart ProxySQL after reconfiguring the config file. Defaults to 'false'
load_to_runtime
Specifies wheter te managed ProxySQL resources should be immediately loaded to the active runtime. Boolean, defaults to 'true'.
save_to_disk
Specifies wheter te managed ProxySQL resources should be immediately save to disk. Boolean, defaults to 'true'.
repo
These are the repo's we will configure. Currently only Debian is supported. This hash will be passed on to apt::source
. Defaults to {}.
manage_repo
Boolean to determine wheter we want to configure the repo management. Defaults to true.
override_config_settings
Which configuration variables should be overriden. Hash, defaults to {} (empty hash).
Types
proxy_global_variable
proxy_global_variable
manages a variable in the ProxySQL global_variables
admin table.
name
The name of the variable.
load_to_runtime
Specifies wheter the resource should be immediately loaded to the active runtime. Boolean, defaults to 'true'.
save_to_disk
Specifies wheter the resource should be immediately save to disk. Boolean, defaults to 'true'.
value
The value of the variable.
proxy_mysql_replication_hostgroup
proxy_mysql_replication_hostgroup
manages an entry in the ProxySQL mysql_replication_hostgroups
admin table.
ensure
Whether the resource is present. Valid values are 'present', 'absent'. Defaults to 'present'.
name
Name to describe the hostgroup config. Must be in a 'writer_hostgroup
-reader_hostgroup
' format.
load_to_runtime
Specifies wheter the resource should be immediately loaded to the active runtime. Boolean, defaults to 'true'.
save_to_disk
Specifies wheter the resource should be immediately save to disk. Boolean, defaults to 'true'.
writer_hostgroup
Id of the writer hostgroup. Required.
reader_hostgroup
Id of the reader hostgroup. Required.
comment
Optional comment.
proxy_mysql_server
proxy_mysql_server
manages an entry in the ProxySQL mysql_servers
admin table.
ensure
Whether the resource is present. Valid values are 'present', 'absent'. Defaults to 'present'.
name
Name to describe the hostgroup config. Must be in a 'hostname
:port
-hostgroup_id
' format.
load_to_runtime
Specifies wheter the resource should be immediately loaded to the active runtime. Boolean, defaults to 'true'.
save_to_disk
Specifies wheter the resource should be immediately save to disk. Boolean, defaults to 'true'.
hostgroup_id
Id of the hostgroup this server wil be configured to be part of. Integer value, required.
hostname
Hostname of the server. Required.
port
Port of the server. Required. Defaults to 3306.
status
Status of the server. Should be one of the following values: 'ONLINE', 'OFFLINE_SOFT', 'OFFLINE_HARD', 'SHUNNED'. Defaults to 'ONLINE'.
weight
Weight value of the server. The higher the value, the higher the probability this server will be chosen from the hostgroup. Integer, defaults to 0.
compression
Compression value of the serer. If the value is greater than 0, new connections to that server will use compression. Integer, defaults to 0.
max_connections
The maximum number of connections ProxySQL will open to this backend server. Even though this server will have the highest weight, no new connections will be opened to it once this limit is hit. Please ensure that the backend is configured with a correct value of max_connections to avoid that ProxySQL will try to go beyond that limit. Integer, defaults to 1000.
max_replication_lag
If greater and 0, ProxySQL will reguarly monitor replication lag and if it goes beyond such threshold it will temporary shun the host until replication catch ups. Integer, defaults to 0.
use_ssl
If set to 1, connections to the backend will use SSL. Values 0 or 1. Defaults to 0.
max_latency_ms
Ping time is regularly monitored. If a host has a ping time greater than max_latency_ms it is excluded from the connection pool (although the server stays ONLINE. Integer, defaults to 0.
comment
Optional comment.
proxy_mysql_user
proxy_mysql_user
manages an entry in the ProxySQL mysql_users
admin table.
ensure
Whether the resource is present. Valid values are 'present', 'absent'. Defaults to 'present'.
name
Username for the user. Required.
load_to_runtime
Specifies wheter the resource should be immediately loaded to the active runtime. Boolean, defaults to 'true'.
save_to_disk
Specifies wheter the resource should be immediately save to disk. Boolean, defaults to 'true'.
encrypt_password
Specifies wheter the user password should be encrypted (requires ProxySQL setting admin-hash_password
= true
). Boolean, defaults to 'true'.
password
Password for the user. Required.
Note: you should make sure that the global variable admin-hashed_passwords
is set to true
and then encrypt this password using the mysql_password()
function.
active
Flag to determine if this user is active or not. Values 0 or 1. Defaults to 1.
use_ssl
Flag to determine if this user uses SSL or not. Values 0 or 1. Defaults to 0.
default_hostgroup
Default hostgroup for the user. Integer, defaults to 0.
default_schema
Default schema for the user. String, defaults to ''.
schema_locked
Is the user locked in the default_schema
or not. Values 0 or 1. Defaults to 0.
transaction_persistent
Disable routing across hostgroups once a transaction has started for a specific user. Values 0 or 1. Defaults to 0.
fast_forward
Flag to determine fast forward or not. Values 0 or 1. Defaults to 0.
backend
Is this a backend user. Values 0 or 1. Defaults to 1.
frontend
Is this a frontend user. Values 0 or 1. Defaults to 1.
proxy_mysql_query_rule
proxy_mysql_query_rule
manages an entry in the ProxySQL mysql_query_rules
admin table.
ensure
Whether the resource is present. Valid values are 'present', 'absent'. Defaults to 'present'.
name
The name of the query rule entry, Must be in a 'mysql_query_rule-rule_id
' format.
load_to_runtime
Specifies wheter the resource should be immediately loaded to the active runtime. Boolean, defaults to 'true'.
save_to_disk
Specifies wheter the resource should be immediately save to disk. Boolean, defaults to 'true'.
rule_id
Id of the scheduler entry. Integer value, required.
active
Is the rule active or not. Boolean value 0 or 1, defaults to 0.
username
Username to apply this rule to. String, defaults to NULL.
schemaname
Schema to apply this rule to. String, defaults to NULL.
flag_in
Used to chain rules. This is the id of the previous rule to apply. Integer, defaults to 0.
flag_out
Used to chain rules. This is the id of the next rule to apply, Integer, defaults to NULL
apply
Used to chain rules.
client_addr
Match traffic from a certain address. String, defaults to NULL.
proxy_addr
Match incoming traffic on a specific local address. String, defaults to NULL.
proxy_port
Match incoming traffic on a specific local port. Integer, defaults to NULL.
digest
match queries with a specific digest, as returned by stats_mysql_query_digest
.digest
. String, defaults to NULL.
match_digest
regular expression that matches the query digest. String, defaults to NULL.
match_pattern
regular expression that matches the query text. String, defaults to NULL.
replace_pattern
this is the pattern with which to replace the matched pattern. String, defaults to NULL.
negate_match_pattern
if this is set to 1, only queries not matching the query text will be considered as a match. This acts as a NOT operator in front of the regular expression matching against match_pattern or match_digest. Boolean value 0 or 1, defaults to 0.
destination_hostgroup
The hostgroup to send this query to. Integer, defaults to NULL.
cache_ttl
The amount of miliseconds to cache the result of this query. Integer, defaults to NULL.
reconnect
feature currently not in use.
timeout
The maximum amount of miliseconds in which the matched or rewritten query should be executed. Integer, defaults to NULL.
retries
The maximum number of times a query needs to be re-executed in case of detected failure during the execution of the query. Integer, defaults to NULL.
delay
The number of milliseconds to delay the execution of the query. Integer, defaults to NULL.
error_msg
The query will be blocked, and the specified error_msg will be returned to the client. String, defaults to NULL.
log
The query will be logged. Boolean value 0 or 1, defaults to NULL.
mirror_hostgroup
see https://github.com/sysown/proxysql/blob/master/doc/mirroring.md. Integer, defaults to NULL.
mirror_flag_out
see https://github.com/sysown/proxysql/blob/master/doc/mirroring.md. Integer, defaults to NULL.
comment
Optional free form text field, usable for a descriptive comment of the query rule.
proxy_scheduler
proxy_scheduler
manages an entry in the ProxySQL scheduler
admin table.
ensure
Whether the resource is present. Valid values are 'present', 'absent'. Defaults to 'present'.
name
The name of the scheduler entry, Must be in a 'scheduler-scheduler_id
' format.
load_to_runtime
Specifies wheter the resource should be immediately loaded to the active runtime. Boolean, defaults to 'true'.
save_to_disk
Specifies wheter the resource should be immediately save to disk. Boolean, defaults to 'true'.
scheduler_id
Id of the scheduler entry. Integer value, required.
filename
The filename of the scheduler script to run. Required.
interval_ms
Interval in which to run this scheduler. In miliseconds, Integer, defaults to 10000 (10sec).
arg1
The 1st argument for the scheduler script to run. Optional, defaults to NULL.
arg2
The 2nd argument for the scheduler script to run. Optional, defaults to NULL.
arg3
The 3rd argument for the scheduler script to run. Optional, defaults to NULL.
arg4
The 4th argument for the scheduler script to run. Optional, defaults to NULL.
arg5
The 5th argument for the scheduler script to run. Optional, defaults to NULL.
comment
Optional comment.
Limitations
The module requires Puppet 4.x and currently supports only Debian 8 "Jessie" (and possibly Debian 7 "Wheezy"). It depends on the puppetlabs/mysql module (>= 3.x)
Development
This module is originally developed by Matthias Crauwels for use at Ghent University, Belgium. This module is published under the Apache 2.0 license.
We are open to feature requests, bug reports, contributions, etc...
Contributors
Original author: Matthias Crauwels
Types in this module release
Dependencies
- puppetlabs-stdlib (>= 4.6.0 < 5.0.0)
- puppetlabs-mysql (>= 3.5.0 < 4.0.0)
- puppetlabs-apt (>= 2.1.0 < 3.0.0)
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.