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

Fixes for ubuntu support #23

Merged
merged 14 commits into from
May 25, 2017
Merged
4 changes: 4 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,7 @@ If you don't want to have to recreate the virtual machine every time you
can use `BEAKER_DESTROY=no` and `BEAKER_PROVISION=no`. On the first run you will
at least need `BEAKER_PROVISION` set to yes (the default). The Vagrantfile
for the created virtual machines will be in `.vagrant/beaker_vagrant_fies`.

The easiest way to debug in a docker container is to open a shell:

docker exec -it -u root ${container_id_or_name} bash
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
modulesync_config_version: '0.20.1'
modulesync_config_version: '0.21.0'
63 changes: 63 additions & 0 deletions .overcommit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Managed by https://github.com/voxpupuli/modulesync_configs
#
# Hooks are only enabled if you take action.
#
# To enable the hooks run:
#
# ```
# bundle exec overcommit --install
# # ensure .overcommit.yml does not harm to you and then
# bundle exec overcommit --sign
# ```
#
# (it will manage the .git/hooks directory):
#
# Examples howto skip a test for a commit or push:
#
# ```
# SKIP=RuboCop git commit
# SKIP=PuppetLint git commit
# SKIP=RakeTask git push
# ```
#
# Don't invoke overcommit at all:
#
# ```
# OVERCOMMIT_DISABLE=1 git commit
# ```
#
# Read more about overcommit: https://github.com/brigade/overcommit
#
# To manage this config yourself in your module add
#
# ```
# .overcommit.yml:
# unmanaged: true
# ```
#
# to your modules .sync.yml config
---
PreCommit:
RuboCop:
enabled: true
description: 'Runs rubocop on modified files only'
command: ['bundle', 'exec', 'rubocop']
PuppetLint:
enabled: true
description: 'Runs puppet-lint on modified files only'
command: ['bundle', 'exec', 'puppet-lint']
YamlSyntax:
enabled: true
JsonSyntax:
enabled: true
TrailingWhitespace:
enabled: true

PrePush:
RakeTarget:
enabled: true
description: 'Run rake targets'
targets:
- 'test'
- 'rubocop'
command: [ 'bundle', 'exec', 'rake' ]
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ AllCops:
- .vendor/**/*
- pkg/**/*
- spec/fixtures/**/*
- Gemfile
- Rakefile
- Guardfile
Lint/ConditionPosition:
Enabled: True

Expand Down
17 changes: 11 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ sudo: false
dist: trusty
language: ruby
cache: bundler
bundler_args: --without system_tests development
before_install:
- bundle -v
- rm Gemfile.lock || true
Expand All @@ -17,16 +16,22 @@ matrix:
fast_finish: true
include:
- rvm: 2.1.9
bundler_args: --without system_tests development
env: PUPPET_VERSION="~> 4.0" CHECK=test
- rvm: 2.2.6
- rvm: 2.2.7
bundler_args: --without system_tests development
env: PUPPET_VERSION="~> 4.0" CHECK=test
- rvm: 2.3.3
- rvm: 2.3.4
bundler_args: --without system_tests development
env: PUPPET_VERSION="~> 4.0" CHECK=test
- rvm: 2.4.0
- rvm: 2.4.1
bundler_args: --without system_tests development
env: PUPPET_VERSION="~> 4.0" CHECK=test
- rvm: 2.4.0
- rvm: 2.4.1
bundler_args: --without system_tests development
env: PUPPET_VERSION="~> 4.0" CHECK=rubocop
- rvm: 2.4.0
- rvm: 2.4.1
bundler_args: --without system_tests development
env: PUPPET_VERSION="~> 4.0" CHECK=build DEPLOY_TO_FORGE=yes
branches:
only:
Expand Down
16 changes: 8 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ def location_for(place, fake_version = nil)
end

group :test do
gem 'puppetlabs_spec_helper', '~> 2.0.1', :require => false
gem 'parallel_tests', :require => false
gem 'puppetlabs_spec_helper', '~> 2.1.1', :require => false
gem 'rspec-puppet', '~> 2.5', :require => false
gem 'rspec-puppet-facts', :require => false
gem 'rspec-puppet-utils', :require => false
Expand All @@ -26,10 +25,10 @@ group :test do
gem 'metadata-json-lint', :require => false
gem 'puppet-blacksmith', :require => false
gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem.git'
gem 'puppet-strings', '~> 1.0.0', :require => false
gem 'puppet-strings', '~> 1.0', :require => false
gem 'redcarpet', :require => false
gem 'rubocop', '~> 0.47.0', :require => false if RUBY_VERSION >= '2.3.0'
gem 'rubocop-rspec', '~> 1.10.0', :require => false if RUBY_VERSION >= '2.3.0'
gem 'rubocop', '~> 0.48.0', :require => false if RUBY_VERSION >= '2.3.0'
gem 'rubocop-rspec', '~> 1.15.0', :require => false if RUBY_VERSION >= '2.3.0'
gem 'mocha', '>= 1.2.1', :require => false
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
Expand All @@ -39,9 +38,10 @@ group :test do
end

group :development do
gem 'travis', :require => false
gem 'travis-lint', :require => false
gem 'guard-rake', :require => false
gem 'travis', :require => false
gem 'travis-lint', :require => false
gem 'guard-rake', :require => false
gem 'overcommit', '~> 0.39.1', :require => false
end

group :system_tests do
Expand Down
2 changes: 1 addition & 1 deletion Guardfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
notification :off

guard 'rake', :task => 'test' do
guard 'rake', task: 'test' do
watch(%r{^manifests\/(.+)\.pp$})
end
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
24 changes: 10 additions & 14 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 Expand Up @@ -178,19 +174,19 @@
$config_settings = deep_merge($proxysql::params::config_settings, $override_config_settings, $settings)
# lint:endignore

anchor { '::proxysql::begin': } ->
class { '::proxysql::repo':} ->
class { '::proxysql::install':} ->
class { '::proxysql::config':} ->
class { '::proxysql::service':} ->
anchor { '::proxysql::end': }
anchor { '::proxysql::begin': }
-> class { '::proxysql::repo':}
-> class { '::proxysql::install':}
-> class { '::proxysql::config':}
-> class { '::proxysql::service':}
-> anchor { '::proxysql::end': }

Class['::proxysql::install'] ~>
Class['::proxysql::service']
Class['::proxysql::install']
~> Class['::proxysql::service']

if $restart {
Class['::proxysql::config'] ~>
Class['::proxysql::service']
Class['::proxysql::config']
~> Class['::proxysql::service']
}

}
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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it a good idea to put a socket to /tmp?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/tmp is the upstream ProxySQL default...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it's fine by me FWIW.

$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') != '' -%>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we work with undef so this works?

<% if scope.lookupvar('::proxysql::admin_listen_socket') -%>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been working on this last night but I couldn't get it to work with undef.
The parameter is currently defined as:

String $admin_listen_socket = $::proxysql::params::admin_listen_socket

The default in params is:

$admin_listen_socket = '/tmp/proxysql_admin.sock'

When I change the definition to:

Variant[String, Undef] $admin_listen_socket = $::proxysql::params::admin_listen_socket

Then I can do:

class { '::proxysql': 
 admin_listen_socket => undef,
}

but that will go on and use the default /tmp/proxysql_admin.sock.

Either I leave it like this or I remove the if and the entire else case and we don't support an empty $admin_listen_sock...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote empty string is fine then.

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') %>