- From: Curtis Stewart <
>
- To: "
" <
>
- Subject: [chef] include_recipe in library
- Date: Thu, 6 Feb 2014 15:57:24 +0000
- Accept-language: en-US
Is there anyway to add ‘include_recipe’ to a library method, then use that
method in both the recipe context as well as resource context?
An example of this is below.
class MyApp
# Recipe Helpers
module Helper
def license
if node['use_vault']
include_recipe 'chef-vault'
chef_vault_item(node['data_bag'], node['data_bag_item'])['license']
else
node[‘myapp’]['license']
end
end
end
end
Chef::Recipe.send(:include, MyApp::Helper)
Chef::Resource.send(:include, MyApp::Helper)
Works:
my_license = license
template ‘/etc/my.cfg’ do
variables(:license => my_license)
end
Doesn’t work:
template ‘/etc/my.cfg’ do
variables(:license => license)
end
[2014-02-06T15:49:13+00:00] ERROR: undefined method `include_recipe' for
Chef::Resource::Template
Thanks,
Curtis
- [chef] include_recipe in library, Curtis Stewart, 02/06/2014
Archive powered by MHonArc 2.6.16.