Skip to content

Commit

Permalink
Merge pull request #204 from blackknight36/service_cmd_fix
Browse files Browse the repository at this point in the history
Set snmpd stop command based on the node's default service provider
  • Loading branch information
juniorsysadmin authored Aug 17, 2019
2 parents 443688f + baaa2ed commit 6094052
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
8 changes: 4 additions & 4 deletions manifests/snmpv3_user.pp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@

if $create {
unless defined(Exec["stop-${service_name}"]) {
#
# TODO: update $command for different operating systems/releases
#
$command = "service ${service_name} stop ; sleep 5"
$command = $facts['service_provider'] ? {
'systemd' => "systemctl stop ${service_name}; sleep 5",
default => "service ${service_name} stop ; sleep 5",
}

exec { "stop-${service_name}":
command => $command,
Expand Down
9 changes: 0 additions & 9 deletions spec/defines/snmp_snmpv3_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
it {
is_expected.to contain_exec('stop-snmpd').with(
path: '/bin:/sbin:/usr/bin:/usr/sbin',
command: 'service snmpd stop ; sleep 5',
user: 'root'
).that_requires(['Package[snmpd]', 'File[var-net-snmp]'])

Expand Down Expand Up @@ -50,7 +49,6 @@
it {
is_expected.to contain_exec('stop-snmpd').with(
path: '/bin:/sbin:/usr/bin:/usr/sbin',
command: 'service snmpd stop ; sleep 5',
user: 'root'
).that_requires(['Package[snmpd]', 'File[var-net-snmp]'])

Expand All @@ -77,7 +75,6 @@
it {
is_expected.to contain_exec('stop-snmptrapd').with(
path: '/bin:/sbin:/usr/bin:/usr/sbin',
command: 'service snmptrapd stop ; sleep 5',
user: 'root'
).that_requires(['Package[snmpd]', 'File[var-net-snmp]'])

Expand All @@ -103,7 +100,6 @@
it {
is_expected.to contain_exec('stop-snmpd').with(
path: '/bin:/sbin:/usr/bin:/usr/sbin',
command: 'service snmpd stop ; sleep 5',
user: 'root'
).that_requires(['Package[snmpd]', 'File[var-net-snmp]'])

Expand Down Expand Up @@ -132,7 +128,6 @@
it {
is_expected.to contain_exec('stop-snmpd').with(
path: '/bin:/sbin:/usr/bin:/usr/sbin',
command: 'service snmpd stop ; sleep 5',
user: 'root'
).that_requires(['Package[snmpd]', 'File[var-net-snmp]'])

Expand All @@ -159,7 +154,6 @@
it {
is_expected.to contain_exec('stop-snmpd').with(
path: '/bin:/sbin:/usr/bin:/usr/sbin',
command: 'service snmpd stop ; sleep 5',
user: 'root'
).that_requires(['Package[snmpd]', 'File[var-net-snmp]'])

Expand All @@ -185,7 +179,6 @@
it {
is_expected.to contain_exec('stop-snmpd').with(
path: '/bin:/sbin:/usr/bin:/usr/sbin',
command: 'service snmpd stop ; sleep 5',
user: 'root'
).that_requires(['Package[snmpd]', 'File[var-net-snmp]'])

Expand Down Expand Up @@ -214,7 +207,6 @@
it {
is_expected.to contain_exec('stop-snmpd').with(
path: '/bin:/sbin:/usr/bin:/usr/sbin',
command: 'service snmpd stop ; sleep 5',
user: 'root'
).that_requires(['Package[snmpd]', 'File[var-net-snmp]'])

Expand All @@ -241,7 +233,6 @@
it {
is_expected.to contain_exec('stop-snmptrapd').with(
path: '/bin:/sbin:/usr/bin:/usr/sbin',
command: 'service snmptrapd stop ; sleep 5',
user: 'root'
).that_requires(['Package[snmpd]', 'File[var-net-snmp]'])

Expand Down

0 comments on commit 6094052

Please sign in to comment.