1

The Puppet Azure module requires specific gems to be installed. The directions https://github.com/puppetlabs/puppetlabs-azure show the following example:

/opt/puppetlabs/puppet/bin/gem install azure azure_mgmt_compute azure_mgmt_storage azure_mgmt_resources azure_mgmt_network  hocon retries --no-ri --no-rdoc

The specific gem binary /opt/puppetlabs/puppet/bin/gem is used to ensure the gems are installed to the puppet install directory and use puppet's bundled version of ruby.

Puppet's package resource has a gem provider but it will install using the system ruby.

How can I puppetize the gem install specific to puppet? I prefer not to use an exec resource. Is there a resource for puppet-agent to install gems?

Mike Marseglia
  • 883
  • 7
  • 18

2 Answers2

1

I found the answer on https://docs.puppetlabs.com/references/4.0.0/type.html#package-provider-puppet_gem

New for Puppet v4 is a puppet_gem provider to the package resource.

package { 'azure' :
  provider => 'puppet_gem',
  ensure   => installed,
}
Mike Marseglia
  • 883
  • 7
  • 18
0

Looking at the provider it does indeed shell out to gem instead of doing things in-ruby (which is probably not possible at all).

This is not configurable. You can try and make the puppet agent (or apply) run with a PATH that prefers Puppet's Ruby/gem over other copies. That might do it (but might break other things). Of course, you loose the option to install "system" gems in the same Puppet transaction.

Felix Frank
  • 3,063
  • 1
  • 15
  • 22