Posts Tagged → GitHub
I was looking at Jesse Newland’s excellent knife-github-cookbooks tool and thought that this would be an excellent tool to write for Puppet too. With the release of Puppet Faces this is now incredibly easy to do. I created a tool called Puppet-GitHub-Face that allows you to install and compare modules from GitHub to modules in your Puppet module path.
Currently Puppet Faces are only supported in Puppet 2.7.0 and later (2.7.0 is currently an RC but will hopefully be out soon!) and distributing them requires placing them into Puppet’s load path. They’ll shortly be distributable as Puppet modules using pluginsync.
So to install the GitHub face for now clone the git repository:
$ git clone git://github.com/jamtur01/puppet-github-face.git
Copy the relevant files into your Puppet master’s path (for example on Debian/Ubuntu into a source-based install).
$ cp lib/puppet/application/github.rb /usr/local/lib/site_ruby/1.8/puppet/application/github.rb $ cp lib/puppet/face/github.rb /usr/local/lib/site_ruby/1.8/puppet/face/github.rb
You can then see if the GitHub Face is installed like so:
$ puppet help
You should see the GitHub face listed in the available Puppet commands and you can now use it to install and compare installed modules. Let’s start with installing a module from Github, for example my puppet-httpauth module.
$ puppet github install --user jamtur01 --repo puppet-httpauth
This command will connect to GitHub, download the puppet-httpauth module and install it into your module path as the httpauth module (the Face automatically strips off prefix and suffix from a module, for example removing puppet-, puppet-module-, and -module from a repository name).
Warning! If a module of the same name is already in your path it’ll get deleted and replaced with this new module.
You can also compare the state of a currently installed module with its GitHub parent, like so:
$ puppet github compare --user jamtur01 --repo puppet-httpauth
This will return unified diff output showing any differences between the currently installed module and the module upstream on Github.
Hope someone finds this useful!
One of the challenges of hosting projects on GitHub and their ticket trackers elsewhere is linking items like GitHub Pull Requests with tickets. I’ve written a very simple API-driven prototype tool called GhostRed to do some simple integration. GhostRed scans GitHub pull requests, creates Redmine tickets in an appropriate project for them and then closes the request with a comment that includes a link to the ticket created.
You can install GhostRed with:
$ gem install ghostred
And you can use it pretty simply like so:
$ ghostred --rm_token=token --rm_site=http://projects.puppetlabs.com --gh_org=puppetlabs --gh_token=token --gh_user jamtur01
Replace the options with ones appropriate to your environment. GhostRed also tries to match GitHub repository names to Redmine projects but also contains a mapping hash
The full help text:
$ ghostred --help Usage: ghostred [options] ... Configuration options: -r, --rm_token TOKEN The API token to use with Redmine -s, --rm_site SITE The Redmine site to connect to -g, --gh_org GITHUB_ORG The GitHub organisation -u, --gh_user GITHUB_USER The GitHub user -t, --gh_token TOKEN The GitHub token Common options: -v, --version Display version -h, --help Display this screen
You can find the code on GitHub and comments, patches and feedback welcomed.