Skip to content

Commit

Permalink
Merge pull request #16 from alexvaque/amazon_linux
Browse files Browse the repository at this point in the history
Adding Repo Management for Centos, Redhat, LinuzAmazon
  • Loading branch information
mcrauwel authored Mar 17, 2017
2 parents 1a34ef2 + 35dc6e1 commit c753cdc
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 30 deletions.
7 changes: 6 additions & 1 deletion CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
Matthias Crauwels
alexvaque @alexvaque)
Jean-François Roche (@jfroche)
Matthias Crauwels (@mcrauwel)
Narcis Pillao (@narcisbcn)
Rudy Gevaert (@rgevaert)
Tim Meusel (@bastelfreak)
42 changes: 41 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ You can customize options such as (but not limited to) `listen_port`, `admin_pas
}
```

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_rpm => true,
}
```

## Usage

Configuration is done by the `proxysql` class.
Expand Down Expand Up @@ -177,7 +187,37 @@ Specifies wheter te managed ProxySQL resources should be immediately save to dis
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`
Boolean to determine wheter we want to configure the repo management. Defaults to true.
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 {}.

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

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

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

##### `override_config_settings`
Which configuration variables should be overriden. Hash, defaults to {} (empty hash).
Expand Down
8 changes: 4 additions & 4 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
path => $proxysql::config_file,
content => template('proxysql/proxysql.cnf.erb'),
mode => '0640',
owner => 'root',
group => 'root',
owner => $proxysql::params::sys_owner,
group => $proxysql::params::sys_group,
selinux_ignore_defaults => true,
}
}
Expand All @@ -22,8 +22,8 @@
ensure => file,
path => $proxysql::mycnf_file_name,
content => template('proxysql/my.cnf.erb'),
owner => 'root',
group => 'root',
owner => $proxysql::params::sys_owner,
group => $proxysql::params::sys_group,
mode => '0400',
}
}
Expand Down
42 changes: 40 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,44 @@
# * `manage_repo`
# Determines wheter this module will manage the repositories where ProxySQL might be. Defaults to 'true'
#
# * `repo
# * `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_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'
#
# * `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
#
# * `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'
#
# * `override_config_settings`
# Which configuration variables should be overriden. Hash, defaults to {} (empty hash).
#
class proxysql (
String $package_name = $::proxysql::params::package_name,
String $package_ensure = $::proxysql::params::package_ensure,
Array[String] $package_install_options = $::proxysql::params::package_install_options,

String $service_name = $::proxysql::params::service_name,
String $service_ensure = $::proxysql::params::service_ensure,

Expand Down Expand Up @@ -119,8 +145,20 @@
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,
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: 14 additions & 5 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@
#
class proxysql::install {

package { $::proxysql::package_name:
ensure => $::proxysql::package_ensure,
install_options => $::proxysql::package_install_options,
if $::proxysql::manage_rpm {
package { $::proxysql::package_name:
ensure => $::proxysql::package_ensure,
source => $::proxysql::package_source,
provider => $::proxysql::package_provider,
install_options => $::proxysql::package_install_options,
}
} else {
package { $::proxysql::package_name:
ensure => $::proxysql::package_ensure,
install_options => $::proxysql::package_install_options,
}
}

file { 'proxysql-datadir':
ensure => directory,
path => $::proxysql::datadir,
owner => 'root',
group => 'root',
owner => $::proxysql::sys_owner,
group => $::proxysql::sys_group,
mode => '0600',
}

Expand Down
36 changes: 33 additions & 3 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
# It sets variables according to platform.
#
class proxysql::params {
$package_name = 'proxysql'
$package_name = 'proxysql'
$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 @@ -19,7 +22,28 @@
$admin_password = 'admin'
$admin_listen_ip = '127.0.0.1'
$admin_listen_port = 6032
$admin_listen_socket = '/tmp/proxysql_admin.sock'

case $::operatingsystem {
'Debian', 'Ubuntu': {
$admin_listen_socket = '/tmp/proxysql_admin.sock'
$package_provider = 'dpkg'
$sys_owner = 'root'
$sys_group = 'root'
}
'CentOS', 'Fedora', 'Scientific', 'RedHat', 'Amazon', 'OracleLinux': {
$admin_listen_socket = '/tmp/proxysql_admin.sock'
$package_provider = 'rpm'
$sys_owner = 'proxysql'
$sys_group = 'proxysql'
}
default: {
$admin_listen_socket = '/tmp/proxysql_admin.sock'
$package_provider = undef
$sys_owner = 'root'
$sys_group = 'root'
}
}


$monitor_username = 'monitor'
$monitor_password = 'monitor'
Expand All @@ -35,7 +59,12 @@
$restart = false

$load_to_runtime = true
$save_to_disk = 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,
Expand All @@ -52,4 +81,5 @@
scheduler => {},
mysql_replication_hostgroups => {},
}

}
13 changes: 11 additions & 2 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@
# Manage the repos where the ProxySQL package might be
#
class proxysql::repo inherits proxysql {
if $::proxysql::manage_repo {
if ($::proxysql::manage_repo == true) and ($::proxysql::manage_rpm == false) {
case $::operatingsystem {
'Debian': {
'Debian', 'Ubuntu': {
create_resources('::apt::source', $::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,
}
}
default: {
fail('This operatingsystem is not supported (yet).')
}
Expand Down
13 changes: 7 additions & 6 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"8"
]
}
{ "operatingsystem": "Amazon", "operatingsystemrelease": [ "2016.09" ] },
{ "operatingsystem": "RedHat", "operatingsystemrelease": [ "6", "7" ] },
{ "operatingsystem": "CentOS", "operatingsystemrelease": [ "6", "7" ] },
{ "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "6", "7" ] },
{ "operatingsystem": "Scientific", "operatingsystemrelease": [ "6", "7" ] },
{ "operatingsystem": "Debian", "operatingsystemrelease": [ "7", "8" ] },
{ "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "12.04", "14.04", "16.04" ] }
],
"requirements": [
{
Expand Down
24 changes: 18 additions & 6 deletions spec/classes/proxysql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,38 @@
install_options: [])
end

case facts[:operatingsystem]
when 'Debian', 'Ubuntu' then
let(:sys_user) { 'root' }
let(:sys_group) { 'root' }
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

it do
is_expected.to contain_file('proxysql-config-file').with(ensure: 'file',
owner: 'root',
group: 'root',
owner: sys_user,
group: sys_group,
mode: '0640',
path: '/etc/proxysql.cnf')
end

it do
is_expected.to contain_file('proxysql-datadir').with(ensure: 'directory',
owner: 'root',
group: 'root',
owner: sys_user,
group: sys_group,
mode: '0600',
path: '/var/lib/proxysql')
end

it do
is_expected.to contain_file('root-mycnf-file').with(ensure: 'file',
owner: 'root',
group: 'root',
owner: sys_user,
group: sys_group,
mode: '0400',
path: '/root/.my.cnf')
end
Expand Down

0 comments on commit c753cdc

Please sign in to comment.