Tuesday, October 2, 2012

Puppet install rpms via http sources

The redhat package manager - rpm has the capability to install packages
from an url. As simple as

rpm -ivh http://example.com/package.rpm

Taking this in consideration we can use this into puppet to install packages
from an url.

Save this text as test.pp

class examplerpm ( $src ) {

  package { 'package':
     provider => 'rpm',
     ensure => installed,
     source => "${examplerpm::rpm}"
 }
}

class { 'examplerpm':
  src => 'https://example.com/package.rpm',
}


Apply the manifest with puppet

puppet apply --debug --no-daemonize test.pp

Voila - the package is installed via puppet->rpm provider.
The key to all this is to specify the provider into the Package section of
examplerpm class. This ensures that rpm will go fetch the source and installs
it.


3 comments:

  1. Hi and thanks for your post! Just pointing out a little typo:

    source => "${examplerpm::rpm}"

    should be:

    source => "${examplerpm::src}"

    ReplyDelete
  2. Thanks for the information. I am currently installing an rpm package from http source but when I try to update the package with a newer version in the http source, rpm won't update the package. Any insight on this is greatly appreciated.
    package { 'packagename':
    ensure => 'installed',
    provider => 'rpm',
    source => $url,
    }

    ReplyDelete