# Can I use a package resource here instead of exec?

Hi,

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


# 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",
}


package { "$packagename": ensure => installed, }  Is there still a way I could be using a Package resource type rather than an Exec? Thanks edit retag close merge delete ## 2 Answers Sort by » oldest newest most voted 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. more ## Comments 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 ( 2017-03-22 07:38:16 -0600 )edit 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.

more