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

make ensure for package and service configurable #11

Merged
merged 4 commits into from
Feb 11, 2017
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
6 changes: 6 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,15 @@ You can override any configuration setting by using the `override_config_setting
##### `package_name`
The name of the ProxySQL package in your package manager. Defaults to 'proxysql'

##### `package_ensure`
The ensure of the ProxySQL package resource. Defaults to 'latest'

##### `service_name`
The name of the ProxySQL service resource. Defaults to 'proxysql'

##### `service_ensure`
The ensure of the ProxySQL service resource. Defaults to 'running'

##### `datadir`
The directory where ProxySQL will store it's data. defaults to '/var/lib/proxysql'

Expand Down
16 changes: 16 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@
# * `package_name`
# The name of the ProxySQL package in your package manager. Defaults to 'proxysql'
#
# * `package_ensure`
# The ensure of the ProxySQL package resource. Defaults to 'latest'
#
# * `service_name`
# The name of the ProxySQL service resource. Defaults to 'proxysql'
#
# * `service_ensure`
# The ensure of the ProxySQL service resource. Defaults to 'running'
#
# * `datadir`
# The directory where ProxySQL will store it's data. defaults to '/var/lib/proxysql'
#
Expand Down Expand Up @@ -68,12 +74,22 @@
# * `save_to_disk`
# Specifies wheter te managed ProxySQL resources should be immediately save to disk. Boolean, defaults to 'true'.
#
# * `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 {}.
#
# * `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,

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

String $datadir = $::proxysql::params::datadir,

Expand Down
2 changes: 1 addition & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class proxysql::install {

package { $::proxysql::package_name:
ensure => present,
ensure => $::proxysql::package_ensure,
}

file { 'proxysql-datadir':
Expand Down
3 changes: 3 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
#
class proxysql::params {
$package_name = 'proxysql'
$package_ensure = 'installed'

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

$listen_ip = '0.0.0.0'
$listen_port = 6033
Expand Down
4 changes: 2 additions & 2 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

if $::proxysql::restart {
service { $::proxysql::service_name:
ensure => running,
ensure => $::proxysql::service_ensure,
enable => true,
hasstatus => true,
hasrestart => false,
Expand All @@ -18,7 +18,7 @@
}
} else {
service { $::proxysql::service_name:
ensure => running,
ensure => $::proxysql::service_ensure,
enable => true,
hasstatus => true,
hasrestart => true,
Expand Down
20 changes: 19 additions & 1 deletion spec/classes/proxysql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@
it { is_expected.to compile.with_all_deps }

it { is_expected.to contain_class('proxysql::params') }
it { is_expected.to contain_class('proxysql::repo').that_comes_before('Class[proxysql::install]') }
it { is_expected.to contain_class('proxysql::install').that_comes_before('Class[proxysql::config]') }
it { is_expected.to contain_class('proxysql::config').that_comes_before('Class[proxysql::service]') }
it { is_expected.to contain_class('proxysql::service').that_subscribes_to('Class[proxysql::install]') }

it { is_expected.to contain_anchor('::proxysql::begin').that_comes_before('Class[proxysql::repo]') }
it { is_expected.to contain_anchor('::proxysql::end') }
it { is_expected.to contain_class('proxysql::service').that_comes_before('Anchor[::proxysql::end]') }

it { is_expected.to contain_class('proxysql::install').that_notifies('Class[proxysql::service]') }

it { is_expected.to contain_class('mysql::client').with(bindings_enable: false) }

it { is_expected.to contain_package('proxysql').with_ensure('present') }
it { is_expected.to contain_package('proxysql').with_ensure('installed') }

it do
is_expected.to contain_file('proxysql-config-file').with(ensure: 'file',
Expand Down Expand Up @@ -51,6 +58,17 @@
hasstatus: true,
hasrestart: true)
end

it do
is_expected.to contain_exec('wait_for_admin_socket_to_open').with(
command: 'test -S /tmp/proxysql_admin.sock',
unless: 'test -S /tmp/proxysql_admin.sock',
tries: 3,
try_sleep: 10,
require: 'Service[proxysql]',
path: '/bin:/usr/bin'
)
end
end
end
end
Expand Down