blt04 / puppet-rvm

A puppet module for installing and using RVM (Ruby Version Manager)
Other
242 stars 280 forks source link

Add compatibility with puppet-stdlib ensure_packages function #64

Closed pbrit closed 11 years ago

pbrit commented 11 years ago

Logically, code is the same as before.

But compatibility with puppet-stdlib ensure_packages/ensure_resource is on board.

Small snippet to explain commit:

node foo {
  include rvm
  include another_module
}
class another_module 
{
  ensure_packages(['libxml2','bar']) # There is no redeclaration error with that commit 
}
davidcollom commented 11 years ago

Am I missing something here or have you just changed "installed"" to "present" your description mentions

ensure_packages([xxxx])
pbrit commented 11 years ago

@davidcollom yes, it's exactly what I did. Do you understand why I did that?

davidcollom commented 11 years ago

Not entirely... my understanding is that installed and present are the same?

From the docs:

Valid values are present (also called installed), absent, purged, held, latest.

pbrit commented 11 years ago

There is things where present and installed are not the same. When you don't use ensure_package function, they are the same.

Take a look at https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/lib/puppet/parser/functions/ensure_packages.rb

I guess the code is the best explanation, so see bellow.

This snippet causes compilation error (due to double definition of resource Package['libxml2']).

node foo {
  package { 'libxml2':
    ensure => installed
  }
  ensure_packages(['libxml2'])
}

But this one works well.

node foo {
  package { 'libxml2':
    ensure => present
  }
  ensure_packages(['libxml2'])
}

Is my explanation clear for you now?