7

I use the package install attribute to ensure that given package X is installed.

However, even though the package is installed, puppet tries to install it over again and of course exits with an exception ("X already installed"). It does not happen when the package name matches a service name. I use local RPM and an RPM provider.

How do I avoid that exception?


I also implemented a workaround: if I succeed with the RPM installation, I create a file called /X_DONE. Then I install the dependencies based on that file, not the package.

What is the proper way to deal with that?

Here is the failing manifest:

file {"$tmp_dir/$php_pdo":
  ensure => present,
  source => "puppet:///files/services/$php_pdo"
}

package {"php_pdo": require => File["$tmp_dir/$php_pdo"], ensure => installed, provider => rpm, source => "$tmp_dir/$php_pdo" }

and exception:

err: /Stage[main]/Apache-php/Package[php_pdo]/ensure: change from absent to present failed: Execution of '/bin/rpm -i --oldpackage /tmp/puppet/php-pdo-5.1.6-27.el5_5.3.x86_64.rpm' returned 1:     package php-pdo-5.1.6-27.el5_5.3.x86_64 is already installed
Giacomo1968
  • 58,727
michal
  • 215

2 Answers2

11

You refer to the package by the name php_pdo, but Puppet sees the package as php-pdo (dash, not underscore).

Every time it checks to see of php_pdo is installed, it finds out that it is not. Unfortunately it doesn't matter how many times you install php-pdo, it will never be php_pdo.

To resolve the issue, change the line:

package {"php_pdo":

to be:

package {"php-pdo":
Giacomo1968
  • 58,727
0

This can sometimes be down to how apt references packages.

In my case, I had Puppet telling machines to install pip this was just continuously installing same package again and again. When pip does install it's just a pointer to the python3-pip package. Puppets keeps applying the same task because there is no package installed called pip, it doesn't throw a error.

apt sometime has meta-packages or symbolic-packages, i.e. Running apt install pip doesn't mean dpkg -l | grep pip will report a matching package.

Fundamentally, reference the package correctly whether it's spelling php_pdo right or accounting for ghostly meta-packages within apt repo listings.

Toto
  • 19,304
jamboNum5
  • 116
  • 1