From 91df464517029b368dbe27922b5fea7a3f097941 Mon Sep 17 00:00:00 2001 From: Matthias Crauwels Date: Mon, 20 Mar 2017 15:05:48 +0100 Subject: [PATCH 01/14] fixed permissions for Ubuntu (#20) --- manifests/params.pp | 8 +++++++- spec/classes/proxysql_spec.rb | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) 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/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' } From c33c895e97e0987e0f41ed171d1c7aa02e132fff Mon Sep 17 00:00:00 2001 From: Matthias Crauwels Date: Mon, 20 Mar 2017 15:06:28 +0100 Subject: [PATCH 02/14] made example code functional using the percona repos (#20) --- README.markdown | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 8205b5e7..95549ecb 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', + } }, }, } From e79c0f921e96007e997df84c96dbcfd214ac1216 Mon Sep 17 00:00:00 2001 From: Matthias Crauwels Date: Mon, 20 Mar 2017 15:31:20 +0100 Subject: [PATCH 03/14] use the admin socket to connect when it is configured... otherwise you may fall back to the host+port --- templates/my.cnf.erb | 3 +++ 1 file changed, 3 insertions(+) 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') %> From df45445b8dd87e8f9eca4a33720d61fd9633b056 Mon Sep 17 00:00:00 2001 From: Matthias Crauwels Date: Mon, 20 Mar 2017 15:32:17 +0100 Subject: [PATCH 04/14] fixed ordering so the configfiles are always set before we tried to start the daemon (#20) --- manifests/service.pp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/manifests/service.pp b/manifests/service.pp index 1d157a26..86e7a3fd 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 = [] + } + 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, } } From a047c11cfae754cfc1401e44e6c570c8dbd1d9f7 Mon Sep 17 00:00:00 2001 From: Matthias Crauwels Date: Mon, 20 Mar 2017 20:22:10 +0100 Subject: [PATCH 05/14] fixed review comments --- manifests/service.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/service.pp b/manifests/service.pp index 86e7a3fd..41141aec 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -9,10 +9,10 @@ if $::proxysql::manage_mycnf_file { $service_require = [ File['proxysql-config-file'], File['root-mycnf-file'] ] } else { - $service_require = [ File['proxysql-config-file'] ] + $service_require = File['proxysql-config-file'] } } else { - $service_require = [] + $service_require = undef } if $::proxysql::restart { From c5e640962bbf288cadbbb272ff28bfcda69825e0 Mon Sep 17 00:00:00 2001 From: Matthias Crauwels Date: Tue, 21 Mar 2017 14:05:42 +0100 Subject: [PATCH 06/14] fix #22, when changing admin variables a restart is required for the module to be functional. --- manifests/config.pp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/manifests/config.pp b/manifests/config.pp index 0ed3466d..2bb18bd7 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, From 0c9fb003c7793f19974c683420f11c193b9b80d8 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 15 Apr 2017 16:57:57 +0200 Subject: [PATCH 07/14] modulesync 0.21.0 --- .github/CONTRIBUTING.md | 4 +++ .msync.yml | 2 +- .overcommit.yml | 63 +++++++++++++++++++++++++++++++++++++++++ .rubocop.yml | 2 ++ .travis.yml | 17 +++++++---- Gemfile | 16 +++++------ 6 files changed, 89 insertions(+), 15 deletions(-) create mode 100644 .overcommit.yml diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 5574191a..602f324b 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -98,3 +98,7 @@ If you don't want to have to recreate the virtual machine every time you can use `BEAKER_DESTROY=no` and `BEAKER_PROVISION=no`. On the first run you will at least need `BEAKER_PROVISION` set to yes (the default). The Vagrantfile for the created virtual machines will be in `.vagrant/beaker_vagrant_fies`. + +The easiest way to debug in a docker container is to open a shell: + + docker exec -it -u root ${container_id_or_name} bash diff --git a/.msync.yml b/.msync.yml index a8e6a4ee..540f0cea 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '0.20.1' +modulesync_config_version: '0.21.0' diff --git a/.overcommit.yml b/.overcommit.yml new file mode 100644 index 00000000..31699e74 --- /dev/null +++ b/.overcommit.yml @@ -0,0 +1,63 @@ +# Managed by https://github.com/voxpupuli/modulesync_configs +# +# Hooks are only enabled if you take action. +# +# To enable the hooks run: +# +# ``` +# bundle exec overcommit --install +# # ensure .overcommit.yml does not harm to you and then +# bundle exec overcommit --sign +# ``` +# +# (it will manage the .git/hooks directory): +# +# Examples howto skip a test for a commit or push: +# +# ``` +# SKIP=RuboCop git commit +# SKIP=PuppetLint git commit +# SKIP=RakeTask git push +# ``` +# +# Don't invoke overcommit at all: +# +# ``` +# OVERCOMMIT_DISABLE=1 git commit +# ``` +# +# Read more about overcommit: https://github.com/brigade/overcommit +# +# To manage this config yourself in your module add +# +# ``` +# .overcommit.yml: +# unmanaged: true +# ``` +# +# to your modules .sync.yml config +--- +PreCommit: + RuboCop: + enabled: true + description: 'Runs rubocop on modified files only' + command: ['bundle', 'exec', 'rubocop'] + PuppetLint: + enabled: true + description: 'Runs puppet-lint on modified files only' + command: ['bundle', 'exec', 'puppet-lint'] + YamlSyntax: + enabled: true + JsonSyntax: + enabled: true + TrailingWhitespace: + enabled: true + +PrePush: + RakeTarget: + enabled: true + description: 'Run rake targets' + targets: + - 'test' + - 'rubocop' + command: [ 'bundle', 'exec', 'rake' ] diff --git a/.rubocop.yml b/.rubocop.yml index ef85ceb4..4e113f03 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -9,6 +9,8 @@ AllCops: - .vendor/**/* - pkg/**/* - spec/fixtures/**/* + - Gemfile + - Rakefile Lint/ConditionPosition: Enabled: True diff --git a/.travis.yml b/.travis.yml index 176f9c04..388d169f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ sudo: false dist: trusty language: ruby cache: bundler -bundler_args: --without system_tests development before_install: - bundle -v - rm Gemfile.lock || true @@ -17,16 +16,22 @@ matrix: fast_finish: true include: - rvm: 2.1.9 + bundler_args: --without system_tests development env: PUPPET_VERSION="~> 4.0" CHECK=test - - rvm: 2.2.6 + - rvm: 2.2.7 + bundler_args: --without system_tests development env: PUPPET_VERSION="~> 4.0" CHECK=test - - rvm: 2.3.3 + - rvm: 2.3.4 + bundler_args: --without system_tests development env: PUPPET_VERSION="~> 4.0" CHECK=test - - rvm: 2.4.0 + - rvm: 2.4.1 + bundler_args: --without system_tests development env: PUPPET_VERSION="~> 4.0" CHECK=test - - rvm: 2.4.0 + - rvm: 2.4.1 + bundler_args: --without system_tests development env: PUPPET_VERSION="~> 4.0" CHECK=rubocop - - rvm: 2.4.0 + - rvm: 2.4.1 + bundler_args: --without system_tests development env: PUPPET_VERSION="~> 4.0" CHECK=build DEPLOY_TO_FORGE=yes branches: only: diff --git a/Gemfile b/Gemfile index 2270de7d..d35336cb 100644 --- a/Gemfile +++ b/Gemfile @@ -11,8 +11,7 @@ def location_for(place, fake_version = nil) end group :test do - gem 'puppetlabs_spec_helper', '~> 2.0.1', :require => false - gem 'parallel_tests', :require => false + gem 'puppetlabs_spec_helper', '~> 2.1.1', :require => false gem 'rspec-puppet', '~> 2.5', :require => false gem 'rspec-puppet-facts', :require => false gem 'rspec-puppet-utils', :require => false @@ -26,10 +25,10 @@ group :test do gem 'metadata-json-lint', :require => false gem 'puppet-blacksmith', :require => false gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem.git' - gem 'puppet-strings', '~> 1.0.0', :require => false + gem 'puppet-strings', '~> 1.0', :require => false gem 'redcarpet', :require => false - gem 'rubocop', '~> 0.47.0', :require => false if RUBY_VERSION >= '2.3.0' - gem 'rubocop-rspec', '~> 1.10.0', :require => false if RUBY_VERSION >= '2.3.0' + gem 'rubocop', '~> 0.48.0', :require => false if RUBY_VERSION >= '2.3.0' + gem 'rubocop-rspec', '~> 1.15.0', :require => false if RUBY_VERSION >= '2.3.0' gem 'mocha', '>= 1.2.1', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false @@ -39,9 +38,10 @@ group :test do end group :development do - gem 'travis', :require => false - gem 'travis-lint', :require => false - gem 'guard-rake', :require => false + gem 'travis', :require => false + gem 'travis-lint', :require => false + gem 'guard-rake', :require => false + gem 'overcommit', '~> 0.39.1', :require => false end group :system_tests do From 5dc5261c92f76ac8529c7c75d6b8be6d8de97542 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 15 Apr 2017 16:58:13 +0200 Subject: [PATCH 08/14] rubocop: autofixes --- Guardfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Guardfile b/Guardfile index fd50602a..d007cdcf 100644 --- a/Guardfile +++ b/Guardfile @@ -1,5 +1,5 @@ notification :off -guard 'rake', :task => 'test' do +guard 'rake', task: 'test' do watch(%r{^manifests\/(.+)\.pp$}) end From 597abb503815bef4f27b54a424f0b7544b74582e Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 15 Apr 2017 16:58:14 +0200 Subject: [PATCH 09/14] puppet-lint: autofixes --- manifests/init.pp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 7f9118f9..285c0291 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -178,19 +178,19 @@ $config_settings = deep_merge($proxysql::params::config_settings, $override_config_settings, $settings) # lint:endignore - anchor { '::proxysql::begin': } -> - class { '::proxysql::repo':} -> - class { '::proxysql::install':} -> - class { '::proxysql::config':} -> - class { '::proxysql::service':} -> - anchor { '::proxysql::end': } + anchor { '::proxysql::begin': } + -> class { '::proxysql::repo':} + -> class { '::proxysql::install':} + -> class { '::proxysql::config':} + -> class { '::proxysql::service':} + -> 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 460b936783ec5d135d1180bad25224c4acc16857 Mon Sep 17 00:00:00 2001 From: juniorsysadmin Date: Sun, 16 Apr 2017 17:46:08 +1000 Subject: [PATCH 10/14] Rubocop fixes: Ignore Guardfile --- .rubocop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop.yml b/.rubocop.yml index 4e113f03..6c9347f9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -11,6 +11,7 @@ AllCops: - spec/fixtures/**/* - Gemfile - Rakefile + - Guardfile Lint/ConditionPosition: Enabled: True From 9445344d6720b04001b8d517f2dc896d8897ef27 Mon Sep 17 00:00:00 2001 From: Matthias Crauwels Date: Wed, 24 May 2017 17:57:30 +0200 Subject: [PATCH 11/14] fix #25 do not force a default... --- lib/puppet/provider/proxy_mysql_server/proxysql.rb | 2 +- lib/puppet/type/proxy_mysql_server.rb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) 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..d30ece52 100644 --- a/lib/puppet/type/proxy_mysql_server.rb +++ b/lib/puppet/type/proxy_mysql_server.rb @@ -51,7 +51,6 @@ newproperty(:status) do desc 'Server status.' - defaultto :ONLINE newvalues(:ONLINE, :SHUNNED, :OFFLINE_SOFT, :OFFLINE_HARD) end From ec78dfd6a305823b3d8d72c6589be3a8a0e640cc Mon Sep 17 00:00:00 2001 From: Matthias Crauwels Date: Wed, 24 May 2017 17:58:26 +0200 Subject: [PATCH 12/14] we don't only use rpm... --- manifests/init.pp | 4 ---- manifests/install.pp | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) 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, From 680169d4903610a349161ae000880671f96e63d6 Mon Sep 17 00:00:00 2001 From: Matthias Crauwels Date: Wed, 24 May 2017 18:00:13 +0200 Subject: [PATCH 13/14] fix #28, default weight should be 1 --- README.markdown | 2 +- lib/puppet/type/proxy_mysql_server.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 95549ecb..74d128ff 100644 --- a/README.markdown +++ b/README.markdown @@ -295,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/type/proxy_mysql_server.rb b/lib/puppet/type/proxy_mysql_server.rb index d30ece52..c7be5d0f 100644 --- a/lib/puppet/type/proxy_mysql_server.rb +++ b/lib/puppet/type/proxy_mysql_server.rb @@ -56,7 +56,7 @@ 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 From b50fa0e3babc12347e33acc7f6b820cdf2acd520 Mon Sep 17 00:00:00 2001 From: Matthias Crauwels Date: Wed, 24 May 2017 18:14:44 +0200 Subject: [PATCH 14/14] removed references to manage_rpm --- README.markdown | 2 +- manifests/repo.pp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 74d128ff..2dd86f5c 100644 --- a/README.markdown +++ b/README.markdown @@ -65,7 +65,7 @@ class { '::proxysql': listen_port => 3306, admin_password => '654321', monitor_password => '123456', - manage_rpm => true, + manage_repo => true, } ``` 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)