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

package manager updates #47

Merged
merged 11 commits into from
Sep 2, 2018
Merged
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ fixtures:
repositories:
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
mysql: "git://github.com/puppetlabs/puppetlabs-mysql.git"
apt: "git://github.com/puppetlabs/puppetlabs-apt.git"
symlinks:
proxysql: "#{source_dir}"
51 changes: 8 additions & 43 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,9 @@ You can customize options such as (but not limited to) `listen_port`, `admin_pas
admin_password => '654321',
monitor_password => '123456',
override_config_settings => $override_settings,
repo => {
'debs_proxysql_repo' => {
comment => 'Percona repo',
location => 'http://repo.percona.com/apt',
repos => 'main',
key => {
'id' => '4D1BB29D63D98E422B2113B19334A25F8507EFA5',
'server' => 'keyserver.ubuntu.com',
}
},
},
}
```

On `Yum` based systems you can do and the module will install ProxySQL from the Percona repo's.
```
class { '::proxysql':
listen_port => 3306,
admin_password => '654321',
monitor_password => '123456',
manage_repo => true,
}
```

## Usage

Configuration is done by the `proxysql` class.
Expand Down Expand Up @@ -187,44 +166,30 @@ Specifies wheter te managed ProxySQL resources should be immediately loaded to t
##### `save_to_disk`
Specifies wheter te managed ProxySQL resources should be immediately save to disk. Boolean, 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`. Defaults to {}.

##### `manage_repo`
Determines wheter 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`. Defaults to {}.
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.

##### `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'
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

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

##### `sys_owner`
owner of the datadir and config_file, defaults to 'root' on most systems, to 'proxysql' on redhat-based
owner of the datadir and config_file, defaults to 'root'

##### `sys_group`
group of the datadir and config_file, defaults to 'root' on most systems, to 'proxysql' on redhat-based

##### `rpm_repo_name`
title for the yumrepo-resource in RedHat-based systems, defaults to 'percona_repo'

##### `rpm_repo_descr`
description for the yumrepo-resource in RedHat-based systems, defaults to 'percona_repo_contains_proxysql'

##### `rpm_repo`
repo url for the yumrepo-resource in RedHat-based systems, defaults to 'http://repo.percona.com/release/$releasever/RPMS/$basearch'

##### `rpm_repo_key`
key utl for the yumrepo-resource in RedHat-based systems, defaults to 'https://www.percona.com/downloads/RPM-GPG-KEY-percona'
group of the datadir and config_file, defaults to 'root'

##### `override_config_settings`
Which configuration variables should be overriden. Hash, defaults to {} (empty hash).
Which configuration variables should be overriden. Hash, defaults to `{}` (empty hash).


## Types
Expand Down
7 changes: 0 additions & 7 deletions examples/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
class { '::proxysql':
listen_port => 3306,
admin_password => 'SuperSecretPassword',
repo => {
'debs_proxysql_repo' => {
comment => 'ProxySQL repo',
location => 'http://debs.ugent.be/debian',
repos => 'mysql-dev',
},
},
}

proxy_mysql_server { '192.168.33.31:3306-31':
Expand Down
37 changes: 13 additions & 24 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -81,31 +81,22 @@
#
# * `repo`
# These are the repo's we will configure. Currently only Debian is supported. This hash will be passed on
# to `apt::source`. Defaults to {}.
# 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.
#
# * `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'
# 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
#
# * `package_provider`
# provider for package-resource. defaults to `dpkg` for debian-based, `rpm` for redhat base or undef for others
#
# * `sys_owner`
# owner of the datadir and config_file, defaults to root on most systems, to proxysql on redhat-based
# owner of the datadir and config_file, defaults to root.
#
# * `sys_group`
# group of the datadir and config_file, defaults to root on most systems, to proxysql on redhat-based
#
# * `rpm_repo_name`
# title for the yumrepo-resource in RedHat-based systems, defaults to 'percona_repo'
#
# * `rpm_repo_descr`
# description for the yumrepo-resource in RedHat-based systems, defaults to 'percona_repo_contains_proxysql'
#
# * `rpm_repo`
# repo url for the yumrepo-resource in RedHat-based systems, defaults to 'http://repo.percona.com/release/$releasever/RPMS/$basearch'
#
# * `rpm_repo_key`
# key utl for the yumrepo-resource in RedHat-based systems, defaults to 'https://www.percona.com/downloads/RPM-GPG-KEY-percona'
# group of the datadir and config_file, defaults to root.
#
# * `override_config_settings`
# Which configuration variables should be overriden. Hash, defaults to {} (empty hash).
Expand Down Expand Up @@ -144,19 +135,17 @@
Boolean $save_to_disk = $::proxysql::params::save_to_disk,

Boolean $manage_repo = true,
Hash $repo = {},
Hash $repo = $::proxysql::params::repo,
mcrauwel marked this conversation as resolved.
Show resolved Hide resolved

String $package_source = $::proxysql::params::package_source,
String $package_provider = $::proxysql::params::package_provider,
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,

String $sys_owner = $::proxysql::params::sys_owner,
String $sys_group = $::proxysql::params::sys_group,

String $rpm_repo_name = $::proxysql::params::rpm_repo_name,
String $rpm_repo_descr = $::proxysql::params::rpm_repo_descr,
String $rpm_repo = $::proxysql::params::rpm_repo,
String $rpm_repo_key = $::proxysql::params::rpm_repo_key,

Hash $override_config_settings = {},
) inherits ::proxysql::params {

Expand Down
19 changes: 18 additions & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,26 @@
class proxysql::install {

if !$::proxysql::manage_repo {
case $facts['os']['family'] {
'Debian': {
archive { '/root/proxysql-package.deb':
ensure => present,
source => $::proxysql::package_source,
mcrauwel marked this conversation as resolved.
Show resolved Hide resolved
checksum => $::proxysql::package_checksum_value,
checksum_type => $::proxysql::package_checksum_type,
}

$real_package_source = '/root/proxysql-package.deb'
}
default: {
$real_package_source = $::proxysql::package_source
}
}

ensure_packages($::proxysql::package_dependencies)
package { $::proxysql::package_name:
ensure => $::proxysql::package_ensure,
source => $::proxysql::package_source,
source => $real_package_source,
provider => $::proxysql::package_provider,
install_options => $::proxysql::package_install_options,
}
Expand Down
108 changes: 80 additions & 28 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
$package_ensure = 'installed'
$package_install_options = []

# Check your version in https://github.com/sysown/proxysql/releases
$package_source = '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'

$service_name = 'proxysql'
$service_ensure = 'running'

Expand All @@ -23,30 +20,90 @@
$admin_listen_ip = '127.0.0.1'
$admin_listen_port = 6032

case $::operatingsystem {
$admin_listen_socket = '/tmp/proxysql_admin.sock'
$sys_owner = 'root'
$sys_group = 'root'

case $facts['os']['family'] {
'Debian': {
$admin_listen_socket = '/tmp/proxysql_admin.sock'
$package_provider = 'dpkg'
$sys_owner = 'root'
$sys_group = 'root'
$package_provider = 'dpkg'
case $facts['os']['name'] {
'Debian': {
case $facts['lsbdistcodename'] {
mcrauwel marked this conversation as resolved.
Show resolved Hide resolved
'jessie': {
$package_source = 'https://github.com/sysown/proxysql/releases/download/v1.4.10/proxysql_1.4.10-debian8_amd64.deb'
$package_checksum_value = '98bab1b7cd719039b1483f7d51c30d7fc563def7'
$package_checksum_type = 'sha1'
$package_dependencies = []
}
'stretch': {
$package_source = 'https://github.com/sysown/proxysql/releases/download/v1.4.10/proxysql_1.4.10-debian9_amd64.deb'
$package_checksum_value = 'd97a2f870e46d5f3218ab80d6c0db6bcc288127a'
$package_checksum_type = 'sha1'
$package_dependencies = []
}
default: {
$package_source = undef
$package_checksum_value = undef
$package_checksum_type = undef
$package_dependencies = []
}
}
}
'Ubuntu': {
case $facts['lsbdistcodename'] {
'trusty': {
$package_source = 'https://github.com/sysown/proxysql/releases/download/v1.4.10/proxysql_1.4.10-ubuntu14_amd64.deb'
$package_checksum_value = '0b89f290bd9cd7e8bc2b7acd8a7799840a31af94'
$package_checksum_type = 'sha1'
$package_dependencies = []
}
'xenial': {
$package_source = 'https://github.com/sysown/proxysql/releases/download/v1.4.10/proxysql_1.4.10-ubuntu16_amd64.deb'
$package_checksum_value = 'df8695c6296678a0eeda036cddff679cc1ff604e'
$package_checksum_type = 'sha1'
$package_dependencies = []
}
'bionic': {
# no upstream bionic builds are provided yet.
mcrauwel marked this conversation as resolved.
Show resolved Hide resolved
}
default: {
$package_source = undef
$package_checksum_value = undef
$package_checksum_type = undef
$package_dependencies = []
}
}
}
default: {}
}
$repo = {
comment => 'ProxySQL APT repository',
location => "http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/${facts['lsbdistcodename']}/",
release => './',
repos => '',
key => {
'id' => '1448BF693CA600C799EB935804A562FB79953B49',
'server' => 'keyserver.ubuntu.com',
},
}
}
'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'
$sys_owner = 'proxysql'
$sys_group = 'proxysql'
'RedHat': {
$package_provider = 'rpm'
$package_source = 'https://github.com/sysown/proxysql/releases/download/v1.4.10/proxysql-1.4.10-1-centos67.x86_64.rpm'
$package_checksum_value = 'f5ca4efa9d69e9bd6ba9a96c724b031cd7326051'
$package_checksum_type = 'sha1'
$package_dependencies = ['perl-DBI', 'perl-DBD-mysql']
$repo = {
descr => 'ProxySQL YUM repository',
baseurl => 'http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/centos/$releasever',
enabled => true,
gpgcheck => true,
gpgkey => 'http://repo.proxysql.com/ProxySQL/repo_pub_key',
}
}
default: {
$admin_listen_socket = '/tmp/proxysql_admin.sock'
$package_provider = undef
$sys_owner = 'root'
$sys_group = 'root'
$package_provider = undef
}
}

Expand All @@ -67,11 +124,6 @@
$load_to_runtime = true
$save_to_disk = true

$rpm_repo_name = 'percona_repo'
$rpm_repo_descr = 'percona_repo_contains_proxysql'
$rpm_repo = 'http://repo.percona.com/release/$releasever/RPMS/$basearch'
$rpm_repo_key = 'https://www.percona.com/downloads/RPM-GPG-KEY-percona'

$config_settings = {
datadir => $datadir,
admin_variables => {
Expand Down
16 changes: 6 additions & 10 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
#
class proxysql::repo inherits proxysql {
if $::proxysql::manage_repo == true {
case $::operatingsystem {
'Debian', 'Ubuntu': {
create_resources('::apt::source', $::proxysql::repo)
case $facts['os']['family'] {
'Debian': {
create_resources('::apt::source', { 'proxysql_repo' => $::proxysql::repo})
}
'CentOS', 'Fedora', 'Scientific', 'RedHat', 'Amazon', 'OracleLinux': {
yumrepo { $::proxysql::rpm_repo_name:
descr => $::proxysql::rpm_repo_descr,
baseurl => $::proxysql::rpm_repo,
enabled => true,
gpgcheck => true,
gpgkey => $::proxysql::rpm_repo_key,
'RedHat': {
yumrepo { 'proxysql_repo':
* => $::proxysql::repo,
}
}
default: {
Expand Down
16 changes: 2 additions & 14 deletions spec/classes/proxysql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,8 @@
install_options: [])
end

case facts[:operatingsystem]
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' }
else
let(:sys_user) { 'root' }
let(:sys_group) { 'root' }
end
let(:sys_user) { 'root' }
let(:sys_group) { 'root' }

it do
is_expected.to contain_file('proxysql-config-file').with(ensure: 'file',
Expand Down