Skip to content

Commit

Permalink
Merge pull request voxpupuli#23 from voxpupuli/fixes_for_ubuntu_support
Browse files Browse the repository at this point in the history
Fixes for ubuntu support
  • Loading branch information
bastelfreak authored May 25, 2017
2 parents f32afab + b50fa0e commit 6376f2f
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 16 deletions.
14 changes: 9 additions & 5 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ You can customize options such as (but not limited to) `listen_port`, `admin_pas
override_config_settings => $override_settings,
repo => {
'debs_proxysql_repo' => {
comment => 'ProxySQL repo',
location => 'http://debs.example.tld/debian',
repos => 'proxsql',
comment => 'Percona repo',
location => 'http://repo.percona.com/apt',
repos => 'main',
key => {
'id' => '4D1BB29D63D98E422B2113B19334A25F8507EFA5',
'server' => 'keyserver.ubuntu.com',
}
},
},
}
Expand All @@ -61,7 +65,7 @@ class { '::proxysql':
listen_port => 3306,
admin_password => '654321',
monitor_password => '123456',
manage_rpm => true,
manage_repo => true,
}
```

Expand Down Expand Up @@ -291,7 +295,7 @@ Port of the server. Required. Defaults to 3306.
Status of the server. Should be one of the following values: 'ONLINE', 'OFFLINE_SOFT', 'OFFLINE_HARD', 'SHUNNED'. Defaults to 'ONLINE'.

##### `weight`
Weight value of the server. The higher the value, the higher the probability this server will be chosen from the hostgroup. Integer, defaults to 0.
Weight value of the server. The higher the value, the higher the probability this server will be chosen from the hostgroup. Integer, defaults to 1.

##### `compression`
Compression value of the serer. If the value is greater than 0, new connections to that server will use compression. Integer, defaults to 0.
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/proxy_mysql_server/proxysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def create
hostname = @resource.value(:hostname)
port = @resource.value(:port) || 3306
hostgroup_id = @resource.value(:hostgroup_id) || 0
status = @resource.value(:status) || 'ONLINE'
status = @resource.value(:status)
weight = @resource.value(:weight) || 1
compression = @resource.value(:compression) || 0
max_connections = @resource.value(:max_connections) || 1000
Expand Down
3 changes: 1 addition & 2 deletions lib/puppet/type/proxy_mysql_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@

newproperty(:status) do
desc 'Server status.'
defaultto :ONLINE
newvalues(:ONLINE, :SHUNNED, :OFFLINE_SOFT, :OFFLINE_HARD)
end

newproperty(:weight) do
desc 'the bigger the weight of a server relative to other weights, the higher the probability of the server to be chosen from a hostgroup'
defaultto 0
defaultto 1
newvalue(%r{\d+})
end

Expand Down
14 changes: 14 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@
}
}

proxy_global_variable { 'admin-admin_credentials':
value => $config_settings['admin_variables']['admin_credentials'],
load_to_runtime => false,
notify => Service[$::proxysql::service_name],
before => File['root-mycnf-file'],
}

proxy_global_variable { 'admin-mysql_ifaces':
value => $config_settings['admin_variables']['mysql_ifaces'],
load_to_runtime => false,
notify => Service[$::proxysql::service_name],
before => File['root-mycnf-file'],
}

if $proxysql::manage_mycnf_file {
file { 'root-mycnf-file':
ensure => file,
Expand Down
4 changes: 0 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@
# 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'
#
Expand Down Expand Up @@ -145,7 +142,6 @@
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,
Expand Down
2 changes: 1 addition & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
class proxysql::install {

if $::proxysql::manage_rpm {
if !$::proxysql::manage_repo {
package { $::proxysql::package_name:
ensure => $::proxysql::package_ensure,
source => $::proxysql::package_source,
Expand Down
8 changes: 7 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@
$admin_listen_port = 6032

case $::operatingsystem {
'Debian', 'Ubuntu': {
'Debian': {
$admin_listen_socket = '/tmp/proxysql_admin.sock'
$package_provider = 'dpkg'
$sys_owner = 'root'
$sys_group = 'root'
}
'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'
Expand Down
2 changes: 1 addition & 1 deletion manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Manage the repos where the ProxySQL package might be
#
class proxysql::repo inherits proxysql {
if ($::proxysql::manage_repo == true) and ($::proxysql::manage_rpm == false) {
if $::proxysql::manage_repo == true {
case $::operatingsystem {
'Debian', 'Ubuntu': {
create_resources('::apt::source', $::proxysql::repo)
Expand Down
12 changes: 12 additions & 0 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
#
class proxysql::service {

if $::proxysql::manage_config_file {
if $::proxysql::manage_mycnf_file {
$service_require = [ File['proxysql-config-file'], File['root-mycnf-file'] ]
} else {
$service_require = File['proxysql-config-file']
}
} else {
$service_require = undef
}

if $::proxysql::restart {
service { $::proxysql::service_name:
ensure => $::proxysql::service_ensure,
Expand All @@ -15,13 +25,15 @@
status => '/etc/init.d/proxysql status',
start => '/usr/bin/proxysql --reload',
stop => '/etc/init.d/proxysql stop',
require => $service_require,
}
} else {
service { $::proxysql::service_name:
ensure => $::proxysql::service_ensure,
enable => true,
hasstatus => true,
hasrestart => true,
require => $service_require,
}
}

Expand Down
5 changes: 4 additions & 1 deletion spec/classes/proxysql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@
end

case facts[:operatingsystem]
when 'Debian', 'Ubuntu' then
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' }
Expand Down
3 changes: 3 additions & 0 deletions templates/my.cnf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
prompt = 'Admin> '

[client]
<% if scope.lookupvar('::proxysql::admin_listen_socket') != '' -%>
socket = <%= scope.lookupvar('::proxysql::admin_listen_socket') %>
<% else -%>
host = <%= scope.lookupvar('::proxysql::admin_listen_ip') %>
port = <%= scope.lookupvar('::proxysql::admin_listen_port') %>
<% end -%>
user = <%= scope.lookupvar('::proxysql::admin_username') %>
password = <%= scope.lookupvar('::proxysql::admin_password') %>

0 comments on commit 6376f2f

Please sign in to comment.