Hi list,
I'm working on a little addition to an internal module we use to ensure
our puppet clients have a consistent configuration to also ensure the
correct version of puppet is installed on the system and run into a bit
of semantics issue as I thought that "ensure => 'version.num'" was a
more correct way of specifying the version of a package, rather than
doing it in the name of the resource.

Here's a few snippets of code:

Common class opening:

class puppet_mw::client (
  ...
  $manage_versions  = true,
  $puppet_version   = '3.6.2',
  $facter_version   = '2.0.2',
  $hiera_version    = '1.3.4',
  ...
) {

This works:

  if $manage_versions {
    package { "puppet-${puppet_version}":
      ensure => present,
    }
    package { "facter-${facter_version}":
      ensure => present,
    }
    package { "hiera-${hiera_version}":
      ensure => present,
    }
  }


This however, does not:

  if $manage_versions {
    package { 'puppet':
      ensure => ${puppet_version},
    }
    package { 'facter':
      ensure => ${facter_version},
    }
    package { 'hiera':
      ensure => ${hiera_version},
    }
  }

As it generates this error:

Error: Could not update: Failed to update to version 3.6.2, got version
3.6.2-1.el6 instead
Wrapped exception:
Failed to update to version 3.6.2, got version 3.6.2-1.el6 instead
Error: /Stage[main]/Puppet_mw::Client/Package[puppet]/ensure: change
from 3.6.2-1.el6 to 3.6.2 failed: Could not update: Failed to update to
version 3.6.2, got version 3.6.2-1.el6 instead
Error: Could not update: Failed to update to version 2.0.2, got version
2.0.2-1.el6 instead
Wrapped exception:
Failed to update to version 2.0.2, got version 2.0.2-1.el6 instead
Error: /Stage[main]/Puppet_mw::Client/Package[facter]/ensure: change
from 1.7.5-1.el6 to 2.0.2 failed: Could not update: Failed to update to
version 2.0.2, got version 2.0.2-1.el6 instead
Error: Could not update: Failed to update to version 1.3.4, got version
1.3.4-1.el6 instead
Wrapped exception:
Failed to update to version 1.3.4, got version 1.3.4-1.el6 instead
Error: /Stage[main]/Puppet_mw::Client/Package[hiera]/ensure: change from
1.3.2-1.el6 to 1.3.4 failed: Could not update: Failed to update to
version 1.3.4, got version 1.3.4-1.el6 instead

Which lead me to this, but will get messy to ensure compatibility with
different Linux versions:

  if $manage_versions {
    case $::osfamily {
      'RedHat': { $os_string = "-1.el${::operatingsystemmajrelease}" }
      default : { $os_string = undef }
    }

    package { 'puppet':
      ensure => "${puppet_version}${os_string}",
    }
    package { 'facter':
      ensure => "${facter_version}${os_string}",
    }
    package { 'hiera':
      ensure => "${hiera_version}${os_string}",
    }
  }

Running 'yum install puppet-3.6.2' works as desired, but adding
'allow_virutal => true,' to the package resource doesn't change the
previous error.

Is this working as designed for the Yum provider for the package
resource or is this a bug with the provider?  For some reason, I want to
think this has been discussed on the list before, but couldn't find the
relevant thread.

It appears I may be running up against this bug:

https://tickets.puppetlabs.com/browse/PUP-1244

TIA.

-- 
Joseph Swick <[email protected]>
Operations Engineer
Meltwater Group

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to