Puppet Module Gem Dependency?

394 views
Skip to first unread message

bryan...@gmail.com

unread,
Dec 24, 2016, 4:41:28 PM12/24/16
to Puppet Developers
Hello All,

I'm updating a module that will require a ruby gem (e.g. xml-simple) for one of the custom providers. How does Puppet make sure that the gem is available and installed when the module is installed? Does a puppet module install also install any dependent gems? How does it know which gems are needed to install? To where does Puppet install gems?

Or is there something else that consumers of my module will need to do to ensure that the gems are available before they try to use the module's resources?

I tried searching both this group and Puppet Users but didn't find much. May be the key-words aren't right.

Anyway, any assistance would be appreciated.

-Stopp

Rob Nelson

unread,
Dec 24, 2016, 9:14:16 PM12/24/16
to puppe...@googlegroups.com
Zabbix uses the zabbixapi gem, you can take a look at how it implements it to be sure it's present before the type and provider is used. There's no simple tutorial about how that's laid out but you can see the references at https://github.com/voxpupuli/puppet-zabbix/search?utf8=%E2%9C%93&q=zabbixapi

--


You received this message because you are subscribed to the Google Groups "Puppet Developers" group.


To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/67b2a7a4-4551-4ec8-9f3e-5e5d3383b425%40googlegroups.com.


For more options, visit https://groups.google.com/d/optout.


--
Rob Nelson

bryan...@gmail.com

unread,
Dec 24, 2016, 9:30:11 PM12/24/16
to Puppet Developers
I see the pattern. Is this the "Puppet way"? I saw/found this PR[1] which shows a module which requires a gem; but when i try this i still get the error:

Could not autoload puppet/provider/aem_crx_package/ruby: cannot load such file -- xmlsmiple


I've tried the following:

1) Installing the gem with puppetserver gem install and restarting the master
2) Installing it using the gem command in the puppserver bin directory directly (which does not install it to the same place as #1)
3) Specifying package (type gem) on the master like the example in the PR link
4) Specifying package (type gem) on the agent like the example in the PR link

I get the impression that the pattern in the referenced project is similar to #3 and/or #4 above, but it still doesn't work.

Still looking for help and thoughts/suggestions.

bryan...@gmail.com

unread,
Dec 24, 2016, 10:06:55 PM12/24/16
to Puppet Developers
I've also tried to add the confines logic as the PR says, however i still get the missing load file. Here's the project i've been trying to update:


The provider is here: 


-Stopp

bryan...@gmail.com

unread,
Jan 4, 2017, 12:44:01 AM1/4/17
to Puppet Developers
I refactored my work to follow the pattern/design in the Zabbix module, as suggested. However i still continue to get this error, but only on the first run:

Could not run: cannot load such file --


Subsequent runs work, as it appears the issue is now that the Ruby gems/packages installed are not auto-loaded back into the Puppet Agent's cache to identify that they are now available. So the require declarations still fail to find the gem. 

Is it possible to tell the agent during a run that it needs to reload the gem in-memory cache? (Is this a thing?)

Any thoughts? 

For Zabbix team: How does the Zabbix module's acceptance test manage this?

Thanks again!

-Stopp

bryan...@gmail.com

unread,
Jan 4, 2017, 2:48:20 PM1/4/17
to Puppet Developers
I was able to resolve this issue by creating appropriate feature/confines with my provider.

Thanks all for the help!

-Stopp
Reply all
Reply to author
Forward
0 new messages