Ruby Third-Party Dependencies in Custom Puppet Providers - ruby

I am not so familiar with Ruby and native custom type development in Puppet, but I cannot find any hints what is the right way of getting modules running that require other ruby gems. I have implemented a custom provider that requires rest-client and nokogiri.
For test purposes I put the module to a specific location und used puppet apply --modulepath=... site.pp. Of course, the run fails because rest-client and nokogiri and are not available on the test host. I can install the gems manually via gem install rest-client nokogiri and everythings works, but I am trying to create a fully automated provision process.
What is the right approach for getting those modules running automatically. In the final scenario, the modules are located at the puppetmaster. Are rest-client and nokogiri required to be present on server- or client-side and how can I make sure that those gems are installed automatically when the module gets used?

Unfortunately, as of right now, "Puppet module metadata.json currently are only concerned with module dependencies," and can't configure gems (PUP-3386).
There was an email discussion on Puppet Users about this at the end of last year as well.

Related

How to create chef tag using ridley

I'm using ruby ridley plugin to bootstrap the node and install some packages. However, I'm trying to create a chef tag using the ridley plugin but I'm unable to find any resources online.
is there a way to create chef tag using ridley or any other best way to do this from ruby?
Node tags aren't a specific object, they are just a convention around node attributes. Specifically it's an array called tags at the normal level. You can set this via any API tool that can get/set node objects. Unless you need high concurrency I would probably recommend using the chef-api gem instead of Ridley, it's simpler for management script use cases.

Config information for a gem

I am working on a gem that needs to be configured with a hostname, username, and password. I would prefer to store this configuration information in config/directoryservices.yml
How do I make my gem automatically create this file when installed?
I've seen a lot of places say that config information should be passed as hashes with gems. The main use of this gem will be in an app that is installed on ~15 servers. Each server will need different config information.
If it is better to include the YAML code in the app and then pass the data as a hash to the gem, I can do that, but I would still like pointers on the best way to do that.
An example of a gem that uses this kind of config is activeldap
If are you working on rails gem, you can create install generator which will copy default config file and then load it into your app.

What is the correct way to use Chef from Ruby (Rails)?

I'm very new with Chef, maybe I search wrong but Google show a lot of quick starts and deployment options, but mostly on how to deploy an app from dev's console. What I need is to perform recipes from the Rails app.
I have a stack which includes Rails+Resque as a master and Chef as a slave. Chef is added as a gem chef, the chef/shef/ext used inside the app to run queries.
It should do several things, like create ssh users (which works) and deploy new app stacks (which don't).
As the chef gem doesn't have a lot of docs and ext doesn't feel like user (or dev) oriented too, I think there should be some other way to work with Chef server (knife?), or some kind of documentation on gem I definitely miss to work effitiantly with this.
We got stuck on something similar and ended up using the ridley gem:
As per this SO question.

Puppet to chef converter

Is there any convertor which converts Puppet scripts to Chef?
I found ruby script which converts Chef scripts to Puppet https://github.com/relistan/chef2puppet but I need puppet2chef.
UPDATE: So, Blueprint is abandonware (last update in 2013). I think the answer to this question is, sadly, now: No.
So, I do not believe there is a 'simple script' way available yet to do this conversion. What I've done in testing is to use Blueprint to do the following:
Install a fresh node with Puppet for the node type you wish to "convert".
Allow Blueprint to scan the resulting server.
Use Blueprint to export either Chef or Puppet code.
Repeat for each node type you have defined in Puppet (or Chef, if you go the other direction).
From the Blueprint README.md:
Blueprint reverse-engineers servers.
Easy configuration management.
Detect relevant packages, files, and source installs.
Generate reusable server configs.
Convert blueprints to Puppet or Chef or CFEngine 3.
No DSLs, no extra servers, no workflow changes.
I hope I'm proven wrong, and there is a soup-to-nuts script to just "convert" from Puppet to Chef. I'd use it in a heartbeat! :) This method will at least get you started.

Installing MaxMind GeoIP ruby library on heroku

I have a Rails app running on heroku. Now I want to run a rake task (which uses a model of my rails app) and geo-tag each record using the MaxMind GeoIP database (http://www.maxmind.com/app/geolite).
Using this database in a Ruby application involves :
Building it's C-API (http://www.maxmind.com/app/c) and then
Build the Ruby bindings for that (http://www.maxmind.com/app/ruby).
I could do this on my local machine and successfully get the country codes from IP addresses. However I do not know how to install these libraries on Heroku. From what I understand the ruby bindings are not available as a gem with native extensions (which heroku would have handled just fine). Also their C-API seems to have a few other dependencies which makes me wonder whether such a thing is possible at all.
So has anyone installed the MaxMind GeoIP (a.k.a Net::GeoIP) on Heroku? If yes how?
I could run the rake task from my laptop by pointing my local setup to the production DB. Before that I would like to know if I can run it from my Heroku setup itself to avoid latency or connection breakdown etc.
I found a gem which bundles the MaxMind C-API and provides it's own Ruby API. It works just fine - http://rubygems.org/gems/geoip
I ll tentatively accept this as the answer. However it would be awesome if someone can tell me how to install binary extensions to Ruby on Heroku.

Resources