ruby

Checking file permissions with Ruby

I just noticed today you can easily check file permissions by selecting the appropriate bits using an array format with a range. For example, if I want to make sure that the permissions of /etc/sudoers is 440, I could do the following: File.stat("/etc/sudoers").mode.to_s(8)[3..5] == "440" So, you’re converting the mode to octal format and then selecting characters 3 thur 5. Characters start at 0 from the left side of the string.

New Ohai Plugin for Linux VServer

Today I posted my first Ohai plugin to Github and put a link on the Opscode Community Plugins wiki page. I know not a whole lot of people useVServer, but hopefully some will find it useful. :) #opschef

Installing RubyGems on Centos 5

This should apply to RHEL5 as well, but I haven’t verified yet. The easiest solution I’ve found is to simply install Ruby and it’s dependencies and then install RubyGems from source. I’ve written a small script which installs Ruby and it’s dependencies. It then grabs the RubyGems source tarball and installs Gems from source. As I wrote this to get a working Chef install, it also adds an opscode gems source.