diff --git a/README.markdown b/README.markdown index 70467670..b0643193 100644 --- a/README.markdown +++ b/README.markdown @@ -33,7 +33,7 @@ The module requires Puppet 5.5.8 and above. It also depends on: * [puppetlabs/mysql](https://forge.puppet.com/puppetlabs/mysql) * [puppetlabs/apt](https://forge.puppet.com/puppetlabs/apt) - (Not strictly required on non Debian based systems) * [puppetlabs/stdlib](https://forge.puppet.com/puppetlabs/stdlib) -* [camptocamp/systemd](https://forge.puppet.com/camptocamp/systemd) - (Not strictly required if installing ProxySQL 1.4) +* [camptocamp/systemd](https://forge.puppet.com/camptocamp/systemd) For up to date details on external dependencies, please see the [metadata.json](https://github.com/voxpupuli/puppet-proxysql/blob/master/metadata.json) or for released versions, the [puppet forge page](https://forge.puppet.com/puppet/proxysql/dependencies). @@ -48,18 +48,9 @@ include proxysql ``` By default, packages come from the official upstream package repositories which the module will configure. -On new installations, (by default), the 2.0.x repository will be configured. If ProxySQL is already installed, then the repository matching the currently installed version +On new installations, (by default), the 2.7.x repository will be configured. If ProxySQL is already installed, then the repository matching the currently installed version will be used. -To force the use of 1.4.x packages, use the `version` parameter. (Note, the example below does not force the installation of `1.4.16`, it only ensures the correct repository -is configured and that ProxySQL will be configured as if the version installed is `1.4.16`) - -```puppet -class { 'proxysql': - version => '1.4.16', -} -``` - To use your Operating System's own packages set `manage_repo => false`. ```puppet diff --git a/REFERENCE.md b/REFERENCE.md index 7b94d2a2..0a98a31a 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -388,7 +388,7 @@ Data type: `Pattern[/^[1|2]\.\d+\.\d+/]` 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. +deployed, use `package_name` or `package_source`. Currently defaults to '2.7.1' or the value of the `proxysql_version` fact. Default value: `$proxysql::params::version` diff --git a/manifests/init.pp b/manifests/init.pp index d73e493f..b87a935d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -73,7 +73,7 @@ # @param 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. +# deployed, use `package_name` or `package_source`. Currently defaults to '2.7.1' or the value of the `proxysql_version` fact. # @param package_source # 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. diff --git a/manifests/params.pp b/manifests/params.pp index b5501edf..9fd917db 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -9,68 +9,68 @@ $package_provider = 'dpkg' $package_dependencies = [] - if versioncmp(fact('os.release.major'), '18.04') >= 0 { + if versioncmp(fact('os.release.major'), '18.04') == 0 { # The 2.0.x systemd service file in ubuntu 18.04 has `ReadWritePaths=/var/lib/proxysql /var/run/proxysql`. # This limits where we can write sockets. $_listen_socket = "${datadir}/proxysql.sock" $_admin_listen_socket = "${datadir}/proxysql_admin.sock" } - $repo14 = { - comment => 'ProxySQL 1.4.x APT repository', - location => "http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/${facts['os']['distro']['codename']}/", + $repo22 = { + comment => 'ProxySQL 2.2.x APT repository', + location => "http://repo.proxysql.com/ProxySQL/proxysql-2.2.x/${facts['os']['distro']['codename']}/", release => './', - repos => '', + repos => ' ', key => { 'id' => '1448BF693CA600C799EB935804A562FB79953B49', 'server' => 'keyserver.ubuntu.com', }, } - $repo20 = { - comment => 'ProxySQL 2.0.x APT repository', - location => "http://repo.proxysql.com/ProxySQL/proxysql-2.0.x/${facts['os']['distro']['codename']}/", + $repo23 = { + comment => 'ProxySQL 2.3.x APT repository', + location => "http://repo.proxysql.com/ProxySQL/proxysql-2.3.x/${facts['os']['distro']['codename']}/", release => './', - repos => '', + repos => ' ', key => { 'id' => '1448BF693CA600C799EB935804A562FB79953B49', 'server' => 'keyserver.ubuntu.com', }, } - $repo21 = { - comment => 'ProxySQL 2.1.x APT repository', - location => "http://repo.proxysql.com/ProxySQL/proxysql-2.1.x/${facts['os']['distro']['codename']}/", + $repo24 = { + comment => 'ProxySQL 2.4.x APT repository', + location => "http://repo.proxysql.com/ProxySQL/proxysql-2.4.x/${facts['os']['distro']['codename']}/", release => './', - repos => '', + repos => ' ', key => { - 'id' => '1448BF693CA600C799EB935804A562FB79953B49', + 'id' => '653F85BB38256DF8A96206C3E8CA2E8D8217C97E', 'server' => 'keyserver.ubuntu.com', }, } - $repo22 = { - comment => 'ProxySQL 2.2.x APT repository', - location => "http://repo.proxysql.com/ProxySQL/proxysql-2.2.x/${facts['os']['distro']['codename']}/", + $repo25 = { + comment => 'ProxySQL 2.5.x APT repository', + location => "http://repo.proxysql.com/ProxySQL/proxysql-2.5.x/${facts['os']['distro']['codename']}/", release => './', - repos => '', + repos => ' ', key => { - 'id' => '1448BF693CA600C799EB935804A562FB79953B49', + 'id' => '653F85BB38256DF8A96206C3E8CA2E8D8217C97E', 'server' => 'keyserver.ubuntu.com', }, } - $repo23 = { - comment => 'ProxySQL 2.3.x APT repository', - location => "http://repo.proxysql.com/ProxySQL/proxysql-2.3.x/${facts['os']['distro']['codename']}/", + $repo26 = { + comment => 'ProxySQL 2.6.x APT repository', + location => "http://repo.proxysql.com/ProxySQL/proxysql-2.6.x/${facts['os']['distro']['codename']}/", release => './', - repos => '', + repos => ' ', key => { - 'id' => '1448BF693CA600C799EB935804A562FB79953B49', + 'id' => '653F85BB38256DF8A96206C3E8CA2E8D8217C97E', 'server' => 'keyserver.ubuntu.com', }, } - $repo24 = { - comment => 'ProxySQL 2.4.x APT repository', - location => "http://repo.proxysql.com/ProxySQL/proxysql-2.4.x/${facts['os']['distro']['codename']}/", + $repo27 = { + comment => 'ProxySQL 2.7.x APT repository', + location => "http://repo.proxysql.com/ProxySQL/proxysql-2.7.x/${facts['os']['distro']['codename']}/", release => './', - repos => '', + repos => ' ', key => { 'id' => '653F85BB38256DF8A96206C3E8CA2E8D8217C97E', 'server' => 'keyserver.ubuntu.com', @@ -84,30 +84,6 @@ '2016' => '6', default => $facts['os']['release']['major'], } - $repo14 = { - name => 'proxysql_1_4', - descr => 'ProxySQL 1.4.x YUM repository', - baseurl => "http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/centos/${repo_os_major_version}", - enabled => true, - gpgcheck => true, - gpgkey => 'http://repo.proxysql.com/ProxySQL/repo_pub_key', - } - $repo20 = { - name => 'proxysql_2_0', - descr => 'ProxySQL 2.0.x YUM repository', - baseurl => "http://repo.proxysql.com/ProxySQL/proxysql-2.0.x/centos/${repo_os_major_version}", - enabled => true, - gpgcheck => true, - gpgkey => 'http://repo.proxysql.com/ProxySQL/repo_pub_key', - } - $repo21 = { - name => 'proxysql_2_1', - descr => 'ProxySQL 2.1.x YUM repository', - baseurl => "http://repo.proxysql.com/ProxySQL/proxysql-2.1.x/centos/${repo_os_major_version}", - enabled => true, - gpgcheck => true, - gpgkey => 'http://repo.proxysql.com/ProxySQL/repo_pub_key', - } $repo22 = { name => 'proxysql_2_2', descr => 'ProxySQL 2.2.x YUM repository', @@ -132,6 +108,30 @@ gpgcheck => true, gpgkey => 'http://repo.proxysql.com/ProxySQL/repo_pub_key', } + $repo25 = { + name => 'proxysql_2_5', + descr => 'ProxySQL 2.5.x YUM repository', + baseurl => "http://repo.proxysql.com/ProxySQL/proxysql-2.5.x/centos/${repo_os_major_version}", + enabled => true, + gpgcheck => true, + gpgkey => 'http://repo.proxysql.com/ProxySQL/repo_pub_key', + } + $repo26 = { + name => 'proxysql_2_6', + descr => 'ProxySQL 2.6.x YUM repository', + baseurl => "http://repo.proxysql.com/ProxySQL/proxysql-2.6.x/centos/${repo_os_major_version}", + enabled => true, + gpgcheck => true, + gpgkey => 'http://repo.proxysql.com/ProxySQL/repo_pub_key', + } + $repo27 = { + name => 'proxysql_2_7', + descr => 'ProxySQL 2.7.x YUM repository', + baseurl => "http://repo.proxysql.com/ProxySQL/proxysql-2.7.x/centos/${repo_os_major_version}", + enabled => true, + gpgcheck => true, + gpgkey => 'http://repo.proxysql.com/ProxySQL/repo_pub_key', + } } default: { fail("osfamily ${facts['os']['family']} is not supported") @@ -143,7 +143,7 @@ } else { $short_proxysql_version_fact = undef } - $version = pick($short_proxysql_version_fact,'2.0.7') + $version = pick($short_proxysql_version_fact,'2.7.1') $listen_socket = pick(getvar('_listen_socket'),'/tmp/proxysql.sock') $admin_listen_socket = pick(getvar('_admin_listen_socket'),'/tmp/proxysql_admin.sock') diff --git a/manifests/repo.pp b/manifests/repo.pp index 9c0eda96..9906d1f7 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -6,12 +6,12 @@ if $proxysql::manage_repo and !$proxysql::package_source { $repo = $proxysql::version ? { + /^2\.7\./ => $proxysql::params::repo27, + /^2\.6\./ => $proxysql::params::repo26, + /^2\.5\./ => $proxysql::params::repo25, /^2\.4\./ => $proxysql::params::repo24, /^2\.3\./ => $proxysql::params::repo23, /^2\.2\./ => $proxysql::params::repo22, - /^2\.1\./ => $proxysql::params::repo21, - /^2\.0\./ => $proxysql::params::repo20, - /^1\.4\./ => $proxysql::params::repo14, default => fail("Unsupported `proxysql::version` ${proxysql::version}") } case $facts['os']['family'] { @@ -27,28 +27,28 @@ } # Purge old/unnecessary repos. - if ($proxysql::version !~ /^2\.3\./) { - yumrepo { $proxysql::params::repo23['name']: + if ($proxysql::version !~ /^2\.6\./) { + yumrepo { $proxysql::params::repo26['name']: ensure => absent, } } - if ($proxysql::version !~ /^2\.2\./) { - yumrepo { $proxysql::params::repo22['name']: + if ($proxysql::version !~ /^2\.5\./) { + yumrepo { $proxysql::params::repo25['name']: ensure => absent, } } - if ($proxysql::version !~ /^2\.1\./) { - yumrepo { $proxysql::params::repo21['name']: + if ($proxysql::version !~ /^2\.4\./) { + yumrepo { $proxysql::params::repo24['name']: ensure => absent, } } - if ($proxysql::version !~ /^2\.0\./) { - yumrepo { $proxysql::params::repo20['name']: + if ($proxysql::version !~ /^2\.3\./) { + yumrepo { $proxysql::params::repo23['name']: ensure => absent, } } - if ($proxysql::version !~ /^1\.4\./) { - yumrepo { $proxysql::params::repo14['name']: + if ($proxysql::version !~ /^2\.2\./) { + yumrepo { $proxysql::params::repo22['name']: ensure => absent, } } diff --git a/manifests/service.pp b/manifests/service.pp index 81c870c6..89ced667 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -19,8 +19,10 @@ notify => Service[$proxysql::service_name], } service { $proxysql::service_name: - ensure => $proxysql::service_ensure, - enable => true, + ensure => $proxysql::service_ensure, + enable => true, + hasrestart => true, + hasstatus => true, } } else { if $proxysql::restart { diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index c578893a..b3f8c14f 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -3,43 +3,12 @@ require 'spec_helper_acceptance' describe 'proxysql class' do - unless ['18.04', '20.04'].include?(fact('os.release.major')) || - (fact('os.name') == 'Debian' && fact('os.release.major') == '10') # There are no proxysql 1.4 packages for these OSes - context 'version 1.4' do - it 'works idempotently with no errors' do - pp = <<-EOS - class { 'proxysql': - version => '1.4.16', - } - EOS - - # Run it twice and test for idempotency - apply_manifest(pp, catch_failures: true) - apply_manifest(pp, catch_changes: true) - end - - describe package('proxysql') do - it { is_expected.to be_installed } - end - - describe service('proxysql') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } - end - - describe command('proxysql --version') do - its(:exit_status) { is_expected.to eq 0 } - its(:stderr) { is_expected.to match %r{^ProxySQL version 1\.4\.} } - end - end - end - - context 'Upgrading to version 2.0' do + context 'Upgrading to version 2.7' do it 'works idempotently with no errors' do pp = <<-EOS class { 'proxysql': package_ensure => latest, - version => '2.0.7', + version => '2.7.1', } EOS @@ -48,7 +17,7 @@ class { 'proxysql': apply_manifest(pp, catch_changes: true) # Run it again, this time relying on proxysql_version fact - apply_manifest('class { \'proxysql\':}', catch_changes: true) + apply_manifest("class { 'proxysql':}", catch_changes: true) end describe package('proxysql') do @@ -62,7 +31,7 @@ class { 'proxysql': describe command('proxysql --version') do its(:exit_status) { is_expected.to eq 0 } - its(:stdout) { is_expected.to match %r{^ProxySQL version 2\.0\.} } + its(:stdout) { is_expected.to match %r{^ProxySQL version 2\.7\.} } end end @@ -71,18 +40,6 @@ class { 'proxysql': it 'works idempotently with no errors' do pp = <<-EOS class { 'proxysql': - listen_port => 3306, - admin_username => 'admin', - admin_password => Sensitive('654321'), - stats_username => 'stats', - stats_password => Sensitive('567890'), - monitor_username => 'monitor', - monitor_password => Sensitive('123456'), - override_config_settings => { - mysql_variables => { - 'monitor_writer_is_also_reader' => false, - } - }, } proxy_mysql_replication_hostgroup { '10-20': @@ -353,18 +310,6 @@ class { 'proxysql': pp = <<-EOS class { 'proxysql': restart => true, - listen_port => 3306, - admin_username => 'admin', - admin_password => Sensitive('654321'), - stats_username => 'stats', - stats_password => Sensitive('567890'), - monitor_username => 'monitor', - monitor_password => Sensitive('123456'), - override_config_settings => { - mysql_variables => { - 'monitor_writer_is_also_reader' => true, - } - }, } EOS apply_manifest(pp, catch_failures: true) diff --git a/spec/classes/proxysql_spec.rb b/spec/classes/proxysql_spec.rb index 5cdd9ba4..ed0ef0e7 100644 --- a/spec/classes/proxysql_spec.rb +++ b/spec/classes/proxysql_spec.rb @@ -33,13 +33,13 @@ it { is_expected.to contain_class('mysql::client').with(bindings_enable: false) } if facts[:osfamily] == 'RedHat' - if facts[:operatingsystem] == 'Amazon' && facts[:operatingsystemmajrelease] == '2016' - it { is_expected.to contain_yumrepo('proxysql_2_0').with_baseurl('http://repo.proxysql.com/ProxySQL/proxysql-2.0.x/centos/6') } - else - it { is_expected.to contain_yumrepo('proxysql_2_0').with_baseurl("http://repo.proxysql.com/ProxySQL/proxysql-2.0.x/centos/#{facts[:operatingsystemmajrelease]}") } - end + it { is_expected.to contain_yumrepo('proxysql_2_7').with_baseurl("http://repo.proxysql.com/ProxySQL/proxysql-2.7.x/centos/#{facts[:operatingsystemmajrelease]}") } it { is_expected.to contain_yumrepo('proxysql_repo').with_ensure('absent') } - it { is_expected.to contain_yumrepo('proxysql_1_4').with_ensure('absent') } + it { is_expected.to contain_yumrepo('proxysql_2_6').with_ensure('absent') } + it { is_expected.to contain_yumrepo('proxysql_2_5').with_ensure('absent') } + it { is_expected.to contain_yumrepo('proxysql_2_4').with_ensure('absent') } + it { is_expected.to contain_yumrepo('proxysql_2_3').with_ensure('absent') } + it { is_expected.to contain_yumrepo('proxysql_2_2').with_ensure('absent') } end it do @@ -87,14 +87,8 @@ if facts[:osfamily] == 'RedHat' context 'with restart = true' do - context 'and proxysql 1.4.16' do - let(:params) { { 'restart' => true, 'version' => '1.4.16' } } - - it { is_expected.to contain_service('proxysql').with_start('/usr/bin/proxysql --reload') } - end - - context 'and proxysql 2.0.6' do - let(:params) { { 'restart' => true, 'version' => '2.0.6' } } + context 'and proxysql 2.7.1' do + let(:params) { { 'restart' => true, 'version' => '2.7.1' } } it { is_expected.to contain_service('proxysql').with_start('/etc/init.d/proxysql reload') } end