diff --git a/README.markdown b/README.markdown index 8205b5e7..2dd86f5c 100644 --- a/README.markdown +++ b/README.markdown @@ -47,9 +47,13 @@ You can customize options such as (but not limited to) `listen_port`, `admin_pas override_config_settings => $override_settings, repo => { 'debs_proxysql_repo' => { - comment => 'ProxySQL repo', - location => 'http://debs.example.tld/debian', - repos => 'proxsql', + comment => 'Percona repo', + location => 'http://repo.percona.com/apt', + repos => 'main', + key => { + 'id' => '4D1BB29D63D98E422B2113B19334A25F8507EFA5', + 'server' => 'keyserver.ubuntu.com', + } }, }, } @@ -61,7 +65,7 @@ class { '::proxysql': listen_port => 3306, admin_password => '654321', monitor_password => '123456', - manage_rpm => true, + manage_repo => true, } ``` @@ -291,7 +295,7 @@ Port of the server. Required. Defaults to 3306. 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. +Weight value of the server. The higher the value, the higher the probability this server will be chosen from the hostgroup. Integer, defaults to 1. ##### `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. diff --git a/lib/puppet/provider/proxy_mysql_server/proxysql.rb b/lib/puppet/provider/proxy_mysql_server/proxysql.rb index f464e1e3..0778016c 100644 --- a/lib/puppet/provider/proxy_mysql_server/proxysql.rb +++ b/lib/puppet/provider/proxy_mysql_server/proxysql.rb @@ -58,7 +58,7 @@ def create hostname = @resource.value(:hostname) port = @resource.value(:port) || 3306 hostgroup_id = @resource.value(:hostgroup_id) || 0 - status = @resource.value(:status) || 'ONLINE' + status = @resource.value(:status) weight = @resource.value(:weight) || 1 compression = @resource.value(:compression) || 0 max_connections = @resource.value(:max_connections) || 1000 diff --git a/lib/puppet/type/proxy_mysql_server.rb b/lib/puppet/type/proxy_mysql_server.rb index 90abd28a..c7be5d0f 100644 --- a/lib/puppet/type/proxy_mysql_server.rb +++ b/lib/puppet/type/proxy_mysql_server.rb @@ -51,13 +51,12 @@ newproperty(:status) do desc 'Server status.' - defaultto :ONLINE newvalues(:ONLINE, :SHUNNED, :OFFLINE_SOFT, :OFFLINE_HARD) end newproperty(:weight) do desc 'the bigger the weight of a server relative to other weights, the higher the probability of the server to be chosen from a hostgroup' - defaultto 0 + defaultto 1 newvalue(%r{\d+}) end diff --git a/manifests/config.pp b/manifests/config.pp index 6e3a6326..adeb4650 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -17,6 +17,20 @@ } } + proxy_global_variable { 'admin-admin_credentials': + value => $config_settings['admin_variables']['admin_credentials'], + load_to_runtime => false, + notify => Service[$::proxysql::service_name], + before => File['root-mycnf-file'], + } + + proxy_global_variable { 'admin-mysql_ifaces': + value => $config_settings['admin_variables']['mysql_ifaces'], + load_to_runtime => false, + notify => Service[$::proxysql::service_name], + before => File['root-mycnf-file'], + } + if $proxysql::manage_mycnf_file { file { 'root-mycnf-file': ensure => file, diff --git a/manifests/init.pp b/manifests/init.pp index 285c0291..ebd38838 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -81,9 +81,6 @@ # 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_rpm` -# Determines wheter this module will use local provider instead of the repo to install ProxySQL, defaults to false, -# # * `package_source` # location ot the proxysql package for the `package_provider`. Default to 'https://www.percona.com/redir/downloads/proxysql/proxysql-1.3.2/binary/redhat/6/x86_64/proxysql-1.3.2-1.1.x86_64.rpm' # @@ -145,7 +142,6 @@ Boolean $save_to_disk = $::proxysql::params::save_to_disk, Boolean $manage_repo = true, - Boolean $manage_rpm = false, Hash $repo = {}, String $package_source = $::proxysql::params::package_source, diff --git a/manifests/install.pp b/manifests/install.pp index 3e1519d0..fbe691ed 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -4,7 +4,7 @@ # class proxysql::install { - if $::proxysql::manage_rpm { + if !$::proxysql::manage_repo { package { $::proxysql::package_name: ensure => $::proxysql::package_ensure, source => $::proxysql::package_source, diff --git a/manifests/params.pp b/manifests/params.pp index 480ae663..9a49c65b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -24,12 +24,18 @@ $admin_listen_port = 6032 case $::operatingsystem { - 'Debian', 'Ubuntu': { + 'Debian': { $admin_listen_socket = '/tmp/proxysql_admin.sock' $package_provider = 'dpkg' $sys_owner = 'root' $sys_group = 'root' } + 'Ubuntu': { + $admin_listen_socket = '/tmp/proxysql_admin.sock' + $package_provider = 'dpkg' + $sys_owner = 'proxysql' + $sys_group = 'proxysql' + } 'CentOS', 'Fedora', 'Scientific', 'RedHat', 'Amazon', 'OracleLinux': { $admin_listen_socket = '/tmp/proxysql_admin.sock' $package_provider = 'rpm' diff --git a/manifests/repo.pp b/manifests/repo.pp index 1f423b84..561d487b 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -4,7 +4,7 @@ # Manage the repos where the ProxySQL package might be # class proxysql::repo inherits proxysql { - if ($::proxysql::manage_repo == true) and ($::proxysql::manage_rpm == false) { + if $::proxysql::manage_repo == true { case $::operatingsystem { 'Debian', 'Ubuntu': { create_resources('::apt::source', $::proxysql::repo) diff --git a/manifests/service.pp b/manifests/service.pp index 1d157a26..41141aec 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -5,6 +5,16 @@ # class proxysql::service { + if $::proxysql::manage_config_file { + if $::proxysql::manage_mycnf_file { + $service_require = [ File['proxysql-config-file'], File['root-mycnf-file'] ] + } else { + $service_require = File['proxysql-config-file'] + } + } else { + $service_require = undef + } + if $::proxysql::restart { service { $::proxysql::service_name: ensure => $::proxysql::service_ensure, @@ -15,6 +25,7 @@ status => '/etc/init.d/proxysql status', start => '/usr/bin/proxysql --reload', stop => '/etc/init.d/proxysql stop', + require => $service_require, } } else { service { $::proxysql::service_name: @@ -22,6 +33,7 @@ enable => true, hasstatus => true, hasrestart => true, + require => $service_require, } } diff --git a/spec/classes/proxysql_spec.rb b/spec/classes/proxysql_spec.rb index 077a84cc..b88f499c 100644 --- a/spec/classes/proxysql_spec.rb +++ b/spec/classes/proxysql_spec.rb @@ -32,9 +32,12 @@ end case facts[:operatingsystem] - when 'Debian', 'Ubuntu' then + when 'Debian' then let(:sys_user) { 'root' } let(:sys_group) { 'root' } + when 'Ubuntu' then + let(:sys_user) { 'proxysql' } + let(:sys_group) { 'proxysql' } when 'CentOS', 'Fedora', 'Scientific', 'RedHat', 'Amazon', 'OracleLinux' then let(:sys_user) { 'proxysql' } let(:sys_group) { 'proxysql' } diff --git a/templates/my.cnf.erb b/templates/my.cnf.erb index 262a3ebb..933b7eec 100644 --- a/templates/my.cnf.erb +++ b/templates/my.cnf.erb @@ -2,8 +2,11 @@ prompt = 'Admin> ' [client] +<% if scope.lookupvar('::proxysql::admin_listen_socket') != '' -%> socket = <%= scope.lookupvar('::proxysql::admin_listen_socket') %> +<% else -%> host = <%= scope.lookupvar('::proxysql::admin_listen_ip') %> port = <%= scope.lookupvar('::proxysql::admin_listen_port') %> +<% end -%> user = <%= scope.lookupvar('::proxysql::admin_username') %> password = <%= scope.lookupvar('::proxysql::admin_password') %>