Here is an example of a working recipe that loops through an array of website names and creates them in IIS using the function createIisWebsite().
def createIisWebsite(websiteName)
iis_site websiteName do
protocol :http
port 80
path "#{node['iis']['docroot']}/#{websiteName}"
host_header "#{websiteName}.test.kermit.a-aws.co.uk"
action [:add,:start]
end
end
In our actual solution this data is stored elsewhere and accessed via a web API.
websiteNames = ["website-2", "website-3", "website-4"]
for websiteName in websiteNames do
createIisWebsite websiteName
end
Now I want to be able to call the function createIisWebsite() from multiple recipes within this Cookbook.
I have tried throwing it into a helper module (library). There I cannot get the reference to iis_site to work.
I have tried moving the function to default.rb
and then doing include_recipe "::default". That does not seem to work either.
I get a "Cannot find a resource for createIisWebsite on windows version 6.2.9200"
The reason I am taking this approach is because I want to have a recipe containing the list of websites per cluster of web servers. I get the feeling I am not taking the best practice route.
Any ideas?