Last active
September 16, 2015 21:04
-
-
Save burtlo/ce00756479101bb5fdac to your computer and use it in GitHub Desktop.
Code Samples from the Online Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name "win-production" | |
description "For Prods!" | |
cookbook "iis_demo", "= 0.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name "windows-dev" | |
description "For developers!" | |
cookbook "iis_demo", "= 0.2.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Cookbook Name:: iis_demo | |
# Recipe:: default | |
# | |
# Copyright 2015, YOUR_COMPANY_NAME | |
# | |
# All rights reserved - Do Not Redistribute | |
# | |
powershell_script 'Intall IIS' do | |
code 'add-windowsfeature Web-Server' | |
action :run | |
end | |
service 'w3svc' do | |
action [ :enable, :start ] | |
end | |
powershell_script "Disable Default Site" do | |
code 'get-website "Default Web Site*" | where {$_.state -ne "Stopped"} | Stop-Website' | |
end | |
node["iis_demo"]["sites"].each do |site_name, site_data| | |
site_dir = "#{ENV['SYSTEMDRIVE']}\\inetpub\\wwwroot\\#{site_name}" | |
directory site_dir | |
powershell_script "create app pool for #{site_name}" do | |
code "New-WebAppPool #{site_name}" | |
not_if "C:\\Windows\\System32\\inetsrv\\appcmd.exe list appPool #{site_name}" | |
end | |
powershell_script "new website for #{site_name}" do | |
code <<-PINEAPPLE | |
Import-Module WebAdministration | |
if(-not(test-path IIS:\\Sites\\#{site_name})) { | |
New-WebSite -name #{site_name} -Port #{site_data["port"]} -PhysicalPath #{site_dir} -ApplicationPool #{site_name} | |
} | |
PINEAPPLE | |
end | |
template "#{site_dir}\\Default.htm" do | |
source "Default.htm.erb" | |
rights :read, "Everyone" | |
variables( | |
:site_name => site_name, | |
:port => site_data["port"] | |
) | |
notifies :restart, "service[w3svc]" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<h2>We love <%= @site_name %></h2> | |
<h2><%= node["ipaddress"] %>:<%= @port %></h2> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name "core" | |
description "Core (Base) Linux role" | |
run_list "recipe[del_val]", "recipe[motd]", "recipe[users::create-users]", "recipe[ip-logger]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name 'lin-webhead' | |
description 'Apache Web Server' | |
run_list "role[core]", "recipe[apache]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name "win-webhead" | |
description "IIS Web Server" | |
run_list "recipe[iis_demo]" | |
default_attributes({ | |
"iis_demo" => { | |
"sites" => { | |
"admins" => { | |
"port" => 8000 | |
} | |
} | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
search("groups", "*:*").each do |group_data| | |
group group_data["id"] do | |
gid group_data["gid"] | |
members group_data["members"] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
search("users", "platform:centos").each do |user_data| | |
user user_data["id"] do | |
comment user_data["comment"] | |
uid user_data["uid"] | |
gid user_data["gid"] | |
home user_data["home"] | |
shell user_data["shell"] | |
end | |
end | |
include_recipe "users::create-groups" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment