Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

EDIT: 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
share|improve this question
If you can post the classes/manifests that you are using it would be easier to diagnose. – Torian Sep 1 '11 at 23:36
This is old, but... Maintaining in /tmp a copy of whatever packages you need installed is probably not ideal either, as this will result in a loop where a cleaning of /tmp (on reboot or maybe nightly) will remove the rpm, and puppet will copy it back down. And you'll be wasting space in /tmp on an RPM which is already installed. Probably better to set up a yum repo, or (especially with an "installed" ensure as opposed to "latest") install from a http url. – dannysauer May 17 at 20:31
up vote 9 down vote accepted

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":
share|improve this answer
wow, so $names are so 'heavy'. Thanks a lot, it puts light in my system ;) – michal Sep 2 '11 at 16:58

In fact, I don't think above is a correct answer.

Package name should be found according to its package manager.

for ubuntu

root@Web2:~# dpkg --get-selections | grep php
php-pdo install

package name would be php-pdo

for centos

[root@centos 2.6.32-71.el6.x86_64-x86_64]# rpm -qa | grep php

we need to omit the version for rpm according to this reference

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .