Skip to content

Commit

Permalink
start removing support for old proxysql versions < 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
saz committed Oct 23, 2024
1 parent d54689d commit 0b08fb3
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 121 deletions.
13 changes: 2 additions & 11 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
92 changes: 46 additions & 46 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,59 +16,59 @@
$_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 => ' ',
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 => ' ',
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 => ' ',
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 => ' ',
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 => ' ',
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 => ' ',
key => {
Expand All @@ -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',
Expand All @@ -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")
Expand All @@ -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')
Expand Down
26 changes: 13 additions & 13 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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'] {
Expand All @@ -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,
}
}
Expand Down
39 changes: 4 additions & 35 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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

Expand Down
22 changes: 8 additions & 14 deletions spec/classes/proxysql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0b08fb3

Please sign in to comment.