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

Avoid reloading proxysql 2 as root #135

Merged
merged 1 commit into from
Mar 5, 2020
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
9 changes: 8 additions & 1 deletion manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,21 @@
}
} else {
if $proxysql::restart {
if versioncmp($proxysql::version, '2') >= 0 and fact('os.family') == 'RedHat' {
# In proxysql version 2, the init.d scripts, (EL6 and EL7 with proxysql < 2.0.7) support a `reload` option.
# Use this instead of `/usr/bin/proxysql --reload`, (which will run as root).
$start = '/etc/init.d/proxysql reload'
} else {
$start = '/usr/bin/proxysql --reload'
}
service { $proxysql::service_name:
ensure => $proxysql::service_ensure,
enable => true,
hasstatus => true,
hasrestart => false,
provider => 'base',
status => '/etc/init.d/proxysql status',
start => '/usr/bin/proxysql --reload',
start => $start,
stop => '/etc/init.d/proxysql stop',
}
} else {
Expand Down
15 changes: 15 additions & 0 deletions spec/classes/proxysql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,21 @@
enable: true)
end

if facts[:osfamily] == 'RedHat'
context 'with restart = true' do
context 'and proxysql 1.4.16' do
let(:params) { { 'restart' => true, 'version' => '1.4.16' } }

it { is_expected.to contain_service('proxysql').with_start('/usr/bin/proxysql --reload') }
end
context 'and proxysql 2.0.6' do
let(:params) { { 'restart' => true, 'version' => '2.0.6' } }

it { is_expected.to contain_service('proxysql').with_start('/etc/init.d/proxysql reload') }
end
end
end

unless (facts[:osfamily] == 'RedHat' && facts[:operatingsystemmajrelease] == '7') ||
(facts[:operatingsystem] == 'Ubuntu' && facts[:operatingsystemmajrelease] == '18.04') ||
(facts[:operatingsystem] == 'Debian' && facts[:operatingsystemmajrelease] =~ %r{^(9|10)$})
Expand Down