Deploy nagios client on windows

564 views
Skip to first unread message

Thomas Bendler

unread,
Sep 27, 2012, 3:59:17 PM9/27/12
to puppet...@googlegroups.com
Hi @all,

does anyone manage the NSClient++ deployment with puppet? I have the strange behavior that I can distribute the installation package to the target server and install the package with the MSI provider. The relevant code is here:

  if $windows {
    file {
      "c:/local/source":
      ensure => directory, mode => 0770,
      owner => "Administrators", group => "Administrators";
      
      "c:/local/source/NSClient++-0.3.9-x64.msi":
      ensure => present, mode => 0660,
      owner => "Administrators", group => "Administrators",
      require => File["c:/local/source"],
      path => $::operatingsystem ? { default => "c:/local/source/NSClient++-0.3.9-x64.msi" },
      source => "puppet:///modules/monitor/nagios/NSClient++-0.3.9-x64.msi";
      
      "c:/local/nsclient/boot.ini":
      ensure => present, mode => 0664,
      owner => "Administrators", group => "SYSTEM",
      require => Package["NSClientpp"],
      notify => Service["NSClientpp"],
      path => $::operatingsystem ? { default => "c:/local/nsclient/boot.ini" },
      content => template("monitor/nagios/client/boot.ini.erb");
      
      "c:/local/nsclient/nsc.ini":
      ensure => present, mode => 0664,
      owner => "Administrators", group => "SYSTEM",
      require => Package["NSClientpp"],
      notify => Service["NSClientpp"],
      path => $::operatingsystem ? { default => "c:/local/nsclient/nsc.ini" },
      content => template("monitor/nagios/client/nsc.ini.erb");
    }
    
    package {
      "NSClientpp":
      ensure => installed,
      provider => "msi",
      source => 'c:\local\source\NSClient++-0.3.9-x64.msi',
      install_options => {
        'INSTALLLOCATION' => 'c:\local\nsclient',
        'ADDLOCAL' => 'ALL',
        'START_SERVICE_ON_EXIT' => '1'
      };
    }
    
    service {
      "NSClientpp":
      name => $::operatingsystem ? { default => "NSClientpp" },
      ensure => "running", enable => true,
      require => Package["NSClientpp"];
    }
  }

Now to the strange thing, when the package is installed with the MSI provider, the service entry from the NSClient++ disapear. When I manually execute the installation package with option repair, it apears again ... until the next puppet run where it disapear again. So calling the service resource fail because of the missing service entry. The OS is a 2003SP2 x64, the puppet client has the version 2.7.19. Any ideas?

Regards, Thomas
--
Linux ... enjoy the ride!

Josh Cooper

unread,
Oct 1, 2012, 1:39:05 PM10/1/12
to puppet...@googlegroups.com
Hi Thomas,

On Thu, Sep 27, 2012 at 12:59 PM, Thomas Bendler
<thomas....@gmail.com> wrote:
> Hi @all,
>
> does anyone manage the NSClient++ deployment with puppet? I have the strange
> behavior that I can distribute the installation package to the target server
> and install the package with the MSI provider. The relevant code is here:
>
> if $windows {
> file {
> "c:/local/source":
> ensure => directory, mode => 0770,
> owner => "Administrators", group => "Administrators";
>
> "c:/local/source/NSClient++-0.3.9-x64.msi":
> ensure => present, mode => 0660,
> owner => "Administrators", group => "Administrators",
> require => File["c:/local/source"],
> path => $::operatingsystem ? { default =>
> "c:/local/source/NSClient++-0.3.9-x64.msi" },
> source => "puppet:///modules/monitor/nagios/NSClient++-0.3.9-x64.msi";

This require shouldn't be necessary as the file will autorequire its
ancestor directories.
The name of the package needs to match the "DisplayName" as specified
in the registry (and Add/Remove Programs). This used to be in the
puppet wiki page, but I don't see it in the new documentation. I'll
file a doc bug about this.

For this package, it should be "NSClient++ (x64)", both in the package
resource and the service resource that requires it.

It appears what is occurring is that the second time puppet runs, it
thinks the package is not installed, so it installs it again (really a
repair). For some reason, the NSClient MSI gets confused and
uninstalls the service during the repair.

In any case, the second time you run puppet (with --debug), you should
see something like:

Debug: /Stage[main]//File[c:/local/nagios/NSClient++-0.3.9-x64.msi]/require:
requires File[c:/local/nagios]
Debug: /Stage[main]//Service[NSClientpp]/require: requires
Package[NSClient++ (x64)]
...
Debug: Prefetching msi resources for package
Debug: Service[NSClientpp](provider=windows): Service NSClientpp is running
Debug: Service[NSClientpp](provider=windows): Service NSClientpp start
type is auto start

But you should not see:

Debug: Executing 'msiexec.exe /qn /norestart /i
c:\local\nagios\NSClient++-0.3.9-x64.msi ADDLOCAL=ALL
INSTALLLOCATION=c:\local\nsclient START_SERVICE_ON_EXIT=1'

Josh

--
Josh Cooper
Developer, Puppet Labs

Josh Cooper

unread,
Oct 2, 2012, 1:33:21 PM10/2/12
to puppet...@googlegroups.com
I submitted a pull request https://github.com/puppetlabs/puppet-docs/pull/107

Thomas Bendler

unread,
Oct 8, 2012, 9:26:21 AM10/8/12
to puppet...@googlegroups.com
Hi Josh,

2012/10/2 Josh Cooper <jo...@puppetlabs.com>
On Mon, Oct 1, 2012 at 10:39 AM, Josh Cooper <jo...@puppetlabs.com> wrote:
> [...]

thanks for the answer and sorry for the late reply but I was on vacation. I will follow your recommendations as soon as possible but it won't be before next week (too much projects ;)).

Reards, Thomas
-- 
Reply all
Reply to author
Forward
0 new messages