From 15faf43e455ecf6c44d5d4bb3a4a76e3810f3e0d Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Thu, 23 Aug 2018 20:36:27 +0300 Subject: [PATCH 01/21] add support for Proxysql cluster --- README.markdown | 24 ++++ lib/puppet/provider/proxy_cluster/proxysql.rb | 128 ++++++++++++++++++ lib/puppet/type/proxy_cluster.rb | 53 ++++++++ manifests/cluster.pp | 22 +++ manifests/init.pp | 32 ++++- manifests/install.pp | 2 + manifests/params.pp | 4 + spec/classes/proxysql_spec.rb | 11 +- 8 files changed, 272 insertions(+), 4 deletions(-) create mode 100644 lib/puppet/provider/proxy_cluster/proxysql.rb create mode 100644 lib/puppet/type/proxy_cluster.rb create mode 100644 manifests/cluster.pp diff --git a/README.markdown b/README.markdown index 338d170a..d1913675 100644 --- a/README.markdown +++ b/README.markdown @@ -191,6 +191,18 @@ group of the datadir and config_file, defaults to 'root' ##### `override_config_settings` Which configuration variables should be overriden. Hash, defaults to `{}` (empty hash). +##### `cluster_name` +If set, proxysql_servers with the same cluster_name will be automatically added to the same cluster and will synchronize their configuration parameters. +Defaults to '' + +##### `cluster_username` +The username ProxySQL will use to connect to the configured mysql_clusters +Defaults to 'cluster' + +##### `cluster_password` +The password ProxySQL will use to connect to the configured mysql_clusters. Defaults to 'cluster' + + ## Types #### proxy_global_variable @@ -208,6 +220,18 @@ Specifies wheter the resource should be immediately save to disk. Boolean, defau ##### `value` The value of the variable. +#### proxy_cluster +`proxy_cluster` manages an entry in the ProxySQL `proxysql_clusters` admin table. + +##### `name` +The name of the resource. + +##### `hostname` +Hostname of the server. Required. + +##### `port` +Port of the server. Required. Defaults to 3306. + #### proxy_mysql_replication_hostgroup `proxy_mysql_replication_hostgroup` manages an entry in the ProxySQL `mysql_replication_hostgroups` admin table. diff --git a/lib/puppet/provider/proxy_cluster/proxysql.rb b/lib/puppet/provider/proxy_cluster/proxysql.rb new file mode 100644 index 00000000..cd949081 --- /dev/null +++ b/lib/puppet/provider/proxy_cluster/proxysql.rb @@ -0,0 +1,128 @@ +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'proxysql')) +Puppet::Type.type(:proxy_cluster).provide(:proxysql, parent: Puppet::Provider::Proxysql) do + desc 'Manage cluster for a ProxySQL instance.' + commands mysql: 'mysql' + + def self.mysql_running + system("mysql #{defaults_file} -NBe 'SELECT 1' >out 2>&1", out: '/dev/null') + end + + # Build a property_hash containing all the discovered information about MySQL + # servers. + def self.instances + instances = [] + if mysql_running + servers = mysql([defaults_file, '-NBe', + 'SELECT `hostname`, `port` FROM `proxysql_servers`'].compact).split(%r{\n}) + + # To reduce the number of calls to MySQL we collect all the properties in + # one big swoop. + servers.each do |line| + hostname, port = line.split(%r{\t}) + query = 'SELECT `hostname`, `port`, `weight`, `comment`' + query << ' FROM `proxysql_servers`' + query << " WHERE `hostname` = '#{hostname}' AND `port` = #{port}" + + @hostname, @port, @weight, @comment = mysql([defaults_file, '-NBe', query].compact).chomp.split(%r{\t}) + name = "#{hostname}:#{port}" + + instances << new( + name: name, + ensure: :present, + hostname: @hostname, + port: @port, + weight: @weight, + comment: @comment + ) + end + end + instances + end + + # We iterate over each proxy_mysql_server entry in the catalog and compare it against + # the contents of the property_hash generated by self.instances + def self.prefetch(resources) + servers = instances + resources.keys.each do |name| + provider = servers.find { |server| server.name == name } + resources[name].provider = provider if provider + end + end + + def create + _name = @resource[:name] + hostname = @resource.value(:hostname) + port = @resource.value(:port) || 6032 + weight = @resource.value(:weight) || 0 + comment = @resource.value(:comment) || '' + + query = 'INSERT INTO proxysql_servers (`hostname`, `port`, `weight`, `comment`)' + query << " VALUES ('#{hostname}', #{port}, #{weight}, '#{comment}')" + mysql([defaults_file, '-e', query].compact) + @property_hash[:ensure] = :present + + exists? ? (return true) : (return false) + end + + def destroy + hostname = @property_hash[:hostname] + port = @property_hash[:port] + query = 'DELETE FROM `proxysql_servers`' + query << " WHERE `hostname` = '#{hostname}' AND `port` = #{port}" + mysql([defaults_file, '-e', query].compact) + + @property_hash.clear + exists? ? (return false) : (return true) + end + + def exists? + @property_hash[:ensure] == :present || false + end + + def initialize(value = {}) + super(value) + @property_flush = {} + end + + def flush + update_server(@property_flush) if @property_flush + @property_hash.clear + + load_to_runtime = @resource[:load_to_runtime] + mysql([defaults_file, '-NBe', 'LOAD PROXYSQL SERVERS TO RUNTIME'].compact) if load_to_runtime == :true + + save_to_disk = @resource[:save_to_disk] + mysql([defaults_file, '-NBe', 'SAVE PROXYSQL SERVERS TO DISK'].compact) if save_to_disk == :true + end + + def update_server(properties) + hostname = @resource.value(:hostname) + port = @resource.value(:port) + + return false if properties.empty? + + values = [] + properties.each do |field, value| + values.push("`#{field}` = '#{value}'") + end + + query = 'UPDATE proxysql_servers SET ' + query << values.join(', ') + query << " WHERE `hostname` = '#{hostname}' AND `port` = #{port}" + mysql([defaults_file, '-e', query].compact) + + @property_hash.clear + exists? ? (return false) : (return true) + end + + # Generates method for all properties of the property_hash + mk_resource_methods + + def weight=(value) + @property_flush[:weight] = value + end + + def comment=(value) + @property_flush[:comment] = value + end +end diff --git a/lib/puppet/type/proxy_cluster.rb b/lib/puppet/type/proxy_cluster.rb new file mode 100644 index 00000000..660ab2fe --- /dev/null +++ b/lib/puppet/type/proxy_cluster.rb @@ -0,0 +1,53 @@ +# This has to be a separate type to enable collecting +Puppet::Type.newtype(:proxy_cluster) do + @doc = 'Manage a ProxySQL cluster.' + + ensurable + + autorequire(:file) { '/root/.my.cnf' } + autorequire(:class) { 'mysql::client' } + autorequire(:service) { 'proxysql' } + + validate do + raise('name parameter is required.') if (self[:ensure] == :present) && self[:name].nil? + raise('hostname parameter is required.') if (self[:ensure] == :present) && self[:hostname].nil? + raise('port parameter is required.') if (self[:ensure] == :present) && self[:port].nil? + end + + newparam(:name, namevar: true) do + desc 'name for cluster to manage.' + end + + newparam(:load_to_runtime) do + desc 'Load this entry to the active runtime.' + defaultto :true + newvalues(:true, :false) + end + + newparam(:save_to_disk) do + desc 'Perist this entry to the disk.' + defaultto :true + newvalues(:true, :false) + end + + newproperty(:hostname) do + desc 'The hostname of the server.' + newvalue(%r{\w+}) + end + + newproperty(:port) do + desc 'The port of the server.' + newvalue(%r{\d+}) + end + + newproperty(:weight) do + desc 'Currently unused, but in the roadmap for future enhancements.' + newvalue(%r{\d+}) + end + + newproperty(:comment) do + desc 'free form comment field.' + newvalue(%r{[\w+]}) + end + end + \ No newline at end of file diff --git a/manifests/cluster.pp b/manifests/cluster.pp new file mode 100644 index 00000000..d6afe5b5 --- /dev/null +++ b/manifests/cluster.pp @@ -0,0 +1,22 @@ +# == Class proxysql::cluster +# +# This class is called from proxysql for cluster config. +# +class proxysql::cluster { + + if $proxysql::cluster_name != '' { + resources { 'proxy_cluster': + purge => true, + } + + $query = "resources[parameters] {type = 'Class' and title = 'Proxysql' and parameters.cluster_name = '${proxysql::cluster_name}'}" + $nodes = puppetdb_query($query).map | $hash | { $hash['parameters']['node_name'] } + + $nodes.each |String $node| { + proxy_cluster { $node: + hostname => "${split($node, ':')[0]}", + port => split($node, ':')[1], + } + } + } +} diff --git a/manifests/init.pp b/manifests/init.pp index bb5b2e0a..477dfd0b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -101,7 +101,19 @@ # * `override_config_settings` # Which configuration variables should be overriden. Hash, defaults to {} (empty hash). # +# * `cluster_name` +# If set, proxysql_servers with the same cluster_name will be automatically added to the same cluster and will +# synchronize their configuration parameters. Defaults to '' +# +# * `cluster_username` +# The username ProxySQL will use to connect to the configured mysql_clusters +# Defaults to 'cluster' +# +# * `cluster_password` +# The password ProxySQL will use to connect to the configured mysql_clusters. Defaults to 'cluster' +# class proxysql ( + String $cluster_name = $proxysql::params::cluster_name, String $package_name = $proxysql::params::package_name, String $package_ensure = $proxysql::params::package_ensure, Array[String] $package_install_options = $proxysql::params::package_install_options, @@ -146,7 +158,11 @@ String $sys_owner = $proxysql::params::sys_owner, String $sys_group = $proxysql::params::sys_group, + String $cluster_username = $::proxysql::params::cluster_username, + Sensitive[String] $cluster_password = $::proxysql::params::cluster_password, + Hash $override_config_settings = {}, + String $node_name = "${::fqdn}:${admin_listen_port}" ) inherits ::proxysql::params { # lint:ignore:80chars @@ -162,7 +178,20 @@ monitor_password => $monitor_password.unwrap, }, } - $config_settings = deep_merge($proxysql::params::config_settings, $settings, $override_config_settings) + + if $cluster_name { + $settings_cluster = { + admin_variables => { + admin_credentials => "${admin_username}:${admin_password.unwrap};${cluster_username}:${cluster_password.unwrap}", + cluster_username => $cluster_username, + cluster_password => "${cluster_password.unwrap}", + }, + } + } + + $settings_result = deep_merge($settings, $settings_cluster) + + $config_settings = deep_merge($proxysql::params::config_settings, $settings_result, $override_config_settings) # lint:endignore anchor { '::proxysql::begin': } @@ -171,6 +200,7 @@ -> class { '::proxysql::config':} -> class { '::proxysql::service':} -> class { '::proxysql::admin_credentials':} + -> class { '::proxysql::cluster':} -> anchor { '::proxysql::end': } Class['::proxysql::install'] diff --git a/manifests/install.pp b/manifests/install.pp index 9f03bd5c..d3cf122e 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -44,6 +44,8 @@ } class { '::mysql::client': + package_name => 'mysql-client', + package_ensure => 'present', bindings_enable => false, } diff --git a/manifests/params.pp b/manifests/params.pp index 01fcae75..8ee68edb 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -128,6 +128,10 @@ $load_to_runtime = true $save_to_disk = true + $cluster_name = '' + $cluster_username = 'cluster' + $cluster_password = Sensitive('cluster') + $config_settings = { datadir => $datadir, admin_variables => { diff --git a/spec/classes/proxysql_spec.rb b/spec/classes/proxysql_spec.rb index 91b6994d..3695ccbc 100644 --- a/spec/classes/proxysql_spec.rb +++ b/spec/classes/proxysql_spec.rb @@ -13,14 +13,19 @@ it { is_expected.to compile.with_all_deps } it { is_expected.to contain_class('proxysql::params') } + it { is_expected.to contain_anchor('::proxysql::begin').that_comes_before('Class[proxysql::repo]') } it { is_expected.to contain_class('proxysql::repo').that_comes_before('Class[proxysql::install]') } it { is_expected.to contain_class('proxysql::install').that_comes_before('Class[proxysql::config]') } it { is_expected.to contain_class('proxysql::config').that_comes_before('Class[proxysql::service]') } - it { is_expected.to contain_class('proxysql::service').that_subscribes_to('Class[proxysql::install]') } + it { is_expected.to contain_class('proxysql::service').that_comes_before('Class[proxysql::admin_credentials]') } + it { is_expected.to contain_class('proxysql::admin_credentials').that_comes_before('Class[proxysql::cluster]') } + it { is_expected.to contain_class('proxysql::cluster').that_comes_before('Anchor[::proxysql::end]') } - it { is_expected.to contain_anchor('::proxysql::begin').that_comes_before('Class[proxysql::repo]') } + + it { is_expected.to contain_class('proxysql::service').that_subscribes_to('Class[proxysql::install]') } + it { is_expected.to contain_anchor('::proxysql::end') } - it { is_expected.to contain_class('proxysql::service').that_comes_before('Anchor[::proxysql::end]') } + it { is_expected.to contain_class('proxysql::install').that_notifies('Class[proxysql::service]') } From fd36377a967733fe7b6a716697d41b4abc332955 Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Thu, 23 Aug 2018 20:55:17 +0300 Subject: [PATCH 02/21] fix linting --- lib/puppet/type/proxy_cluster.rb | 101 +++++++++++++++---------------- spec/classes/proxysql_spec.rb | 4 +- 2 files changed, 51 insertions(+), 54 deletions(-) diff --git a/lib/puppet/type/proxy_cluster.rb b/lib/puppet/type/proxy_cluster.rb index 660ab2fe..eb1926d3 100644 --- a/lib/puppet/type/proxy_cluster.rb +++ b/lib/puppet/type/proxy_cluster.rb @@ -1,53 +1,52 @@ # This has to be a separate type to enable collecting Puppet::Type.newtype(:proxy_cluster) do - @doc = 'Manage a ProxySQL cluster.' - - ensurable - - autorequire(:file) { '/root/.my.cnf' } - autorequire(:class) { 'mysql::client' } - autorequire(:service) { 'proxysql' } - - validate do - raise('name parameter is required.') if (self[:ensure] == :present) && self[:name].nil? - raise('hostname parameter is required.') if (self[:ensure] == :present) && self[:hostname].nil? - raise('port parameter is required.') if (self[:ensure] == :present) && self[:port].nil? - end - - newparam(:name, namevar: true) do - desc 'name for cluster to manage.' - end - - newparam(:load_to_runtime) do - desc 'Load this entry to the active runtime.' - defaultto :true - newvalues(:true, :false) - end - - newparam(:save_to_disk) do - desc 'Perist this entry to the disk.' - defaultto :true - newvalues(:true, :false) - end - - newproperty(:hostname) do - desc 'The hostname of the server.' - newvalue(%r{\w+}) - end - - newproperty(:port) do - desc 'The port of the server.' - newvalue(%r{\d+}) - end - - newproperty(:weight) do - desc 'Currently unused, but in the roadmap for future enhancements.' - newvalue(%r{\d+}) - end - - newproperty(:comment) do - desc 'free form comment field.' - newvalue(%r{[\w+]}) - end - end - \ No newline at end of file + @doc = 'Manage a ProxySQL cluster.' + + ensurable + + autorequire(:file) { '/root/.my.cnf' } + autorequire(:class) { 'mysql::client' } + autorequire(:service) { 'proxysql' } + + validate do + raise('name parameter is required.') if (self[:ensure] == :present) && self[:name].nil? + raise('hostname parameter is required.') if (self[:ensure] == :present) && self[:hostname].nil? + raise('port parameter is required.') if (self[:ensure] == :present) && self[:port].nil? + end + + newparam(:name, namevar: true) do + desc 'name for cluster to manage.' + end + + newparam(:load_to_runtime) do + desc 'Load this entry to the active runtime.' + defaultto :true + newvalues(:true, :false) + end + + newparam(:save_to_disk) do + desc 'Perist this entry to the disk.' + defaultto :true + newvalues(:true, :false) + end + + newproperty(:hostname) do + desc 'The hostname of the server.' + newvalue(%r{\w+}) + end + + newproperty(:port) do + desc 'The port of the server.' + newvalue(%r{\d+}) + end + + newproperty(:weight) do + desc 'Currently unused, but in the roadmap for future enhancements.' + newvalue(%r{\d+}) + end + + newproperty(:comment) do + desc 'free form comment field.' + newvalue(%r{[\w+]}) + end +end diff --git a/spec/classes/proxysql_spec.rb b/spec/classes/proxysql_spec.rb index 3695ccbc..beacffe1 100644 --- a/spec/classes/proxysql_spec.rb +++ b/spec/classes/proxysql_spec.rb @@ -21,11 +21,9 @@ it { is_expected.to contain_class('proxysql::admin_credentials').that_comes_before('Class[proxysql::cluster]') } it { is_expected.to contain_class('proxysql::cluster').that_comes_before('Anchor[::proxysql::end]') } - it { is_expected.to contain_class('proxysql::service').that_subscribes_to('Class[proxysql::install]') } - + it { is_expected.to contain_anchor('::proxysql::end') } - it { is_expected.to contain_class('proxysql::install').that_notifies('Class[proxysql::service]') } From 7294712d3cd3e79a9bce6924cad12d094311f92c Mon Sep 17 00:00:00 2001 From: Maxim Fedotov Date: Fri, 24 Aug 2018 19:16:28 +0300 Subject: [PATCH 03/21] Update init.pp --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 477dfd0b..398aec05 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -162,7 +162,7 @@ Sensitive[String] $cluster_password = $::proxysql::params::cluster_password, Hash $override_config_settings = {}, - String $node_name = "${::fqdn}:${admin_listen_port}" + String $node_name = "${::fqdn}:${admin_listen_port}", ) inherits ::proxysql::params { # lint:ignore:80chars From 49d5fa6c50f96af4c00a3a54481438d317c39973 Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Sat, 25 Aug 2018 17:57:36 +0300 Subject: [PATCH 04/21] apply review notes. Remove cluster.pp --- README.markdown | 3 ++- manifests/cluster.pp | 22 ---------------------- manifests/init.pp | 12 +++++++++--- manifests/install.pp | 3 +-- manifests/params.pp | 1 + spec/classes/proxysql_spec.rb | 3 +-- 6 files changed, 14 insertions(+), 30 deletions(-) delete mode 100644 manifests/cluster.pp diff --git a/README.markdown b/README.markdown index d1913675..9ff4e81b 100644 --- a/README.markdown +++ b/README.markdown @@ -202,7 +202,8 @@ Defaults to 'cluster' ##### `cluster_password` The password ProxySQL will use to connect to the configured mysql_clusters. Defaults to 'cluster' - +##### `mysql_client_package_name` +The name of the mysql client package in your package manager. Defaults to '' ## Types #### proxy_global_variable diff --git a/manifests/cluster.pp b/manifests/cluster.pp deleted file mode 100644 index d6afe5b5..00000000 --- a/manifests/cluster.pp +++ /dev/null @@ -1,22 +0,0 @@ -# == Class proxysql::cluster -# -# This class is called from proxysql for cluster config. -# -class proxysql::cluster { - - if $proxysql::cluster_name != '' { - resources { 'proxy_cluster': - purge => true, - } - - $query = "resources[parameters] {type = 'Class' and title = 'Proxysql' and parameters.cluster_name = '${proxysql::cluster_name}'}" - $nodes = puppetdb_query($query).map | $hash | { $hash['parameters']['node_name'] } - - $nodes.each |String $node| { - proxy_cluster { $node: - hostname => "${split($node, ':')[0]}", - port => split($node, ':')[1], - } - } - } -} diff --git a/manifests/init.pp b/manifests/init.pp index 398aec05..70bd208c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -112,9 +112,13 @@ # * `cluster_password` # The password ProxySQL will use to connect to the configured mysql_clusters. Defaults to 'cluster' # +# * `mysql_client_package_name` +# The name of the mysql client package in your package manager. Defaults to '' +# class proxysql ( String $cluster_name = $proxysql::params::cluster_name, String $package_name = $proxysql::params::package_name, + String $mysql_client_package_name = $proxysql::params::mysql_client_package_name, String $package_ensure = $proxysql::params::package_ensure, Array[String] $package_install_options = $proxysql::params::package_install_options, String $service_name = $proxysql::params::service_name, @@ -162,6 +166,7 @@ Sensitive[String] $cluster_password = $::proxysql::params::cluster_password, Hash $override_config_settings = {}, + String $node_name = "${::fqdn}:${admin_listen_port}", ) inherits ::proxysql::params { @@ -179,7 +184,7 @@ }, } - if $cluster_name { + if $cluster_name != '' { $settings_cluster = { admin_variables => { admin_credentials => "${admin_username}:${admin_password.unwrap};${cluster_username}:${cluster_password.unwrap}", @@ -187,7 +192,9 @@ cluster_password => "${cluster_password.unwrap}", }, } - } + } else { + $settings_cluster = '' + } $settings_result = deep_merge($settings, $settings_cluster) @@ -200,7 +207,6 @@ -> class { '::proxysql::config':} -> class { '::proxysql::service':} -> class { '::proxysql::admin_credentials':} - -> class { '::proxysql::cluster':} -> anchor { '::proxysql::end': } Class['::proxysql::install'] diff --git a/manifests/install.pp b/manifests/install.pp index d3cf122e..1e73dbb2 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -44,8 +44,7 @@ } class { '::mysql::client': - package_name => 'mysql-client', - package_ensure => 'present', + package_name => $::proxysql::mysql_client_package_name, bindings_enable => false, } diff --git a/manifests/params.pp b/manifests/params.pp index 8ee68edb..055302fa 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -5,6 +5,7 @@ # class proxysql::params { $package_name = 'proxysql' + $mysql_client_package_name = '' $package_ensure = 'installed' $package_install_options = [] diff --git a/spec/classes/proxysql_spec.rb b/spec/classes/proxysql_spec.rb index beacffe1..e691b57e 100644 --- a/spec/classes/proxysql_spec.rb +++ b/spec/classes/proxysql_spec.rb @@ -18,8 +18,7 @@ it { is_expected.to contain_class('proxysql::install').that_comes_before('Class[proxysql::config]') } it { is_expected.to contain_class('proxysql::config').that_comes_before('Class[proxysql::service]') } it { is_expected.to contain_class('proxysql::service').that_comes_before('Class[proxysql::admin_credentials]') } - it { is_expected.to contain_class('proxysql::admin_credentials').that_comes_before('Class[proxysql::cluster]') } - it { is_expected.to contain_class('proxysql::cluster').that_comes_before('Anchor[::proxysql::end]') } + it { is_expected.to contain_class('proxysql::admin_credentials').that_comes_before('Anchor[::proxysql::end]') } it { is_expected.to contain_class('proxysql::service').that_subscribes_to('Class[proxysql::install]') } From a3f0e3829a1e9358ee62a015764099275b628a44 Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Mon, 27 Aug 2018 17:08:51 +0300 Subject: [PATCH 05/21] make cluster_name optional. Set default to undef --- README.markdown | 2 +- manifests/init.pp | 4 ++-- manifests/params.pp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index 9ff4e81b..8f1c765e 100644 --- a/README.markdown +++ b/README.markdown @@ -193,7 +193,7 @@ Which configuration variables should be overriden. Hash, defaults to `{}` (empty ##### `cluster_name` If set, proxysql_servers with the same cluster_name will be automatically added to the same cluster and will synchronize their configuration parameters. -Defaults to '' +Defaults to undef ##### `cluster_username` The username ProxySQL will use to connect to the configured mysql_clusters diff --git a/manifests/init.pp b/manifests/init.pp index 70bd208c..9bf740b8 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -103,7 +103,7 @@ # # * `cluster_name` # If set, proxysql_servers with the same cluster_name will be automatically added to the same cluster and will -# synchronize their configuration parameters. Defaults to '' +# synchronize their configuration parameters. Defaults to undef # # * `cluster_username` # The username ProxySQL will use to connect to the configured mysql_clusters @@ -116,7 +116,7 @@ # The name of the mysql client package in your package manager. Defaults to '' # class proxysql ( - String $cluster_name = $proxysql::params::cluster_name, + Optional[String] $cluster_name = $proxysql::params::cluster_name, String $package_name = $proxysql::params::package_name, String $mysql_client_package_name = $proxysql::params::mysql_client_package_name, String $package_ensure = $proxysql::params::package_ensure, diff --git a/manifests/params.pp b/manifests/params.pp index 055302fa..f20e07f9 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -129,7 +129,7 @@ $load_to_runtime = true $save_to_disk = true - $cluster_name = '' + $cluster_name = undef $cluster_username = 'cluster' $cluster_password = Sensitive('cluster') From 3dd15eb50cd22bd9763f18bf9347ab7b9484911b Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Mon, 27 Aug 2018 17:11:27 +0300 Subject: [PATCH 06/21] change if in init.pp --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 9bf740b8..9b861b95 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -184,7 +184,7 @@ }, } - if $cluster_name != '' { + if $cluster_name { $settings_cluster = { admin_variables => { admin_credentials => "${admin_username}:${admin_password.unwrap};${cluster_username}:${cluster_password.unwrap}", From cc64feaa195b73c72ff2ef4466e3a89b5b78c49e Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Tue, 28 Aug 2018 15:44:03 +0300 Subject: [PATCH 07/21] change mysql_client_package_name to optional undef --- README.markdown | 2 +- manifests/init.pp | 4 ++-- manifests/params.pp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index 8f1c765e..24e2b652 100644 --- a/README.markdown +++ b/README.markdown @@ -203,7 +203,7 @@ Defaults to 'cluster' The password ProxySQL will use to connect to the configured mysql_clusters. Defaults to 'cluster' ##### `mysql_client_package_name` -The name of the mysql client package in your package manager. Defaults to '' +The name of the mysql client package in your package manager. Defaults to undef ## Types #### proxy_global_variable diff --git a/manifests/init.pp b/manifests/init.pp index 9b861b95..01d458f4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -113,12 +113,12 @@ # The password ProxySQL will use to connect to the configured mysql_clusters. Defaults to 'cluster' # # * `mysql_client_package_name` -# The name of the mysql client package in your package manager. Defaults to '' +# The name of the mysql client package in your package manager. Defaults to undef # class proxysql ( Optional[String] $cluster_name = $proxysql::params::cluster_name, String $package_name = $proxysql::params::package_name, - String $mysql_client_package_name = $proxysql::params::mysql_client_package_name, + Optional[String] $mysql_client_package_name = $proxysql::params::mysql_client_package_name, String $package_ensure = $proxysql::params::package_ensure, Array[String] $package_install_options = $proxysql::params::package_install_options, String $service_name = $proxysql::params::service_name, diff --git a/manifests/params.pp b/manifests/params.pp index f20e07f9..5c650691 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -5,7 +5,7 @@ # class proxysql::params { $package_name = 'proxysql' - $mysql_client_package_name = '' + $mysql_client_package_name = undef $package_ensure = 'installed' $package_install_options = [] From 020aac45c37d0d3ce6a78a22679b2eca57606962 Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Fri, 31 Aug 2018 18:27:31 +0300 Subject: [PATCH 08/21] change :: to : after $ --- manifests/install.pp | 2 +- manifests/service.pp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index 1e73dbb2..2bc75e16 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -44,7 +44,7 @@ } class { '::mysql::client': - package_name => $::proxysql::mysql_client_package_name, + package_name => $proxysql::mysql_client_package_name, bindings_enable => false, } diff --git a/manifests/service.pp b/manifests/service.pp index 44197bda..0ae02080 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -34,8 +34,8 @@ } exec { 'wait_for_admin_socket_to_open': - command => "test -S ${::proxysql::admin_listen_socket}", - unless => "test -S ${::proxysql::admin_listen_socket}", + command => "test -S ${proxysql::admin_listen_socket}", + unless => "test -S ${proxysql::admin_listen_socket}", tries => '3', try_sleep => '10', require => Service[$proxysql::service_name], From 42aec0c1ddcda91afe73662b18d40f9d71b8d6ab Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Thu, 23 Aug 2018 20:36:27 +0300 Subject: [PATCH 09/21] add support for Proxysql cluster --- README.markdown | 10 ++++++++++ manifests/cluster.pp | 22 ++++++++++++++++++++++ manifests/init.pp | 15 +++++++++++++++ manifests/params.pp | 4 ++++ spec/classes/proxysql_spec.rb | 11 +++++++---- 5 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 manifests/cluster.pp diff --git a/README.markdown b/README.markdown index 24e2b652..349b56ef 100644 --- a/README.markdown +++ b/README.markdown @@ -204,6 +204,16 @@ The password ProxySQL will use to connect to the configured mysql_clusters. Defa ##### `mysql_client_package_name` The name of the mysql client package in your package manager. Defaults to undef +##### `cluster_name` +If set, proxysql_servers with the same cluster_name will be automatically added to the same cluster and will synchronize their configuration parameters. +Defaults to '' + +##### `cluster_username` +The username ProxySQL will use to connect to the configured mysql_clusters +Defaults to 'cluster' + +##### `cluster_password` +The password ProxySQL will use to connect to the configured mysql_clusters. Defaults to 'cluster' ## Types #### proxy_global_variable diff --git a/manifests/cluster.pp b/manifests/cluster.pp new file mode 100644 index 00000000..d6afe5b5 --- /dev/null +++ b/manifests/cluster.pp @@ -0,0 +1,22 @@ +# == Class proxysql::cluster +# +# This class is called from proxysql for cluster config. +# +class proxysql::cluster { + + if $proxysql::cluster_name != '' { + resources { 'proxy_cluster': + purge => true, + } + + $query = "resources[parameters] {type = 'Class' and title = 'Proxysql' and parameters.cluster_name = '${proxysql::cluster_name}'}" + $nodes = puppetdb_query($query).map | $hash | { $hash['parameters']['node_name'] } + + $nodes.each |String $node| { + proxy_cluster { $node: + hostname => "${split($node, ':')[0]}", + port => split($node, ':')[1], + } + } + } +} diff --git a/manifests/init.pp b/manifests/init.pp index 01d458f4..e3c22d05 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -115,6 +115,17 @@ # * `mysql_client_package_name` # The name of the mysql client package in your package manager. Defaults to undef # +# * `cluster_name` +# If set, proxysql_servers with the same cluster_name will be automatically added to the same cluster and will +# synchronize their configuration parameters. Defaults to '' +# +# * `cluster_username` +# The username ProxySQL will use to connect to the configured mysql_clusters +# Defaults to 'cluster' +# +# * `cluster_password` +# The password ProxySQL will use to connect to the configured mysql_clusters. Defaults to 'cluster' +# class proxysql ( Optional[String] $cluster_name = $proxysql::params::cluster_name, String $package_name = $proxysql::params::package_name, @@ -165,6 +176,9 @@ String $cluster_username = $::proxysql::params::cluster_username, Sensitive[String] $cluster_password = $::proxysql::params::cluster_password, + String $cluster_username = $::proxysql::params::cluster_username, + Sensitive[String] $cluster_password = $::proxysql::params::cluster_password, + Hash $override_config_settings = {}, String $node_name = "${::fqdn}:${admin_listen_port}", @@ -207,6 +221,7 @@ -> class { '::proxysql::config':} -> class { '::proxysql::service':} -> class { '::proxysql::admin_credentials':} + -> class { '::proxysql::cluster':} -> anchor { '::proxysql::end': } Class['::proxysql::install'] diff --git a/manifests/params.pp b/manifests/params.pp index 5c650691..2ffa34f8 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -133,6 +133,10 @@ $cluster_username = 'cluster' $cluster_password = Sensitive('cluster') + $cluster_name = '' + $cluster_username = 'cluster' + $cluster_password = Sensitive('cluster') + $config_settings = { datadir => $datadir, admin_variables => { diff --git a/spec/classes/proxysql_spec.rb b/spec/classes/proxysql_spec.rb index e691b57e..2da597ae 100644 --- a/spec/classes/proxysql_spec.rb +++ b/spec/classes/proxysql_spec.rb @@ -13,16 +13,19 @@ it { is_expected.to compile.with_all_deps } it { is_expected.to contain_class('proxysql::params') } - it { is_expected.to contain_anchor('::proxysql::begin').that_comes_before('Class[proxysql::repo]') } + it { is_expected.to contain_anchor('proxysql::begin').that_comes_before('Class[proxysql::repo]') } it { is_expected.to contain_class('proxysql::repo').that_comes_before('Class[proxysql::install]') } it { is_expected.to contain_class('proxysql::install').that_comes_before('Class[proxysql::config]') } it { is_expected.to contain_class('proxysql::config').that_comes_before('Class[proxysql::service]') } it { is_expected.to contain_class('proxysql::service').that_comes_before('Class[proxysql::admin_credentials]') } - it { is_expected.to contain_class('proxysql::admin_credentials').that_comes_before('Anchor[::proxysql::end]') } + it { is_expected.to contain_class('proxysql::admin_credentials').that_comes_before('Class[proxysql::cluster]') } + it { is_expected.to contain_class('proxysql::cluster').that_comes_before('Anchor[proxysql::end]') } - it { is_expected.to contain_class('proxysql::service').that_subscribes_to('Class[proxysql::install]') } - it { is_expected.to contain_anchor('::proxysql::end') } + it { is_expected.to contain_class('proxysql::service').that_subscribes_to('Class[proxysql::install]') } + + it { is_expected.to contain_anchor('proxysql::end') } + it { is_expected.to contain_class('proxysql::install').that_notifies('Class[proxysql::service]') } From 4cb1146b174625063bacfbf69155f320b44b4b5f Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Thu, 23 Aug 2018 20:55:17 +0300 Subject: [PATCH 10/21] fix linting --- spec/classes/proxysql_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/classes/proxysql_spec.rb b/spec/classes/proxysql_spec.rb index 2da597ae..bce668ba 100644 --- a/spec/classes/proxysql_spec.rb +++ b/spec/classes/proxysql_spec.rb @@ -21,7 +21,6 @@ it { is_expected.to contain_class('proxysql::admin_credentials').that_comes_before('Class[proxysql::cluster]') } it { is_expected.to contain_class('proxysql::cluster').that_comes_before('Anchor[proxysql::end]') } - it { is_expected.to contain_class('proxysql::service').that_subscribes_to('Class[proxysql::install]') } it { is_expected.to contain_anchor('proxysql::end') } From bcced73b2f7224b36f14ded0fbfff2203294a88a Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Fri, 24 Aug 2018 19:16:28 +0300 Subject: [PATCH 11/21] Update init.pp --- manifests/init.pp | 1 - 1 file changed, 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index e3c22d05..f17f23fb 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -180,7 +180,6 @@ Sensitive[String] $cluster_password = $::proxysql::params::cluster_password, Hash $override_config_settings = {}, - String $node_name = "${::fqdn}:${admin_listen_port}", ) inherits ::proxysql::params { From ec5438d25ed99d25d410d24c9eb0d6f4e08ed1af Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Sat, 25 Aug 2018 17:57:36 +0300 Subject: [PATCH 12/21] apply review notes. Remove cluster.pp --- README.markdown | 3 +++ manifests/cluster.pp | 22 ---------------------- manifests/init.pp | 7 +++++-- spec/classes/proxysql_spec.rb | 3 +-- 4 files changed, 9 insertions(+), 26 deletions(-) delete mode 100644 manifests/cluster.pp diff --git a/README.markdown b/README.markdown index 349b56ef..4901c53e 100644 --- a/README.markdown +++ b/README.markdown @@ -215,6 +215,9 @@ Defaults to 'cluster' ##### `cluster_password` The password ProxySQL will use to connect to the configured mysql_clusters. Defaults to 'cluster' +##### `mysql_client_package_name` +The name of the mysql client package in your package manager. Defaults to undef + ## Types #### proxy_global_variable `proxy_global_variable` manages a variable in the ProxySQL `global_variables` admin table. diff --git a/manifests/cluster.pp b/manifests/cluster.pp deleted file mode 100644 index d6afe5b5..00000000 --- a/manifests/cluster.pp +++ /dev/null @@ -1,22 +0,0 @@ -# == Class proxysql::cluster -# -# This class is called from proxysql for cluster config. -# -class proxysql::cluster { - - if $proxysql::cluster_name != '' { - resources { 'proxy_cluster': - purge => true, - } - - $query = "resources[parameters] {type = 'Class' and title = 'Proxysql' and parameters.cluster_name = '${proxysql::cluster_name}'}" - $nodes = puppetdb_query($query).map | $hash | { $hash['parameters']['node_name'] } - - $nodes.each |String $node| { - proxy_cluster { $node: - hostname => "${split($node, ':')[0]}", - port => split($node, ':')[1], - } - } - } -} diff --git a/manifests/init.pp b/manifests/init.pp index f17f23fb..cb11b933 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -126,6 +126,9 @@ # * `cluster_password` # The password ProxySQL will use to connect to the configured mysql_clusters. Defaults to 'cluster' # +# * `mysql_client_package_name` +# The name of the mysql client package in your package manager. Defaults to '' +# class proxysql ( Optional[String] $cluster_name = $proxysql::params::cluster_name, String $package_name = $proxysql::params::package_name, @@ -180,6 +183,7 @@ Sensitive[String] $cluster_password = $::proxysql::params::cluster_password, Hash $override_config_settings = {}, + String $node_name = "${::fqdn}:${admin_listen_port}", ) inherits ::proxysql::params { @@ -197,7 +201,7 @@ }, } - if $cluster_name { + if $cluster_name != '' { $settings_cluster = { admin_variables => { admin_credentials => "${admin_username}:${admin_password.unwrap};${cluster_username}:${cluster_password.unwrap}", @@ -220,7 +224,6 @@ -> class { '::proxysql::config':} -> class { '::proxysql::service':} -> class { '::proxysql::admin_credentials':} - -> class { '::proxysql::cluster':} -> anchor { '::proxysql::end': } Class['::proxysql::install'] diff --git a/spec/classes/proxysql_spec.rb b/spec/classes/proxysql_spec.rb index bce668ba..3b9f8d1a 100644 --- a/spec/classes/proxysql_spec.rb +++ b/spec/classes/proxysql_spec.rb @@ -18,8 +18,7 @@ it { is_expected.to contain_class('proxysql::install').that_comes_before('Class[proxysql::config]') } it { is_expected.to contain_class('proxysql::config').that_comes_before('Class[proxysql::service]') } it { is_expected.to contain_class('proxysql::service').that_comes_before('Class[proxysql::admin_credentials]') } - it { is_expected.to contain_class('proxysql::admin_credentials').that_comes_before('Class[proxysql::cluster]') } - it { is_expected.to contain_class('proxysql::cluster').that_comes_before('Anchor[proxysql::end]') } + it { is_expected.to contain_class('proxysql::admin_credentials').that_comes_before('Anchor[proxysql::end]') } it { is_expected.to contain_class('proxysql::service').that_subscribes_to('Class[proxysql::install]') } From 253d32d2e3ba23d2b3d16b63fa4b5b89e5864c96 Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Mon, 27 Aug 2018 17:08:51 +0300 Subject: [PATCH 13/21] make cluster_name optional. Set default to undef --- README.markdown | 2 +- manifests/init.pp | 2 +- manifests/params.pp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 4901c53e..56a9e914 100644 --- a/README.markdown +++ b/README.markdown @@ -206,7 +206,7 @@ The password ProxySQL will use to connect to the configured mysql_clusters. Defa The name of the mysql client package in your package manager. Defaults to undef ##### `cluster_name` If set, proxysql_servers with the same cluster_name will be automatically added to the same cluster and will synchronize their configuration parameters. -Defaults to '' +Defaults to undef ##### `cluster_username` The username ProxySQL will use to connect to the configured mysql_clusters diff --git a/manifests/init.pp b/manifests/init.pp index cb11b933..773d4bec 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -117,7 +117,7 @@ # # * `cluster_name` # If set, proxysql_servers with the same cluster_name will be automatically added to the same cluster and will -# synchronize their configuration parameters. Defaults to '' +# synchronize their configuration parameters. Defaults to undef # # * `cluster_username` # The username ProxySQL will use to connect to the configured mysql_clusters diff --git a/manifests/params.pp b/manifests/params.pp index 2ffa34f8..d9408104 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -133,7 +133,7 @@ $cluster_username = 'cluster' $cluster_password = Sensitive('cluster') - $cluster_name = '' + $cluster_name = undef $cluster_username = 'cluster' $cluster_password = Sensitive('cluster') From c11a5d1c16799a2a4e657e3cc4d0a0b7866afe4a Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Mon, 27 Aug 2018 17:11:27 +0300 Subject: [PATCH 14/21] change if in init.pp --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 773d4bec..5a0db276 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -201,7 +201,7 @@ }, } - if $cluster_name != '' { + if $cluster_name { $settings_cluster = { admin_variables => { admin_credentials => "${admin_username}:${admin_password.unwrap};${cluster_username}:${cluster_password.unwrap}", From 7f6b545f97eda10730ed2691b6d3a4f82fe1b411 Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Tue, 28 Aug 2018 15:44:03 +0300 Subject: [PATCH 15/21] change mysql_client_package_name to optional undef --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 5a0db276..749d05b4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -127,7 +127,7 @@ # The password ProxySQL will use to connect to the configured mysql_clusters. Defaults to 'cluster' # # * `mysql_client_package_name` -# The name of the mysql client package in your package manager. Defaults to '' +# The name of the mysql client package in your package manager. Defaults to undef # class proxysql ( Optional[String] $cluster_name = $proxysql::params::cluster_name, From 640cb400b537891fc9f82600f2dd2cd574a50ab5 Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Sat, 1 Sep 2018 02:04:21 +0300 Subject: [PATCH 16/21] change to undef --- manifests/init.pp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 749d05b4..b5755492 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -167,6 +167,7 @@ Boolean $manage_repo = true, Hash $repo = $proxysql::params::repo, +<<<<<<< HEAD String $package_source = $proxysql::params::package_source, String $package_checksum_value = $proxysql::params::package_checksum_value, String $package_checksum_type = $proxysql::params::package_checksum_type, @@ -178,9 +179,21 @@ String $cluster_username = $::proxysql::params::cluster_username, Sensitive[String] $cluster_password = $::proxysql::params::cluster_password, +======= + String $package_source = $:proxysql::params::package_source, + String $package_provider = $:proxysql::params::package_provider, - String $cluster_username = $::proxysql::params::cluster_username, - Sensitive[String] $cluster_password = $::proxysql::params::cluster_password, + String $sys_owner = $:proxysql::params::sys_owner, + String $sys_group = $:proxysql::params::sys_group, + + String $rpm_repo_name = $:proxysql::params::rpm_repo_name, + String $rpm_repo_descr = $:proxysql::params::rpm_repo_descr, + String $rpm_repo = $:proxysql::params::rpm_repo, + String $rpm_repo_key = $:proxysql::params::rpm_repo_key, +>>>>>>> change to undef + + String $cluster_username = $:proxysql::params::cluster_username, + Sensitive[String] $cluster_password = $:proxysql::params::cluster_password, Hash $override_config_settings = {}, @@ -210,7 +223,7 @@ }, } } else { - $settings_cluster = '' + $settings_cluster = undef } $settings_result = deep_merge($settings, $settings_cluster) From eb3db8af150f197ea38e8a412120fbc675e9b4ea Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Sat, 1 Sep 2018 02:10:16 +0300 Subject: [PATCH 17/21] replace $:: to $ --- manifests/init.pp | 42 +++++++++++++----------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index b5755492..c8ef3637 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -167,7 +167,6 @@ Boolean $manage_repo = true, Hash $repo = $proxysql::params::repo, -<<<<<<< HEAD String $package_source = $proxysql::params::package_source, String $package_checksum_value = $proxysql::params::package_checksum_value, String $package_checksum_type = $proxysql::params::package_checksum_type, @@ -177,23 +176,8 @@ String $sys_owner = $proxysql::params::sys_owner, String $sys_group = $proxysql::params::sys_group, - String $cluster_username = $::proxysql::params::cluster_username, - Sensitive[String] $cluster_password = $::proxysql::params::cluster_password, -======= - String $package_source = $:proxysql::params::package_source, - String $package_provider = $:proxysql::params::package_provider, - - String $sys_owner = $:proxysql::params::sys_owner, - String $sys_group = $:proxysql::params::sys_group, - - String $rpm_repo_name = $:proxysql::params::rpm_repo_name, - String $rpm_repo_descr = $:proxysql::params::rpm_repo_descr, - String $rpm_repo = $:proxysql::params::rpm_repo, - String $rpm_repo_key = $:proxysql::params::rpm_repo_key, ->>>>>>> change to undef - - String $cluster_username = $:proxysql::params::cluster_username, - Sensitive[String] $cluster_password = $:proxysql::params::cluster_password, + String $cluster_username = $proxysql::params::cluster_username, + Sensitive[String] $cluster_password = $proxysql::params::cluster_password, Hash $override_config_settings = {}, @@ -231,20 +215,20 @@ $config_settings = deep_merge($proxysql::params::config_settings, $settings_result, $override_config_settings) # lint:endignore - anchor { '::proxysql::begin': } - -> class { '::proxysql::repo':} - -> class { '::proxysql::install':} - -> class { '::proxysql::config':} - -> class { '::proxysql::service':} - -> class { '::proxysql::admin_credentials':} - -> anchor { '::proxysql::end': } + anchor { 'proxysql::begin': } + -> class { 'proxysql::repo':} + -> class { 'proxysql::install':} + -> class { 'proxysql::config':} + -> class { 'proxysql::service':} + -> class { 'proxysql::admin_credentials':} + -> anchor { 'proxysql::end': } - Class['::proxysql::install'] - ~> Class['::proxysql::service'] + Class['proxysql::install'] + ~> Class['proxysql::service'] if $restart { - Class['::proxysql::config'] - ~> Class['::proxysql::service'] + Class['proxysql::config'] + ~> Class['proxysql::service'] } } From 03727d39368b4f1a66c256eddbbcd0abb6181665 Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Sat, 1 Sep 2018 03:35:56 +0300 Subject: [PATCH 18/21] update syntax for facts --- manifests/init.pp | 2 +- manifests/params.pp | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index c8ef3637..8c645fdd 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -181,7 +181,7 @@ Hash $override_config_settings = {}, - String $node_name = "${::fqdn}:${admin_listen_port}", + String $node_name = "${facts['fqdn']}:${admin_listen_port}", ) inherits ::proxysql::params { # lint:ignore:80chars diff --git a/manifests/params.pp b/manifests/params.pp index d9408104..bbe1fcd3 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -112,7 +112,6 @@ } } - $monitor_username = 'monitor' $monitor_password = Sensitive('monitor') @@ -133,10 +132,6 @@ $cluster_username = 'cluster' $cluster_password = Sensitive('cluster') - $cluster_name = undef - $cluster_username = 'cluster' - $cluster_password = Sensitive('cluster') - $config_settings = { datadir => $datadir, admin_variables => { From 31de90e8055524b5a45ec6432bc87fb25adfd352 Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Mon, 3 Sep 2018 14:32:47 +0300 Subject: [PATCH 19/21] fix README --- README.markdown | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/README.markdown b/README.markdown index 56a9e914..24e2b652 100644 --- a/README.markdown +++ b/README.markdown @@ -202,19 +202,6 @@ Defaults to 'cluster' ##### `cluster_password` The password ProxySQL will use to connect to the configured mysql_clusters. Defaults to 'cluster' -##### `mysql_client_package_name` -The name of the mysql client package in your package manager. Defaults to undef -##### `cluster_name` -If set, proxysql_servers with the same cluster_name will be automatically added to the same cluster and will synchronize their configuration parameters. -Defaults to undef - -##### `cluster_username` -The username ProxySQL will use to connect to the configured mysql_clusters -Defaults to 'cluster' - -##### `cluster_password` -The password ProxySQL will use to connect to the configured mysql_clusters. Defaults to 'cluster' - ##### `mysql_client_package_name` The name of the mysql client package in your package manager. Defaults to undef From 2325208e5d5a4a4be6af6e38234c0b3112473eb2 Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Mon, 3 Sep 2018 15:28:40 +0300 Subject: [PATCH 20/21] fix linting --- spec/classes/proxysql_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/classes/proxysql_spec.rb b/spec/classes/proxysql_spec.rb index 3b9f8d1a..3461d821 100644 --- a/spec/classes/proxysql_spec.rb +++ b/spec/classes/proxysql_spec.rb @@ -21,9 +21,9 @@ it { is_expected.to contain_class('proxysql::admin_credentials').that_comes_before('Anchor[proxysql::end]') } it { is_expected.to contain_class('proxysql::service').that_subscribes_to('Class[proxysql::install]') } - + it { is_expected.to contain_anchor('proxysql::end') } - + it { is_expected.to contain_class('proxysql::install').that_notifies('Class[proxysql::service]') } From 1a9ff67b9bd18a61784f0a95b2ca070e2cb188ac Mon Sep 17 00:00:00 2001 From: Maksim Fedotov Date: Mon, 3 Sep 2018 15:34:44 +0300 Subject: [PATCH 21/21] fix linting --- spec/classes/proxysql_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/classes/proxysql_spec.rb b/spec/classes/proxysql_spec.rb index 3461d821..d0acff44 100644 --- a/spec/classes/proxysql_spec.rb +++ b/spec/classes/proxysql_spec.rb @@ -24,7 +24,6 @@ it { is_expected.to contain_anchor('proxysql::end') } - it { is_expected.to contain_class('proxysql::install').that_notifies('Class[proxysql::service]') } it { is_expected.to contain_class('mysql::client').with(bindings_enable: false) }