Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This is how I got it working at the end...

class snmp {
  if $::kernel == 'windows'{
    exec {'permMgmt':
    command   => "C:\\Windows\\System32\\reg.exe delete HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\SNMP\\Parameters\\PermittedManagers /f /v 1",
    onlyif    => "C:\\Windows\\System32\\cmd.exe /c reg.exe query HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\SNMP\\Parameters\\PermittedManagers /v 1 | findstr.exe localhost",}
    exec {'valComm':
    command   => "C:\\Windows\\System32\\reg.exe add HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\SNMP\\Parameters\\ValidCommunities /f /v ${snmpCommName} /t REG_DWORD /d 0x00000004",
    unless    => "C:\\Windows\\System32\\cmd.exe /c reg.exe query HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\SNMP\\Parameters\\ValidCommunities /v communityName | findstr.exe 0x4",}
  }      
}

This is how I got it working at the end...

class snmp {
  if $::kernel == 'windows'{
    exec {'permMgmt':
    command   => "C:\\Windows\\System32\\reg.exe delete HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\SNMP\\Parameters\\PermittedManagers /f /v 1",
    onlyif    => "C:\\Windows\\System32\\cmd.exe /c reg.exe query HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\SNMP\\Parameters\\PermittedManagers /v 1 | findstr.exe localhost",}
    exec {'valComm':
    command   => "C:\\Windows\\System32\\reg.exe add HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\SNMP\\Parameters\\ValidCommunities /f /v ${snmpCommName} /t REG_DWORD /d 0x00000004",
    unless    => "C:\\Windows\\System32\\cmd.exe /c reg.exe query HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\SNMP\\Parameters\\ValidCommunities /v communityName ${snmpCommName} | findstr.exe 0x4",}
  }      
}