Friday, March 2, 2012

Stupid Puppet Tricks: Appending to a variable

Want to maybe once in a while append things to a variable and not have to result to 15 snippet files and a exec to cat?  Here's one way that assumes that your classes are under your control and you can declare and use top scope variables. 

This is a kludge, and likely shouldn't work in puppet.  It's certainly against the core design and probably just a bad idea.

node 'foo' {
  include appender
  include speaker
  $bob = ''
  appender::append { 'one':
    $text => 'one',
    before => Appender::Append['two'],
  append::append {'two':
    $text => 'two',
  speaker::speak {'truth':
    $lies => $bob,
    require => Appender::Append['two'],

class appender {
  define append($text) {
    $bob += "$text "

class speaker {
  define speak($lies) {
    notice("the speaker $lies")

Wednesday, January 18, 2012

ruby: gem install dies with buffer overflow

In hopes the Google machine will help some other poor hapless soul who stumbles across the same problem...

At work, I'm trying to use vlad-push to do pushes of current code to remote hosts.  I found a few bugs, fixed, them on my Mac, minted a new gem, and then tried to make a RPM at work using the newly built gemfile.  This fails spectacularly anytime you try to parse the gemfile's metadata, like so:

[nhruby@rpmbuilder1 rubygem-vlad-push]$ gem specification vlad-push-1.1.0.gem
*** buffer overflow detected ***: /usr/bin/ruby terminated
======= Backtrace: =========
On my Mac I use rbenv and had 1.9.3-p0 installed, which spits out a "date:" value in the metadata YAML that causes older version of ruby's YAML parser to crash on Linux systems with hardened glibc builds (more details found here). 

Switching rbenv to use ruby 1.8.7 fixes the issue to produce a date field with saner value that older ruby version (such as those on CentOS/RHEL 5) can cope with.