Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't install from github when manage_repo is false and remove unused repo parameter #112

Merged
merged 3 commits into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 37 additions & 12 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,37 @@ To install the ProxySQL software with all the default options:
include proxysql
```

By default, packages come from the official upstream package repositories which the module will configure.
Most operating systems currently default to 1.4.x packages, but this can be changed with the `repo_version` parameter.

To use your Operating System's own packages set `manage_repo => false`.
```puppet
class { 'proxysql':
manage_repo => false,
}
```

or you can configure your own repository by eg. declaring your own `yumrepo`, `pulp_rpmbind` or `rhn_channel` resource and setting `manage_repo => false`.

For example, using `pulp` and [katello/pulp](https://forge.puppet.com/katello/pulp)
```puppet
pulp_rpmbind { 'my_proxysql_repo':}

class { 'proxysql':
manage_repo => false,
require => Pulp_rpmbind['my_proxysql_repo'],
}
```

Alternatively, you can specify a `package_source` and associated options. This mimics the old, (pre version 4), behaviour of this module.
```puppet
class { 'proxysql':
package_source => 'https://github.com/sysown/proxysql/releases/download/v1.4.11/proxysql_1.4.11-debian9_amd64.deb',
package_checksum_value => '65a3c2b98eefa42946ee59eef18ba18534c2a39d',
package_checksum_type => 'sha1',
}
```

You can customize options such as (but not limited to) `listen_port`, `admin_password`, `monitor_password`, ...
```puppet
class { 'proxysql':
Expand Down Expand Up @@ -266,7 +297,6 @@ You can override any configuration setting by using the `override_config_setting
* `proxysql::prerequisites`: Manages the user / group to own the proxysql files
* `proxysql::reload_config`: Reloads admin and mysql variables if you enable the `manage_config_file` option
* `proxysql::repo`: Manages the repo's where ProxySQL might be in.
* `proxysql::repo_version`: Specifies the repo. Possible values are '1.4.x' and '2.0.x'.
* `proxysql::service`: Manages the service

### parameters
Expand Down Expand Up @@ -342,21 +372,15 @@ Specifies whether the managed ProxySQL resources should be immediately save to d
##### `manage_repo`
Determines whether this module will manage the repositories where ProxySQL might be. Defaults to 'true'

##### `repo`
These are the repo's we will configure. Currently only Debian is supported. This hash will be passed on to `apt::source` or `yumrepo` (depending on the OS family).
Defaults to the official upstream repo for your OS. See http://repo.proxysql.com for more info.

#### `repo_version`
Specifies the repo version. Possible values are '1.4.x' and '2.0.x'. String, efaults to '1.4.x'.

Specifies the repo version. Possible values are '1.4.x' and '2.0.x'. String, defaults to '1.4.x' ('2.0.x' for Ubuntu 18.04).

##### `package_source`
location ot the proxysql package for the `package_provider`.
- Default to 'https://github.com/sysown/proxysql/releases/download/v1.4.7/proxysql-1.4.7-1-centos7.x86_64.rpm' for RedHat based systems
- Default to 'https://github.com/sysown/proxysql/releases/download/v1.4.7/proxysql_1.4.7-ubuntu16_amd64.deb' for Debian based systems
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.

##### `package_provider`
provider for package-resource. defaults to `dpkg` for debian-based, `rpm` for redhat base or `undef` for others
provider for `package_source`. Defaults to `dpkg` for debian-based, and `rpm` for redhat systems.

##### `sys_owner`
owner of the datadir and config_file, defaults to 'root'
Expand Down Expand Up @@ -778,11 +802,12 @@ Optional comment.

## Limitations

The module requires Puppet 4.10.0 or above.
The module requires Puppet 5.5 or above.

## Development

This module is originally developed by [Matthias Crauwels](mailto:[email protected]) for use at [Ghent University, Belgium](http://www.ugent.be). This module is published under the Apache 2.0 license.
It is now maintained by [Vox Pupuli](https://voxpupuli.org)

We are open to feature requests, bug reports, contributions, etc...

Expand Down
31 changes: 15 additions & 16 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,21 @@
# * `manage_repo`
# Determines whether this module will manage the repositories where ProxySQL might be. Defaults to 'true'
#
# * `repo`
# These are the repo's we will configure. Currently only Debian is supported. This hash will be passed on
# to `apt::source` or `yumrepo` (depending on the OS family).
# Defaults to the official upstream repo for your OS. See http://repo.proxysql.com for more info.
#
# * `repo_version`
# Specifies the repo version of ProxySQL to be configured. Defaults to '1.4.x' ('2.0.x' for Ubuntu 18.04).
#
# * `package_source`
# location ot the proxysql package for the `package_provider`.
# Default to 'https://github.com/sysown/proxysql/releases/download/v1.4.7/proxysql-1.4.7-1-centos7.x86_64.rpm' for RedHat based systems
# Default to 'https://github.com/sysown/proxysql/releases/download/v1.4.7/proxysql_1.4.7-ubuntu16_amd64.deb' for Debian based systems
# 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.
#
# * `package_provider`
# provider for package-resource. defaults to `dpkg` for debian-based, `rpm` for redhat base or undef for others
# provider for `package_source`. defaults to `dpkg` for debian-based, and `rpm` for redhat systems.
#
# * `package_checksum_value`
# The checksum of the package. Optional and only applicable when `package_source` is provided.
#
# * `package_checksum_type`
# The 'type' of `package_checksum_value`. Optional and only applicable when `package_checksum_value` is provided.
#
# * `sys_owner`
# owner of the datadir and config_file, defaults to root.
Expand Down Expand Up @@ -192,14 +192,13 @@
Boolean $save_to_disk = $proxysql::params::save_to_disk,

Boolean $manage_repo = true,
Hash $repo = $proxysql::params::repo14,
Enum['2.0.x','1.4.x'] $repo_version = $proxysql::params::repo_version,

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,
Array $package_dependencies = $proxysql::params::package_dependencies,
String $package_provider= $proxysql::params::package_provider,
Optional[String[1]] $package_source = undef,
Optional[String[1]] $package_checksum_value = undef,
Optional[String[1]] $package_checksum_type = undef,
Array[String[1]] $package_dependencies = $proxysql::params::package_dependencies,
Enum['dpkg','rpm'] $package_provider = $proxysql::params::package_provider,

String $sys_owner = $proxysql::params::sys_owner,
String $sys_group = $proxysql::params::sys_group,
Expand All @@ -218,7 +217,7 @@
Optional[Proxysql::GaleraHostgroup] $mysql_galera_hostgroups = undef,
Optional[Proxysql::Rule] $mysql_rules = undef,
Optional[Proxysql::Scheduler] $schedulers = undef,
) inherits ::proxysql::params {
) inherits proxysql::params {

# lint:ignore:80chars
$settings = {
Expand Down
17 changes: 7 additions & 10 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,7 @@
#
class proxysql::install {

if $proxysql::manage_repo {
if $facts['os']['family'] == 'Debian' {
Class['apt::update'] -> Package[$proxysql::package_name]
}

package { $proxysql::package_name:
ensure => $proxysql::package_ensure,
install_options => $proxysql::package_install_options,
}
} else {
if $proxysql::package_source {
case $facts['os']['family'] {
'Debian': {
$real_package_source = '/root/proxysql-package.deb'
Expand All @@ -38,6 +29,12 @@
provider => $proxysql::package_provider,
install_options => $proxysql::package_install_options,
}
} else {
# Install from a repo
package { $proxysql::package_name:
ensure => $proxysql::package_ensure,
install_options => $proxysql::package_install_options,
}
}

file { 'proxysql-datadir':
Expand Down
77 changes: 13 additions & 64 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,67 +26,19 @@
case $facts['os']['family'] {
'Debian': {
$package_provider = 'dpkg'
case $facts['os']['name'] {
'Debian': {
case $facts['os']['release']['major'] {
'8': {
$package_source = 'https://github.com/sysown/proxysql/releases/download/v1.4.11/proxysql_1.4.11-debian8_amd64.deb'
$package_checksum_value = '813a91ea030ef480c0210b047df5e88ff1c27810'
$package_checksum_type = 'sha1'
$package_dependencies = []
}
'9': {
$package_source = 'https://github.com/sysown/proxysql/releases/download/v1.4.11/proxysql_1.4.11-debian9_amd64.deb'
$package_checksum_value = '65a3c2b98eefa42946ee59eef18ba18534c2a39d'
$package_checksum_type = 'sha1'
$package_dependencies = []
}
default: {
$package_source = undef
$package_checksum_value = undef
$package_checksum_type = undef
$package_dependencies = []
}
}
}
'Ubuntu': {
case $facts['os']['release']['major'] {
'14.04': {
$package_source = 'https://github.com/sysown/proxysql/releases/download/v1.4.11/proxysql_1.4.11-ubuntu14_amd64.deb'
$package_checksum_value = '42b99a12e8e43410aed88da4c5bbe902c43dbba1'
$package_checksum_type = 'sha1'
$package_dependencies = []
}
'16.04': {
$package_source = 'https://github.com/sysown/proxysql/releases/download/v1.4.11/proxysql_1.4.11-ubuntu16_amd64.deb'
$package_checksum_value = '6e7db2fee78eee1a22cdfabefaa50953c3d24501'
$package_checksum_type = 'sha1'
$package_dependencies = []
}
'18.04': {
$_repo_version = '2.0.x'
$_sys_owner = 'proxysql'
$_sys_group = 'proxysql'

# 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"
$package_source = 'https://github.com/sysown/proxysql/releases/download/v2.0.4/proxysql_2.0.4-ubuntu18_amd64.deb'
$package_checksum_value = '397e7244663d8e15134d788e918d9d75c0802b5a'
$package_checksum_type = 'sha1'
$package_dependencies = []
}
default: {
$package_source = undef
$package_checksum_value = undef
$package_checksum_type = undef
$package_dependencies = []
}
}
}
default: {}
$package_dependencies = []

if $facts['os']['release']['major'] == '18.04' {
$_repo_version = '2.0.x'
$_sys_owner = 'proxysql'
$_sys_group = 'proxysql'

# 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['lsbdistcodename']}/",
Expand All @@ -110,9 +62,6 @@
}
'RedHat': {
$package_provider = 'rpm'
$package_source = 'https://github.com/sysown/proxysql/releases/download/v1.4.11/proxysql-1.4.11-1-centos67.x86_64.rpm'
$package_checksum_value = '6f302beaea096b63851a136287818a1b6e049e28'
$package_checksum_type = 'sha1'
$package_dependencies = ['perl-DBI', 'perl-DBD-mysql']
$repo14 = {
descr => 'ProxySQL 1.4.x YUM repository',
Expand All @@ -130,7 +79,7 @@
}
}
default: {
$package_provider = undef
fail("osfamily ${facts['os']['family']} is not supported")
}
}

Expand Down
41 changes: 13 additions & 28 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,24 @@
#
# Manage the repos where the ProxySQL package might be
#
class proxysql::repo inherits proxysql {
if $proxysql::manage_repo == true {
class proxysql::repo {
assert_private()

if $proxysql::manage_repo and !$proxysql::package_source {
$repo = $proxysql::repo_version ? {
'2.0.x' => $proxysql::params::repo20,
'1.4.x' => $proxysql::params::repo14,
}
case $facts['os']['family'] {
'Debian': {
case $proxysql::repo_version {
'2.0.x': {
create_resources('apt::source', { 'proxysql_repo' => $proxysql::repo20})
}
'1.4.x': {
create_resources('apt::source', { 'proxysql_repo' => $proxysql::repo14})
}
default: {
create_resources('apt::source', { 'proxysql_repo' => $proxysql::repo14})
}
apt::source { 'proxysql_repo':
* => $repo,
}
Class['apt::update'] -> Package[$proxysql::package_name]
}
'RedHat': {
case $proxysql::repo_version {
'2.0.x': {
yumrepo { 'proxysql_repo':
* => $proxysql::repo20,
}
}
'1.4.x': {
yumrepo { 'proxysql_repo':
* => $proxysql::repo14,
}
}
default: {
yumrepo { 'proxysql_repo':
* => $proxysql::repo14,
}
}
yumrepo { 'proxysql_repo':
* => $repo,
}
}
default: {
Expand Down
13 changes: 10 additions & 3 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ class { 'proxysql': }
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} }
if fact('os.release.major') == '18.04'
describe command('proxysql --version') do
its(:exit_status) { is_expected.to eq 0 }
its(:stdout) { is_expected.to match %r{^ProxySQL version 2\.0\.} }
end
else
describe command('proxysql --version') do
its(:exit_status) { is_expected.to eq 0 }
its(:stderr) { is_expected.to match %r{ProxySQL version} }
end
end
end

Expand Down