OSX 10.9 a.k.a Mavericks and puppet

Hmh, Apple got me with my pants down with their announcement about Mavericks being free-for-all as we have been managing some Macs with puppet. Current plan before that was to finally upgrade puppet infra to 3.3.1 from latest 2.7-series…Well, good part is that now we run 3.3.1 in server and are about to push update to clients

But to the beef, puppet 3.3.1 installs itself to /Library/Ruby/Site/1.8 directory and Mavericks has Ruby 2.0 => puppet is broken on Mavericks. There is a feature waiting for a new release (3.4.0)

As workaround puppet was configured to make following symlinks to /Library/Ruby/Site:

facter -> 1.8/facter
facter.rb -> 1.8/facter.rb
hiera -> 1.8/hiera
hiera_puppet.rb -> 1.8/hiera_puppet.rb
puppet -> 1.8/puppet
puppet.rb -> 1.8/puppet.rb
puppetx -> 1.8/puppetx
puppetx.rb -> 1.8/puppetx.rb
semver.rb -> 1.8/semver.rb

puppet:

if versioncmp($clientversion, '3.3.2') < 0 {
    exec { '/bin/ln -s 1.8/facter facter':
        cwd     =>  '/Library/Ruby/Site',
        creates => '/Library/Ruby/Site/facter'
    }
    exec { '/bin/ln -s 1.8/facter.rb facter.rb':
         cwd     =>  '/Library/Ruby/Site',
         creates =>  '/Library/Ruby/Site/facter.rb'
    }
    exec { '/bin/ln -s 1.8/puppet puppet':
        cwd     =>  '/Library/Ruby/Site',
        creates =>  '/Library/Ruby/Site/puppet'
    }
    exec { '/bin/ln -s 1.8/puppet.rb puppet.rb':
        cwd     =>  '/Library/Ruby/Site',
        creates =>  '/Library/Ruby/Site/puppet.rb'
    }
    exec { '/bin/ln -s 1.8/semver.rb semver.rb':
        cwd     =>  '/Library/Ruby/Site',
        creates =>  '/Library/Ruby/Site/semver.rb'
    }
...and so on
}

But after Mavericks update symlinks to directories have disappeared and puppet is again broken :-/

Current plan (which seem to work so far) is to let puppet put in place LaunchDaemon which executes script in every boot. 10.7 -> 10.9 upgrade is tested to be working, just keeping fingers crossed that we don’t hit other known bugs

Script here:

#!/bin/sh
#
# Fixes puppet links for Mavericks update
#
FILES="facter facter.rb puppet puppet.rb puppetx puppetx.rb hiera hiera_puppet.rb semver.rb"
#
cd /Library/Ruby/Site || exit
for file in $FILES; do
    ln -s 1.8/"$file" "$file" || :
done
# Keep launchd happy
sleep 15
exit 0

And plist to /Library/LaunchDaemons/

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>EnvironmentVariables</key>
    <dict>
        <key>PATH</key>
        <string>/sbin:/usr/sbin:/bin:/usr/bin</string>
    </dict>
    <key>Label</key>
    <string>local.my.puppet.link.fixxer</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/fixmavpuppet.sh</string>
    </array>
    <key>StandardErrorPath</key>
    <string>/dev/null</string>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

Edit 2014-02-11: Bugs are fixed with puppet 3.4.1 and facter 1.7.5

Leave a Reply

Your email address will not be published. Required fields are marked *