7

I have been attempting to create a manifest for installing postgres 9.1 using puppet on a Centos 5 server. I have been trying to adapt the instructions at http://wiki.postgresql.org/wiki/YUM_Installation in order to achieve this and when I go through a manual process, I have been able to.

It would seem to me therefore that a puppet manifest containing

package { 'postgresql91-server':
  ensure => installed,
  source => 'http://yum.postgresql.org/9.1/redhat/rhel-5-x86_64/pgdg-centos91-9.1-4.noarch.rpm'
}

however on attempting to apply this manifest I get

err: /Stage[main]//Package[postgresql91-server]/ensure: change from absent to present failed: Could not find package postgresql91-server

Any expert puppeteers out there able to help me?

Craig Ringer
  • 11,083
  • 9
  • 40
  • 61
Mr Wilde
  • 203
  • 2
  • 7
  • 1
    Removed postgresql tag - this question applies to any package with dependencies not available in a local repository. +1 for including exact error message text, commands and (some) version numbers. – Craig Ringer Dec 19 '12 at 01:52

3 Answers3

9

Add the repo to yum (using puppet of course), then specify the repo resource as a dependency of the package. This will make upgrading easier later on. See the puppet docs on yum repos for more info.

Steve Wills
  • 685
  • 3
  • 6
3

Thanks to all help from Steve and Paul. The final code that I have used is

yumrepo { "postgres":
  baseurl => "http://yum.postgesql.org/9.1/redhat/rhel-5x86_64/",
  descr => "Postgres 9.1 repository",
  enabled => 1,
  gpgcheck => 1
}

package { 'postgresql91-server' :
  ensure => installed,
}

This does the trick!

Mr Wilde
  • 203
  • 2
  • 7
  • gpgcheck => 0 isn't the best idea if you can avoid that. Are postgresql really releasing unsigned RPMs in their yumrepo? – Paul Gear Dec 20 '12 at 06:28
  • 1
    I'll make a change to gpgcheck => 1 as they do sign their rpms. Thanks for the advice – Mr Wilde Dec 21 '12 at 10:49
2

According to https://puppet.com/docs/puppet/latest/types/package.html, source is dependent upon the underlying package provider supporting it. To my knowledge, yum doesn't allow arbitrary URLs - you must specify a repo (as Steve Wills mentioned).

You might be able to work around this by specifying 'provider => "rpm"' for just this package resource, but i've not tried this myself.

рüффп
  • 620
  • 1
  • 11
  • 25
Paul Gear
  • 4,367
  • 19
  • 38
  • 1
    Yum does allow arbitrary URLs, but it cannot work out that the URL is part of a yum respository and fetch dependencies from the same repository. You can install from a URL to an RPM only if you have a locally defined repo that contains all the dependencies or the dependencies of the package are already installed. – Craig Ringer Dec 19 '12 at 01:52
  • That is if the RPM is actually in a repo. YUM does not require it to be in a repo, it can even install from a local directory. The problem is Puppet 'assumes' it is part of a repo, even when it isn't! – anthony Oct 22 '20 at 23:48