Skip to content

Commit

Permalink
apply patch from sensu#33
Browse files Browse the repository at this point in the history
  • Loading branch information
vasiliy.karnaukhov committed Apr 27, 2021
1 parent 36e074e commit 596b699
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 25 deletions.
34 changes: 21 additions & 13 deletions manifests/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
dsc_ensure => present,
dsc_policy => 'Log_on_as_a_service',
dsc_identity => $::sensu::windows_service_user['user'],
before => Dsc_service['sensu-client'],
before => Exec['install-sensu-client-service'],
}

acl { 'C:/opt/sensu':
Expand All @@ -62,21 +62,29 @@
'rights' => ['full'],
},
],
before => Dsc_service['sensu-client'],
before => Exec['install-sensu-client-service'],
}

$service_user = $::sensu::windows_service_user['user']
$service_password = $::sensu::windows_service_user['password']
$sc_user_args = " obj= \"${service_user}\" password= \"${service_password}\""
} else {
$sc_user_args = ""
}

# This resource installs the service but service state and refreshes
# are handled by Service[sensu-client]
# See https://tickets.puppetlabs.com/browse/MODULES-4570
dsc_service { 'sensu-client':
dsc_ensure => $dsc_ensure,
dsc_name => 'sensu-client',
dsc_credential => $::sensu::windows_service_user,
dsc_displayname => 'Sensu Client',
dsc_path => 'c:\\opt\\sensu\\bin\\sensu-client.exe',
require => File['C:/opt/sensu/bin/sensu-client.xml'],
notify => Service['sensu-client'],
$sensu_client_exe = "C:\\opt\\sensu\\bin\\sensu-client.exe"
if $sensuclassic::client {
exec { 'install-sensu-client-service':
command => "C:\\windows\\system32\\sc.exe create sensu-client start= delayed-auto binPath= ${sensu_client_exe} DisplayName= \"Sensu Client\"${sc_user_args}", # lint:ignore:140chars
unless => "C:\\windows\\system32\\sc.exe query sensu-client",
require => [
File['C:/opt/sensu/bin/sensu-client.xml'],
Class['::sensu::package'],
Sensu_client_config[$::fqdn],
Class['::sensu::rabbitmq::config'],
],
notify => Service['sensu-client'],
}
}
}
'Darwin': {
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sensu-sensu",
"version": "2.62.3",
"version": "2.62.4",
"author": "sensu",
"summary": "A module to install the Sensu monitoring framework",
"license": "MIT",
Expand Down
24 changes: 13 additions & 11 deletions spec/classes/sensu_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@
end

it do
should contain_dsc_service('sensu-client').only_with({
'dsc_ensure' => 'present',
'dsc_name' => 'sensu-client',
'dsc_credential' => nil,
'dsc_displayname' => 'Sensu Client',
'dsc_path' => 'c:\\opt\\sensu\\bin\\sensu-client.exe',
'notify' => 'Service[sensu-client]',
'require' => 'File[C:/opt/sensu/bin/sensu-client.xml]',
should contain_exec('install-sensu-client-service').only_with({
'command' => "C:\\windows\\system32\\sc.exe create sensu-client start= delayed-auto binPath= C:\\opt\\sensu\\bin\\sensu-client.exe DisplayName= \"Sensu Client\"",
'unless' => "C:\\windows\\system32\\sc.exe query sensu-client",
'notify' => 'Service[sensu-client]',
'require' => [
'File[C:/opt/sensu/bin/sensu-client.xml]',
'Class[Sensu::Package]',
'Sensu_client_config[testfqdn.example.com]',
'Class[Sensu::Rabbitmq::Config]',
],
})
end

Expand All @@ -98,14 +100,14 @@
'dsc_ensure' => 'present',
'dsc_policy' => 'Log_on_as_a_service',
'dsc_identity' => 'test',
'before' => 'Dsc_service[sensu-client]',
'before' => 'Exec[install-sensu-client-service]',
})
end
it do
should contain_acl('C:/opt/sensu').with({
'purge' => 'false',
'permissions' => '[{"identity"=>"test", "rights"=>["full"]}]',
'before' => 'Dsc_service[sensu-client]',
'before' => 'Exec[install-sensu-client-service]',
})
end
end
Expand Down Expand Up @@ -159,7 +161,7 @@

context 'client => false' do
let(:params) { {:client => false} }
it { should contain_dsc_service('sensu-client').with_dsc_ensure('absent') }
it { should_not contain_exec('install-sensu-client-service') }
end
end
end
Expand Down

0 comments on commit 596b699

Please sign in to comment.