- From: Andrey Brindeyev <
>
- To:
- Subject: [chef] Writing a first library
- Date: Mon, 4 May 2015 10:49:26 -0700
Hi, everybody!
I'm trying to write my first library in Chef 11.18.0 (chef-solo) and using this article as an example:
However, this piece of code isn't working for me:
libraries/sensitives_helper.rb:
require 'chef/mixin/shell_out'
module SensitivesHelper
include Chef::Mixin::ShellOut
def self.retrieve_token(type, version)
Chef::Log.info "Retrieving sensitive for token #{type}, version #{version}"
cmd = shell_out!('/usr/local/bin/get-sensitives.sh', type, version)
Chef::Log.info "Retrieved sensitive token: #{cmd.stdout}"
cmd.stdout
end
end
Chef::Recipe.send(:include, SensitivesHelper)
When I try to use it in recipe, it's causing NoMethodError: undefined method `shell_out!' for SensitivesHelper:Module
Usage example:
user = ''
ruby_block "get sensitives" do
block do
user = SensitivesHelper.retrieve_token('a', 'b')
end
end
Any help is appreciated.
--
- [chef] Writing a first library, Andrey Brindeyev, 05/04/2015
Archive powered by MHonArc 2.6.16.