On 1/8/16 3:14 AM, Fraser Goffin wrote:
Puppet Version: 4.3.1
OS: Centos 7

Note: I am running MASTERLESS

I used this to install a gem :-

package { 'rubyzip':
     ensure   => present,
     provider => 'gem',
}

It installed fine, in this location :
/usr/local/share/gems/gems/rubyzip-1.1.7

gem env shows that the parent folder is on the gem path :-

   - GEM PATHS:
      - /home/vagrant/.gem/ruby
      - /usr/share/gems
      - /usr/local/share/gems

However, when a Puppet manifest attempts to make use of that gem, it
can't find it.

Puppet has its own location for gems, in this particular install its :
/opt/puppetlabs/puppet/lib/ruby/gems/2.1.0/gems

If I change the package to include that directory as an install option,
the gem is indeed installed there and Puppet can use it :-

   package { 'rubyzip':
     ensure   => present,
     provider => 'gem',
     install_options => {
             '--install-dir' => "/opt/puppetlabs/puppet/lib/ruby/gems/2.1.0"
       }
   }

However, this approach seems a bit of a hack and one that will
ultimately create a maintenance overhead as/when Puppet's version of
Ruby is updated, not to mention that we also run Puppet on other
platforms (including Windows) which have different paths. I could handle
that but it seems like there must be a better way of making this work
cross platform without resorting to hard-coded paths even if that is
parametrized.

Has anyone got a suggestion how to solve this one more elegantly?

You might create Gemfile/Gemfile.lock files that manage the versions you expect Puppet to use.

# example code, I'm sure none of the paths and
# checks are actually correct.
# install bundler
exec { 'puppetserver install bundler':
  command => 'puppetserver gem install bundler --no-ri --no-rdoc',
  unless  => 'puppetserver gem list | grep bundler',
}

# managed your Gemfile/Gemfile.lock as part of the repo
exec { 'puppet gems bundle install':
command => '/opt/puppetlabs/puppet/bin/bundle /etc/puppetlabs/gems/Gemfile',
  unless => 'bundle check',
}

Ramin

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/568FF805.6050701%40badapple.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to