Ask Your Question

Can I use a package resource here instead of exec?

asked 2017-03-21 11:31:10 -0500

Red Cricket gravatar image


I have a system where the admins do not manage the YUM repos very well and yum installs have to specify the entire URL to a given RPM I need to install. So the command line would look this this ...

# yum -y install http://big.long.url/path/to/YUMREPO/RPMS/nameofrpm-0.1.01-1.noarch.rpm

... instead of ...

# yum -y install nameofrpm

So I am under the impression that I my puppet code has to look like this ...

exec { "yum -y install $rpm_url":
    path   => ['/usr/bin'],
    unless => "rpm -q $packagename",

... instead of ...

package { "$packagename":
    ensure => installed,

Is there still a way I could be using a Package resource type rather than an Exec?


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2017-03-21 23:52:48 -0500

updated 2017-03-21 23:54:44 -0500

Maybe like so:

class some_software {
    file { 'nameofrpm_rpm':
        path     => '/var/cache/yum/noarch/42/nameofrpm.rpm'
        ensure   => present,
        mode     => '0644',
        owner    => 'root',
        group    => 'root',
        source   => 'http://big.long.url/path/to/YUMREPO/RPMS/nameofrpm-0.1.01-1.noarch.rpm',

    package { 'name_of_rpm':
        name     => 'nameofrpm',
        ensure   => latest,
        provider => yum,                  
        source   => File['nameofrpm_rpm']['path'],
        require  => File['nameofrpm_rpm'],

Yeah, no, according to the source attribute documentation for package resources the yum provider ignores the source attribute. Can you build upon the rpm provider? Are there package dependencies?

Otherwise, you apparently can't achieve the behavior you wanted (calling yum), at least not with puppet's native resource types.

edit flag offensive delete link more


I was going to comment to use the rpm provider with a source parameter, we have done that in the past, and I think I have seen a few modules in the wild with an option to override the package information with a path to an rpm

DarylW gravatar imageDarylW ( 2017-03-22 07:38:16 -0500 )edit

answered 2017-03-22 06:23:26 -0500

bschonecker gravatar image

updated 2017-03-22 08:59:11 -0500

Why aren't your admins managing YUM repos very well? That seems to be both the cause and solution to your problem; get them to start managing those repositories.

I recommend that you install a custom yum repository file in /etc/yum.repos.d that references the URL where your (custom?) package can be found.

Puppet can manage YUM repos just fine. Just make sure to order the resources properly.

A bit more hackishly:

file {'/path/to/your/rpm': ensure => present, source => 'puppet:///wherever/your/rpm/is', }

exec { "yum -y localinstall /path/to/your/rpm": path => ['/usr/bin'], unless => "rpm -q $packagename", requires => File['path/to/your/rpm', }

Of course, this is pseudo-code. Puppet will ensure the file is downloaded to your local OS first and then do a 'yum localinstall' on the RPM.

I still think using yum repos is a better way to manage what you're tring to accomplish.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-03-21 11:31:10 -0500

Seen: 49 times

Last updated: Mar 22