optimize my configuration

47 views
Skip to first unread message

puppetstan

unread,
Feb 13, 2017, 7:56:09 AM2/13/17
to Puppet Users
Hi,

i would like modify my conf because is not satisfactory

i would live verify my package version and if my version is 5.0 i do notfhing but if the version is 2.0 for example i download my package in /tmp and i update package...this is my conf but it's not very good...

file { "/tmp/package-5.0.el6.noarch.rpm":
        ensure => 'present',
       source => "puppet:///modules/package/package-5.0.el6.noarch.rpm"
      }

package { "package":
        ensure => '5.0',
        provider => 'rpm',
        source => "/tmp/package-5.0.el6.noarch.rpm"
        }

can you have an idea with condition if i do nothing else dwonload package and i update...
regards

Michael Watters

unread,
Feb 13, 2017, 10:44:03 AM2/13/17
to Puppet Users
ensure => '5.0' should work but you may want to add a dependency to the package resource to ensure that the file is downloaded first.


package { "package":
    ensure => '5.0',
    provider => 'rpm',
    source => '/tmp/package-5.0.el6.noarch.rpm',
    require => File['/tmp/package-5.0.el6.noarch.rpm',

puppetstan

unread,
Feb 13, 2017, 11:51:42 AM2/13/17
to Puppet Users
thanks for your answer

But with this conf, my package package-5.0.el6.noarch.rpm is automatically downloaded even if my package version is 5.0. So it's my problem. I don't want downloaded package package-5.0.el6.noarch.rpm if my version package is 5.0...

file { "/tmp/package-5.0.el6.noarch.rpm":
#        ensure => 'present',
       source => "puppet:///modules/puppet/package-5.0.el6.noarch.rpm"

      }


package { "package":
        ensure => '5.0',
        provider => 'rpm',
        source => "/tmp/package-5.0.el6.noarch.rpm",
        require => File["/tmp/package-5.0.el6.noarch.rpm"]
        }

Regards

jcbollinger

unread,
Feb 14, 2017, 9:09:23 AM2/14/17
to Puppet Users


On Monday, February 13, 2017 at 10:51:42 AM UTC-6, puppetstan wrote:
thanks for your answer

But with this conf, my package package-5.0.el6.noarch.rpm is automatically downloaded even if my package version is 5.0. So it's my problem. I don't want downloaded package package-5.0.el6.noarch.rpm if my version package is 5.0...

file { "/tmp/package-5.0.el6.noarch.rpm":
#        ensure => 'present',
       source => "puppet:///modules/puppet/package-5.0.el6.noarch.rpm"
      }


package { "package":
        ensure => '5.0',
        provider => 'rpm',
        source => "/tmp/package-5.0.el6.noarch.rpm",
        require => File["/tmp/package-5.0.el6.noarch.rpm"]
        }



I strongly recommend creating a local repository for your RPMs, and using yum to manage packages (under Puppet direction).  The job you propose to have Puppet do is among yum's core behaviors.

If you insist on doing it manually, however, then you have two main choices:
  1. Accept that Puppet will maintain copies of your RPMs on each machine.  Give it a place to put them where they will be persistent (i.e. some place other than /tmp) -- Puppet will not download your RPMs again if they are already there.
  2. Create one or more custom facts by which to convey to Puppet whether the RPM(s) of interest are already installed and at the desired version.  Your manifests can then declare both the File resource and the Package resource conditionally, based on the value of the fact.
Option (2) seems to be what you're asking for, but it is the messiest and most fragile alternative of all those available to you.


John

puppetstan

unread,
Feb 28, 2017, 12:09:14 PM2/28/17
to Puppet Users
thanks,

i think the local repository is the best choice...i create it with createrepo

regards
Reply all
Reply to author
Forward
0 new messages