Skip to content

Instantly share code, notes, and snippets.

@lamanotrama
Created June 17, 2014 07:02
Show Gist options
  • Save lamanotrama/1b721b2790cbabd7dc06 to your computer and use it in GitHub Desktop.
Save lamanotrama/1b721b2790cbabd7dc06 to your computer and use it in GitHub Desktop.
serverspecでfactsを使う
class Hash
def symbolize_keys
self.each_with_object({}){|(k,v),memo| memo[k.to_s.to_sym]=v}
end
end
facter_lib = ENV['SERVERSPEC_ENV'] == 'development' ?
'/vagrant/modules/heteml/lib' : '/usr/lib/puppuet/lib'
facts = backend.run_command(
%|FACTERLIB=#{facter_lib} /usr/bin/ruby -r facter -e 'p Facter.to_hash'|
).stdout
property = eval(facts).symbolize_keys
set_property property
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment