#########################################################
#
# snmpd.cf - configure snmpd
#
#########################################################
bundle agent snmpd {
meta:
"description" string => "Configure SNMP";
"tags" slist => { "autorun" };
files:
linux::
"/etc/snmp/snmpd.conf"
edit_template => "$(glb.templates)/snmpd.conf.mustache",
edit_defaults => empty,
template_method => "mustache",
classes => results("bundle", "snmpd_conf"),
perms => mog("0600","$(snmpd_conf_owner)","root");
# NOTE: snmpd saves persistent data in /var/lib/net-snmp/snmpd.conf (refered to here as the
# "persistent" snmpd.conf). snmpd must be stopped before /var/lib/net-snmp/snmpd.conf is copied
# or snmpd will revert any changes on it's next startup. So, we first copy the persistent snmpd.conf
# to a staging area, then stop snmpd, copy snmpd.conf to /var/lib/net-snmp and finally restart snmpd.
"/srv/sysadmin/etc/persistent_snmpd.conf"
comment => "stage the persistent snmpd.conf",
copy_from => force_cp("/var/lib/net-snmp/snmpd.conf"),
classes => results("bundle", "staged_snmpd_conf"),
perms => mog("0640","root","root");
snmpd_stop_repaired::
"/var/lib/net-snmp/snmpd.conf"
delete => file;
"/var/lib/net-snmp/snmpd.conf"
comment => "copy the persistent snmpd.conf to /var/lib/net-snmp",
copy_from => local_cp("/srv/sysadmin/etc/persistent_snmpd.conf"),
classes => results("bundle", "persistent_snmpd_conf"),
perms => mog("0600","root","root");
services:
snmpd_conf_repaired::
"snmpd"
service_policy => "reload";
staged_snmpd_conf_repaired::
"snmpd"
service_policy => "stop",
classes => results("bundle", "snmpd_stop");
!(snmpd_stop_repaired|staged_snmpd_conf_repaired)::
# NOTE: Due to CFEngine function caching, the service status (active/inactive) is only determined once
# per cf-agent process. snmpd service restart must therefore be delayed if it was stopped by the
# current cf-agent process. This means a 5 minute delay in restarting.
"snmpd"
service_policy => "start";
reports:
"DEBUG|DEBUG_$(this.bundle)"::
"DEBUG $(this.bundle): snmpd.conf owner = $(snmpd_conf_owner)";
"DEBUG|DEBUG_$(this.bundle).hpsmh"::
"DEBUG $(this.bundle): Configuring hpsmh dlmod";
"DEBUG|DEBUG_$(this.bundle).!hpsmh"::
"DEBUG $(this.bundle): hpsmh dlmod not configured";
}
Changing function caching temporarily might take two agent runs, but that could be coordinated between update.cf policy and promoses.cf. I can imagine interesting ways to do this with the new multiple augments support.
I think it might be cleaner if we had a way to do per promise cache invalidation.
sysvservice.restart:: |
"$(paths.service) $(service) restart" |
handle => "standard_services_sysvservice_restart", |
classes => kept_successful_command, |
comment => "If the service should be restarted we issue the |
standard service command to restart or reload the service. |
There is no restriction based on the services current state as |
restart can start a service that was not already |
--
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to help-cfengine+unsubscribe@googlegroups.com.
To post to this group, send email to help-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/help-cfengine.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to help-cfengin...@googlegroups.com.
#########################################################
#
# snmpd.cf - configure snmpd
#
#########################################################
bundle agent snmpd {
meta:
"description" string => "Configure SNMP";
"tags" slist => { "autorun" };
classes:
"hpsmh" expression => regcmp("true", "$(hpsmh)");
files:
linux::
"/etc/snmp/snmpd.conf"
edit_template => "$(glb.templates)/snmpd.conf.mustache",
edit_defaults => empty,
template_method => "mustache",
classes => results("bundle", "snmpd_conf"),
perms => mog("0600","$(snmpd_conf_owner)","root");
# NOTE: snmpd saves persistent data in /var/lib/net-snmp/snmpd.conf (refered to here as the
# "persistent" snmpd.conf). snmpd must be stopped before /var/lib/net-snmp/snmpd.conf is copied
# or snmpd will revert any changes on it's next startup. So, we first copy the persistent snmpd.conf
# to a staging area, then stop snmpd, copy snmpd.conf to /var/lib/net-snmp and finally restart snmpd.
"/srv/sysadmin/etc/persistent_snmpd.conf"
comment => "stage the persistent snmpd.conf",
copy_from => force_cp("/var/lib/net-snmp/snmpd.conf"),
classes => results("bundle", "staged_snmpd_conf"),
perms => mog("0640","root","root");
snmpd_stop_repaired::
"/var/lib/net-snmp/snmpd.conf"
delete => file;
"/var/lib/net-snmp/snmpd.conf"
comment => "snmpd is stopped, copy the persistent snmpd.conf to /var/lib/net-snmp",
copy_from => local_cp("/srv/sysadmin/etc/persistent_snmpd.conf"),
classes => results("bundle", "persistent_snmpd_conf"),
perms => mog("0600","root","root");
services:
snmpd_conf_repaired::
"snmpd"
service_policy => "reload";
staged_snmpd_conf_repaired::
"snmpd"
service_policy => "stop",
classes => results("bundle", "snmpd_stop");
any::
"snmpd"
service_policy => "start";
commands:
persistent_snmpd_conf_repaired::
# NOTE: Due to CFEngine function caching, a service promise cannot be used to start snmpd
# if it was stopped by the current cf-agent process. So we use a command instead to start
# snmpd.
"$(paths.path[service]) snmpd start"
ifvarclass => "!systemd";
"$(paths.path[systemctl]) snmpd start"
ifvarclass => "systemd";
reports:
"DEBUG|DEBUG_$(this.bundle)"::
"DEBUG $(this.bundle): snmpd.conf owner = $(snmpd_conf_owner)";
"DEBUG|DEBUG_$(this.bundle).hpsmh"::
"DEBUG $(this.bundle): Configuring hpsmh dlmod";
"DEBUG|DEBUG_$(this.bundle).!hpsmh"::
"DEBUG $(this.bundle): hpsmh dlmod not configured";
}