Mark Christian
2009-Sep-11 17:48 UTC
[Puppet Users] snmpd v3 class help - need to stop service before copying file and then restart
The problem I have is that I need to ensure that snmpd is stopped
before attempting to copy /var/net-snmp/snmpd.conf (snmpd credentials
file that gets corrupted if copied while snmpd is running). Any
suggestions on how best to proceed?
# what I have so far.
class snmpd {
package { net-snmp: ensure => installed }
file { "/etc/snmp/snmpd.conf":
owner => root,
group => root,
mode => 0644,
source => "puppet:///snmpd/snmp.conf",
require => Package[net-snmp],
notify => Service[snmpd],
}
file { "/var/net-snmp/snmpd.conf":
owner => root,
group => root,
mode => 0600,
source => "puppet:///snmpd/net-snmpd.conf",
require => Package[net-snmp],
notify => Service[snmpd],
}
service { snmpd:
enable => true,
hasrestart => true,
ensure => running,
require => Package[$autofs_packages],
}
Thank you.
Mark
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Silviu Paragina
2009-Sep-14 22:00 UTC
[Puppet Users] Re: snmpd v3 class help - need to stop service before copying file and then restart
An odd workaround
Use a secondary file and an exec. Afaik if an exec isn''t executed, the
resources which depend on the exec aren''t applied.
So...
class snmpd {
package { net-snmp: ensure => installed }
file { "/etc/snmp/snmpd.bogous.conf":
owner => root,
group => root,
mode => 0644,
source => "puppet:///snmpd/snmp.conf",
require => Package[net-snmp],
}
exec { "stop-snmpd":
refreshonly => true,
command => "invoke-rc.d snmpd stop", #or change to
/etc/init.d/snmpd stop or whatever
require => File["etc/snmp/snmpd.bogous.conf"],
subscribe => File["etc/snmp/snmpd.bogous.conf"],
}
file { "/etc/snmp/snmpd.conf":
owner => root,
group => root,
mode => 0644,
source => "puppet:///snmpd/snmp.conf",
require => [Package[net-snmp],Exec["stop-snmpd"]],
notify => Service[snmpd],
}
file { "/var/net-snmp/snmpd.conf":
owner => root,
group => root,
mode => 0600,
source => "puppet:///snmpd/net-snmpd.conf",
require =>
[Package[net-snmp],File["/etc/snmp/snmpd.conf"]],
notify => Service[snmpd],
}
service { snmpd:
enable => true,
hasrestart => true,
ensure => running,
require => Package[$autofs_packages],
}
try this with a puppet --test and see what happens
I know this is an ugly workaround :">
Silviu
Mark Christian wrote:> The problem I have is that I need to ensure that snmpd is stopped
> before attempting to copy /var/net-snmp/snmpd.conf (snmpd credentials
> file that gets corrupted if copied while snmpd is running). Any
> suggestions on how best to proceed?
>
>
> # what I have so far.
> class snmpd {
>
> package { net-snmp: ensure => installed }
>
> file { "/etc/snmp/snmpd.conf":
> owner => root,
> group => root,
> mode => 0644,
> source => "puppet:///snmpd/snmp.conf",
> require => Package[net-snmp],
> notify => Service[snmpd],
> }
>
> file { "/var/net-snmp/snmpd.conf":
> owner => root,
> group => root,
> mode => 0600,
> source => "puppet:///snmpd/net-snmpd.conf",
> require => Package[net-snmp],
> notify => Service[snmpd],
> }
>
> service { snmpd:
> enable => true,
> hasrestart => true,
> ensure => running,
> require => Package[$autofs_packages],
> }
>
> Thank you.
>
> Mark
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---