Skip to content

Instantly share code, notes, and snippets.

View johnfitzpatrick's full-sized avatar

John Fitzpatrick johnfitzpatrick

  • Kong
  • Belfast, Northern Ireland
View GitHub Profile
#
# Cookbook Name:: apache
# Recipe:: default
#
# Copyright 2013, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
package "httpd" do
<html>
<body>
<h1>Welcome to <%= node["motd"]["company"] %></h1>
<h2>We love <%= @site_name %></h2>
<%= node["ipaddress"] %>:<%= @port %>
</body>
</html>
<% if @port != 80 -%>
Listen <%= @port %>
<% end -%>
<VirtualHost *:<%= @port %>>
ServerAdmin webmaster@localhost
DocumentRoot <%= @document_root %>
<Directory />
Options FollowSymLinks
powershell_script "Install IIS" do
code "add-windowsfeature Web-Server"
action :run
end
service "w3svc" do
action [:enable, :start ]
end
#node.default["iis_demo"]["indexfile"] = "Default2.htm"
<html>
<body>
<h1>Hello, <%= node['iis_demo']['greeting'] %>!</h1>
<h2>This is server <%= node['hostname']%></h2>
<h3>Do you know the capitals of the following countries?</h3>
<% @country.each do |item| -%>
<p><a href=<%="#{item}"%>.htm><%="#{item}"%></a></p>
<% end -%>
</body>
</html>
#
# Cookbook Name:: iis_demo
# Recipe:: default
#
# Copyright 2014, Chef Workshops, Inc.
#
# All rights reserved - Do Not Redistribute
#
powershell_script "Install IIS" do
code "add-windowsfeature Web-Server"
@johnfitzpatrick
johnfitzpatrick / apache_files_default_plugins_modules.rb
Created May 14, 2014 10:16
Ohai module refactor in Chef Intermediate class
Ohai.plugin(:Apache) do
provides "apache/modules"
collect_data(:default) do
apache Mash.new
apache[:modules] = {:static => [], :shared => []}
modules = shell_out("apachectl -t -D DUMP_MODULES")
modules.stdout.each_line do |line|
fullkey, value = line.split(/\(/, 2).map {|i| i.strip}
apache_mod = fullkey.gsub(/_module/,"")
@johnfitzpatrick
johnfitzpatrick / cookbooks_email_handler_recipes_default.rb
Last active August 29, 2015 14:01
Handler recipe for Chef Intermediate class
chef_gem "pony" do
action :install
end
include_recipe "chef_handler"
cookbook_file "#{node['chef_handler']['handler_path']}/email_handler.rb" do
source "handlers/email_handler.rb"
owner "root"
group "root"
require 'rubygems'
require 'pony'
module MyCompany
class EmailMe < Chef::Handler
def initialize(from_address, to_address)
@from_address = from_address
@to_address = to_address
end
@johnfitzpatrick
johnfitzpatrick / cookbooks_apache_providers_vhost.rb
Created May 21, 2014 09:37
cookbooks/apache/providers/vhost.rb
use_inline_resources
action :create do
# Set the document root
document_root = "/srv/apache/#{new_resource.site_name}"
# Add a template for Apache virtual host configuration
template "/etc/httpd/conf.d/#{new_resource.site_name}.conf" do
source "custom.erb"
mode "0644"