Ask Your Question
0

Why does Puppet execute steps that depend on a Windows package that didn't install?

asked 2015-06-04 09:12:23 -0500

claquer gravatar image

I have a Windows package step that fails (though Puppet doesn't seem to realize it, which might be a problem with the package.) I also have other steps that require the package to be present. However, despite the package not installing and not appearing in Add/Remove Programs, Puppet does not skip the dependent steps. Is this because Puppet assumes that if the package step was part of the class and it succeeded that it doesn't need to check what's actually installed?

E.g.

class myclass {
    package { 'My Package' : # Definitely the DisplayName of the app
        ensure => installed,
        source => 'c:\installer.exe', # Fails to install, but Puppet doesn't notice. Could be a faulty installer that doesn't set errorlevel properly.
    }

    iis::manage_site { 'My Site' : # Puppet proceeds with this step despite My Package not being in Add/Remove programs or "puppet resource package"
        site_path => 'C:\inetpub\MySite',
        app_pool => 'MyAppPool',
        require => Package['My Package'],
    }
}
edit retag flag offensive close merge delete

Comments

It turns out the installer is returning a large number which is turning into a negative number in the DOS console. So there's another mystery for another question - why does Puppet think it succeeded?

claquer gravatar imageclaquer ( 2015-06-04 09:32:34 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-06-08 20:59:51 -0500

cbarbour gravatar image

Success or failure is implemented internally by the package provider. In most cases, Puppet looks at the exit code of the package installation command to determine success or failure. If the package installer returns a successful value (usually 0,) Puppet assumes that the package installed correctly.

I have limited experience with the Windows package management tools, so I can't comment on your specific case. This could be an issue with the way the provider is implemented, with the Windows package installation utility, with the way the installer is invoked, or with 'installer.exe.'

As a workaround, you can add an exec resource that tests whether or not the package installed correctly, and use that to determine the true success or failure of your package installation.

E.g.

package { 'My Package' : # Definitely the DisplayName of the app
    ensure => installed,
    source => 'c:\installer.exe',
    notify  => Exec['validate_my_package'],
}

exec { 'validate_my_package':
  command   => 'C:\MyPackage\MyBinary.exe -version',
  refreshonly => 'true',
}

iis::manage_site { 'My Site' :
    site_path => 'C:\inetpub\MySite',
    app_pool => 'MyAppPool',
    require => Package['My Package'], Exec['validate_my_package'],
}

In this case, validation will only be performed if the package creates a refresh event; E.g. the package was just installed. Otherwise, this step is skipped, and iis::manage_site is evaluated normally. This is the ideal approach, as it creates a gating test, without polluting your runs with false change notifications (rendering the run non-idempotent according to Puppet's reporting model.)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-06-04 09:12:23 -0500

Seen: 470 times

Last updated: Jun 08 '15