Skip to content

Instantly share code, notes, and snippets.

@vinyar
Created April 10, 2014 08:34
Show Gist options
  • Save vinyar/10356830 to your computer and use it in GitHub Desktop.
Save vinyar/10356830 to your computer and use it in GitHub Desktop.
Using knife search with Windows IIS
#
# Cookbook Name:: iis_demo
# Recipe:: default
#
# Copyright 2014, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
powershell_script "Install IIS" do
code "add-windowsfeature web-server"
action :run
end
service "w3svc" do
action [:enable, :start]
end
db = data_bag('countries')
template 'c:\inetpub\wwwroot\Default.htm' do
source "Default.htm.erb"
variables(
:country => db)
end
search("countries", "*:*").each do |db_item|
template "c:\\inetpub\\wwwroot\\#{db_item["country"]}.htm" do
source "countries.htm.erb"
variables(
:capital => db_item["capital"],
:country => db_item["country"]
)
end
end
# db.each do |item|
# country_data = data_bag_item("countries", item)
# countryname = country_data["country"]
# capitalname = country_data["capital"]
# # require 'pry'; binding.pry
# template "c:\\inetpub\\wwwroot\\#{countryname}.htm" do
# source "countries.htm.erb"
# variables(
# :capital => capitalname,
# :country => countryname
# )
# end
# end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment