Puppet Class: proxysql

Inherits:
proxysql::params
Inherited by:
proxysql::prerequisites
Defined in:
manifests/init.pp

Summary

Install and configure ProxySQL.

Overview

Parameters:

  • package_name (String) (defaults to: 'proxysql')

    The name of the ProxySQL package in your package manager.

  • package_ensure (String) (defaults to: 'installed')

    The ensure of the ProxySQL package resource.

  • package_install_options (Array[String]) (defaults to: [])

    An array of additional options to pass when installing a package.

  • service_name (String) (defaults to: 'proxysql')

    The name of the ProxySQL service resource.

  • service_ensure (String) (defaults to: 'running')

    The ensure of the ProxySQL service resource.

  • datadir (String) (defaults to: $proxysql::params::datadir)

    The directory where ProxySQL will store its data.

  • datadir_mode (Stdlib::Filemode) (defaults to: '0600')

    The filesystem mode for the ‘datadir`.

  • errorlog_file (Optional[Stdlib::Unixpath]) (defaults to: undef)

    The File where ProxySQL will store its error logs. Available from ProxySQL v2.0.0

  • errorlog_file_mode (Stdlib::Filemode) (defaults to: '0600')

    The filesystem mode for the ‘errorlog_file`. Available from ProxySQL v2.0.0

  • errorlog_file_owner (String) (defaults to: 'proxysql')

    Owner of the ‘errorlog_file`. Available from ProxySQL v2.0.0

  • errorlog_file_group (String) (defaults to: 'proxysql')

    Group of the ‘errorlog_file`. Available from ProxySQL v2.0.0

  • manage_selinux (Boolean) (defaults to: true)

    Whether to create the required selinux rules for logrotate to work. This parameter also requires the ‘puppet/selinux` module to be installed.

  • manage_mysql_client (Boolean) (defaults to: true)

    Whether to include the mysql::client class. You may have mysql::client included or managed with different parameters elsewhere in your catalogue.

  • listen_ip (String) (defaults to: '0.0.0.0')

    The ip where the ProxySQL service will listen on.

  • listen_port (Integer) (defaults to: 6033)

    The port where the ProxySQL service will listen on.

  • listen_socket (String) (defaults to: $proxysql::params::listen_socket)

    The socket where the ProxySQL service will listen on.

  • admin_username (String) (defaults to: 'admin')

    The username to connect to the ProxySQL admin interface.

  • admin_password (Sensitive[String]) (defaults to: Sensitive('admin'))

    The password to connect to the ProxySQL admin interface.

  • stats_username (String) (defaults to: 'stats')

    The username to connect with read-only permissions to the ProxySQL admin interface.

  • stats_password (Sensitive[String]) (defaults to: Sensitive('stats'))

    The password to connect with read-only permissions to the ProxySQL admin interface.

  • admin_listen_ip (String) (defaults to: '127.0.0.1')

    The ip where the ProxySQL admin interface will listen on.

  • admin_listen_port (Integer) (defaults to: 6032)

    The port where the ProxySQL admin interface will listen on.

  • admin_listen_socket (String) (defaults to: $proxysql::params::admin_listen_socket)

    The socket where the ProxySQL admin interface will listen on. Changing this on a running system will result in failing runs.

  • monitor_username (String) (defaults to: 'monitor')

    The username ProxySQL will use to connect to the configured mysql_servers.

  • monitor_password (Sensitive[String]) (defaults to: Sensitive('monitor'))

    The password ProxySQL will use to connect to the configured mysql_servers.

  • config_file (String) (defaults to: '/etc/proxysql.cnf')

    The file where the ProxySQL configuration is saved. This will only be configured if ‘manage_config_file` is set to `true`.

  • manage_config_file (Boolean) (defaults to: true)

    Determines whether this module will configure the ProxySQL configuration file.

  • mycnf_file_name (String) (defaults to: '/root/.my.cnf')

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

  • manage_mycnf_file (Boolean) (defaults to: true)

    Determines whether this module will configure the my.cnf file to connect to the admin interface. This is required for the providers to work.

  • restart (Boolean) (defaults to: false)

    Determines whether this module will restart ProxySQL after reconfiguring the config file.

  • load_to_runtime (Boolean) (defaults to: true)

    Specifies whether te managed ProxySQL resources should be immediately loaded to the active runtime.

  • save_to_disk (Boolean) (defaults to: true)

    Specifies whether te managed ProxySQL resources should be immediately save to disk.

  • manage_repo (Boolean) (defaults to: true)

    Determines whether this module will manage the repositories where ProxySQL might be.

  • version (Pattern[/^[1|2]\.\d+\.\d+/]) (defaults to: $proxysql::params::version)

    The version of proxysql being managed. This parameter affects the repository configured when ‘manage_repo == true` and how the service is managed. It does not affect the package version being installed. It is used as a hint to the puppet module on how to configure proxysql. To control the exact version deployed, use `package_name` or `package_source`. Currently defaults to ’2.0.7’ or the value of the ‘proxysql_version` fact.

  • package_source (Optional[String[1]]) (defaults to: undef)

    location of a proxysql package. When specified, this package will be installed with the ‘package_provider` and the `manage_repo` setting will be ignored. Since version 4 of this module, this defaults to `undef` and needs to be specified when you don’t want to use a package from a repository.

  • package_provider (Enum['dpkg','rpm']) (defaults to: $proxysql::params::package_provider)

    provider for ‘package_source`.

  • package_checksum_value (Optional[String[1]]) (defaults to: undef)

    The checksum of the package. Optional and only applicable when ‘package_source` is provided.

  • package_checksum_type (Optional[String[1]]) (defaults to: undef)

    The ‘type’ of ‘package_checksum_value`. Optional and only applicable when `package_checksum_value` is provided.

  • package_dependencies (Array[String[1]]) (defaults to: $proxysql::params::package_dependencies)

    A list of packages which should be additionally installed.

  • sys_owner (String) (defaults to: $version ? { /^1/ => 'root', /^2/ => 'proxysql')

    Owner of the datadir and config_file.

  • sys_group (String) (defaults to: $sys_owner)

    Group of the datadir and config_file.

  • override_config_settings (Hash) (defaults to: {})

    Which configuration variables should be overriden.

  • node_name (String) (defaults to: "${facts['networking']['fqdn']}:${admin_listen_port}")

    The name of the node.

  • cluster_name (Optional[String[1]]) (defaults to: undef)

    If set, proxysql_servers with the same cluster_name will be automatically added to the same cluster and will synchronize their configuration parameters.

  • cluster_username (String) (defaults to: 'cluster')

    The username ProxySQL will use to connect to the configured mysql_clusters

  • cluster_password (Sensitive[String]) (defaults to: Sensitive('cluster'))

    The password ProxySQL will use to connect to the configured mysql_clusters.

  • mysql_client_package_name (Optional[String]) (defaults to: undef)

    The name of the mysql client package in your package manager.

  • manage_hostgroup_for_servers (Boolean) (defaults to: true)

    Determines whether this module will manage hostgroup_id for mysql_servers. If false - it will skip difference in this value between manifest and defined in ProxySQL.

  • mysql_servers (Optional[Proxysql::Server]) (defaults to: undef)

    Array of mysql_servers, that will be created in ProxySQL.

  • mysql_users (Optional[Proxysql::User]) (defaults to: undef)

    Array of mysql_users, that will be created in ProxySQL.

  • mysql_hostgroups (Optional[Proxysql::Hostgroup]) (defaults to: undef)

    Array of mysql_hostgroups, that will be created in ProxySQL.

  • mysql_group_replication_hostgroups (Optional[Proxysql::GroupReplicationHostgroup]) (defaults to: undef)

    Hash of mysql_group_replication_hostgroups, that will be created in ProxySQL.

  • mysql_galera_hostgroups (Optional[Proxysql::GaleraHostgroup]) (defaults to: undef)

    Hash of mysql_galera_hostgroups, that will be created in ProxySQL.

  • mysql_rules (Optional[Proxysql::Rule]) (defaults to: undef)

    Array of mysql_rules, that will be created in ProxySQL.

  • schedulers (Optional[Proxysql::Scheduler]) (defaults to: undef)

    Array of schedulers, that will be created in ProxySQL.

  • split_config (Boolean) (defaults to: false)

    If set, ProxySQL config file will be split in 2: main config file with admin and mysql variables and proxy config file with serversusershostgroupsscheduler params.

  • proxy_config_file (String) (defaults to: '/etc/proxysql_proxy.cnf')

    The file where serversusershostgroupsschedulerrules params of ProxySQL configuration are saved This will only be configured if ‘split_config` is set to `true`.

  • manage_proxy_config_file (Boolean) (defaults to: true)

    Determines whether this module will update the ProxySQL proxy configuration file.



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'manifests/init.pp', line 130

class proxysql (
  Optional[String[1]] $cluster_name = undef,
  String $package_name = 'proxysql',
  Optional[String] $mysql_client_package_name = undef,
  String $package_ensure = 'installed',
  Array[String] $package_install_options = [],
  String $service_name = 'proxysql',
  String $service_ensure = 'running',

  String $datadir = $proxysql::params::datadir,
  Stdlib::Filemode $datadir_mode = '0600',
  Boolean $manage_selinux = true,
  Boolean $manage_mysql_client = true,

  Optional[Stdlib::Unixpath] $errorlog_file = undef,
  Stdlib::Filemode $errorlog_file_mode = '0600',
  String $errorlog_file_owner = 'proxysql',
  String $errorlog_file_group = 'proxysql',

  String $listen_ip = '0.0.0.0',
  Integer $listen_port = 6033,
  String $listen_socket = $proxysql::params::listen_socket,

  String $admin_username = 'admin',
  Sensitive[String] $admin_password = Sensitive('admin'),
  String $admin_listen_ip = '127.0.0.1',
  Integer $admin_listen_port = 6032,
  String $admin_listen_socket = $proxysql::params::admin_listen_socket,

  String $stats_username = 'stats',
  Sensitive[String] $stats_password = Sensitive('stats'),

  String $monitor_username = 'monitor',
  Sensitive[String] $monitor_password = Sensitive('monitor'),

  Boolean $split_config = false,

  String $proxy_config_file = '/etc/proxysql_proxy.cnf',
  Boolean $manage_proxy_config_file = true,

  String $config_file = '/etc/proxysql.cnf',
  Boolean $manage_config_file = true,

  String $mycnf_file_name = '/root/.my.cnf',
  Boolean $manage_mycnf_file = true,

  Boolean $restart = false,

  Boolean $load_to_runtime = true,
  Boolean $save_to_disk = true,

  Boolean $manage_repo = true,
  Pattern[/^[1|2]\.\d+\.\d+/] $version = $proxysql::params::version,

  Optional[String[1]] $package_source         = undef,
  Optional[String[1]] $package_checksum_value = undef,
  Optional[String[1]] $package_checksum_type  = undef,
  Array[String[1]]    $package_dependencies   = $proxysql::params::package_dependencies,
  Enum['dpkg','rpm']  $package_provider       = $proxysql::params::package_provider,

  String $sys_owner = $version ? {
    /^1/ => 'root',
    /^2/ => 'proxysql',
  },
  String $sys_group = $sys_owner,

  String $cluster_username = 'cluster',
  Sensitive[String] $cluster_password = Sensitive('cluster'),

  Hash $override_config_settings = {},

  String $node_name = "${facts['networking']['fqdn']}:${admin_listen_port}",
  Boolean $manage_hostgroup_for_servers = true,
  Optional[Proxysql::Server] $mysql_servers = undef,
  Optional[Proxysql::User] $mysql_users = undef,
  Optional[Proxysql::Hostgroup] $mysql_hostgroups = undef,
  Optional[Proxysql::GroupReplicationHostgroup] $mysql_group_replication_hostgroups = undef,
  Optional[Proxysql::GaleraHostgroup] $mysql_galera_hostgroups = undef,
  Optional[Proxysql::Rule] $mysql_rules = undef,
  Optional[Proxysql::Scheduler] $schedulers = undef,
) inherits proxysql::params {
  $default_settings = {
    datadir => $datadir,
    errorlog => $errorlog_file,
    admin_variables => {
      admin_credentials => "${admin_username}:${admin_password.unwrap}",
      mysql_ifaces      => "${admin_listen_ip}:${admin_listen_port};${admin_listen_socket}",
      stats_credentials => "${stats_username}:${stats_password.unwrap}",
    },
    mysql_variables => {
      interfaces       => "${listen_ip}:${listen_port};${listen_socket}",
      monitor_username => $monitor_username,
      monitor_password => $monitor_password.unwrap,
    },
    mysql_servers => {},
    mysql_users => {},
    mysql_query_rules => {},
    scheduler => {},
    mysql_replication_hostgroups => {},
    mysql_group_replication_hostgroups => {},
    mysql_galera_hostgroups => {},
  }.filter |$key, $val| { $val =~ NotUndef }

  $cluster_settings = $cluster_name ? {
    String  => {
      admin_variables => {
        admin_credentials => "${admin_username}:${admin_password.unwrap};${cluster_username}:${cluster_password.unwrap}",
        cluster_username  => $cluster_username,
        cluster_password  => "${cluster_password.unwrap}",
      },
    },
    default => {},
  }

  $config_settings = deep_merge($default_settings, $cluster_settings, $override_config_settings)

  contain proxysql::prerequisites
  contain proxysql::repo
  contain proxysql::install
  contain proxysql::config
  contain proxysql::service
  contain proxysql::admin_credentials
  contain proxysql::reload_config
  contain proxysql::configure

  if $manage_selinux and extlib::has_module('puppet/selinux') and fact('os.selinux.current_mode') in ['enforcing','permissive'] {
    include proxysql::selinux
  }

  Class['proxysql::prerequisites']
  -> Class['proxysql::repo']
  -> Class['proxysql::install']
  -> Class['proxysql::config']
  -> Class['proxysql::service']
  -> Class['proxysql::admin_credentials']
  -> Class['proxysql::reload_config']
  -> Class['proxysql::configure']

  Class['proxysql::install']
  ~> Class['proxysql::service']

  if $restart {
    Class['proxysql::config']
    ~> Class['proxysql::service']
  }
}