Updating Existing Software Already On Syste: Puppet Thru Chocolatey

Viewed 16

I am looking for adjustments on a Puppet script that takes leverages chocolatey to install software. I have a normal script that installs software via chocolatey and works fine. Here it is:

class standardsoftware($list = []) {

include chocolatey

package { $list:
ensure   => latest,
provider => 'chocolatey',
}
}

This script works but I would like it to install a piece of software only if the software is ALREADY installed. I have managed to import a system's software listing into external facts and populate into Foreman. No problem. I have created another Puppet script that checks against the software external facts, but it doesn't seem to work.

Here it is:

class updatesoftware($list = []) {

include chocolatey

$installed = false
$a = $facts['software']
$a.each |$i, $b| 
{
$c = downcase($b)
$d = regsubst($c, " ", "")

if (match($list,$d) or $list in $d) {
$installed = true
}

}

if($installed) {
package { $list:
ensure   => latest,
provider => 'chocolatey',
}
}

Now the script runs when I tested it against a node by running the puppet agent -test command and I get no errors. But I don't see the update from chocolatey when a new update is available.

Can someone assist?

0 Answers
Related