Skip to content

Commit 4dbefb3

Browse files
committed
Adding example-repository
1 parent 8655ef1 commit 4dbefb3

29 files changed

Lines changed: 592 additions & 2 deletions

File tree

README.txt

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
= chef
2+
3+
* http://oss.hjksolutions.com/chef
4+
5+
== DESCRIPTION:
6+
7+
Chef is a configuration management tool.
8+
9+
I'm in ur netwerk, cookin up yer servers. :)
10+
11+
== FEATURES/PROBLEMS:
12+
13+
14+
== SYNOPSIS:
15+
16+
17+
== REQUIREMENTS:
18+
19+
RubyGems:
20+
21+
* stomp
22+
* stompserver
23+
* ultraviolet
24+
* facter
25+
* ferret
26+
* merb-core
27+
* haml
28+
* ruby-openid
29+
* json
30+
31+
External Servers:
32+
33+
* stompserver (for easy stomp mq testing)
34+
* CouchDB
35+
36+
== INSTALL:
37+
38+
Install all of the above. To fire up a develpment environment, do the following:
39+
40+
* Start CouchDB with 'couchdb'
41+
* Start stompserver with 'stompserver'
42+
* Start chef-indexer with:
43+
44+
chef-indexer -l debug
45+
46+
* Start chef-server:
47+
48+
chef-server -N -c 2
49+
50+
* Test run chef with:
51+
52+
chef-client -l debug
53+
54+
== LICENSE:
55+
56+
Chef - A configuration management system
57+
58+
Author:: Adam Jacob (<adam@hjksolutions.com>)
59+
Copyright:: Copyright (c) 2008 HJK Solutions, LLC
60+
License:: Apache License, Version 2.0
61+
62+
Licensed under the Apache License, Version 2.0 (the "License");
63+
you may not use this file except in compliance with the License.
64+
You may obtain a copy of the License at
65+
66+
http://www.apache.org/licenses/LICENSE-2.0
67+
68+
Unless required by applicable law or agreed to in writing, software
69+
distributed under the License is distributed on an "AS IS" BASIS,
70+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
71+
See the License for the specific language governing permissions and
72+
limitations under the License.
73+

Rakefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,13 @@ task :install do
1313
Dir.chdir(dir) { sh "rake install" }
1414
end
1515
end
16+
17+
namespace :dev do
18+
desc "Install a Devel instance of Chef with the example-repository"
19+
task :install do
20+
gems.each do |dir|
21+
Dir.chdir(dir) { sh "rake install" }
22+
end
23+
Dir.chdir("example-repository") { sh("rake install") }
24+
end
25+
end

chef-server/bin/chef-indexer

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require 'rubygems'
2424
require 'facter'
2525

2626
config = {
27-
:config_file => "/etc/chef/config.rb",
27+
:config_file => "/etc/chef/server.rb",
2828
:log_level => :info
2929
}
3030
opts = OptionParser.new do |opts|

chef-server/lib/init.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# limitations under the License.
1717
#
1818

19-
Merb.root = File.join(File.dirname(__FILE__))
19+
Merb.root = Chef::Config[:merb_root]
2020

2121
#
2222
# ==== Structure of Merb initializer
@@ -146,6 +146,7 @@
146146
c[:exception_details] = true
147147
c[:reload_classes] = true
148148
c[:log_level] = :debug
149+
c[:log_stream] = STDOUT
149150
end
150151

151152
Merb.logger.info("Compiling routes...")
0 Bytes
Binary file not shown.

chef/lib/chef/config.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class Config
3535

3636
@configuration = {
3737
:cookbook_path => [ "/etc/chef/site-cookbook", "/etc/chef/cookbook" ],
38+
:merb_root => "/var/chef/merb",
3839
:node_path => "/etc/chef/node",
3940
:file_store_path => "/var/chef/store",
4041
:search_index_path => "/var/chef/search_index",

chef/pkg/chef-0.0.1.gem

512 Bytes
Binary file not shown.

example-repository/Rakefile

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
#
2+
# Rakefile for Chef Server Repository
3+
#
4+
# Author:: Adam Jacob (<adam@hjksolutions.com>)
5+
# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
6+
# License:: Apache License, Version 2.0
7+
#
8+
# Licensed under the Apache License, Version 2.0 (the "License");
9+
# you may not use this file except in compliance with the License.
10+
# You may obtain a copy of the License at
11+
#
12+
# http://www.apache.org/licenses/LICENSE-2.0
13+
#
14+
# Unless required by applicable law or agreed to in writing, software
15+
# distributed under the License is distributed on an "AS IS" BASIS,
16+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
# See the License for the specific language governing permissions and
18+
# limitations under the License.
19+
#
20+
21+
require File.join(File.dirname(__FILE__), 'config', 'rake')
22+
23+
require 'tempfile'
24+
25+
$vcs = :svn
26+
if File.directory?(File.join(TOPDIR, ".svn"))
27+
$vcs = :svn
28+
elsif File.directory?(File.join(TOPDIR, ".git"))
29+
$vcs = :git
30+
end
31+
32+
desc "Update your repository from source control"
33+
task :update do
34+
puts "** Updating your repository"
35+
36+
case $vcs
37+
when :svn
38+
sh %{svn up}
39+
when :git
40+
pull = false
41+
pull = true if File.join(TOPDIR, ".git", "remotes", "origin")
42+
IO.foreach(File.join(TOPDIR, ".git", "config")) do |line|
43+
pull = true if line =~ /\[remote "origin"\]/
44+
end
45+
if pull
46+
sh %{git pull}
47+
else
48+
puts "* Skipping git pull, no origin specified"
49+
end
50+
end
51+
end
52+
53+
desc "Test your cookbooks for syntax errors"
54+
task :test do
55+
puts "** Testing your cookbooks for syntax errors"
56+
Dir[ File.join(TOPDIR, "cookbooks", "**", "*.rb") ].each do |recipe|
57+
sh %{ruby -c #{recipe}} do |ok, res|
58+
if ! ok
59+
raise "Syntax error in #{recipe}"
60+
end
61+
end
62+
end
63+
end
64+
65+
desc "Install the latest copy of the repository on this Chef Server"
66+
task :install => [ :update, :test ] do
67+
puts "** Installing your cookbooks"
68+
directories = [
69+
COOKBOOK_PATH,
70+
SITE_COOKBOOK_PATH,
71+
CHEF_CONFIG_PATH
72+
]
73+
puts "* Creating Directories"
74+
directories.each do |dir|
75+
sh "sudo mkdir -p #{dir}"
76+
sh "sudo chown root #{dir}"
77+
end
78+
puts "* Installing new Cookbooks"
79+
sh "sudo rsync -rlP --delete --exclude '.svn' cookbooks/ #{COOKBOOK_PATH}"
80+
puts "* Installing new Site Cookbooks"
81+
sh "sudo rsync -rlP --delete --exclude '.svn' cookbooks/ #{COOKBOOK_PATH}"
82+
puts "* Installing new Chef Server Config"
83+
sh "sudo cp config/server.rb #{CHEF_SERVER_CONFIG}"
84+
puts "* Installing new Chef Client Config"
85+
sh "sudo cp config/client.rb #{CHEF_CLIENT_CONFIG}"
86+
end
87+
88+
desc "By default, run rake test"
89+
task :default => [ :test ]
90+
91+
desc "Create a new cookbook (with COOKBOOK=name)"
92+
task :new_cookbook do
93+
create_cookbook(File.join(TOPDIR, "cookbooks"))
94+
end
95+
96+
def create_cookbook(dir)
97+
raise "Must provide a COOKBOOK=" unless ENV["COOKBOOK"]
98+
puts "** Creating cookbook #{ENV["COOKBOOK"]}"
99+
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "attributes")}"
100+
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "recipes")}"
101+
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "definitions")}"
102+
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "libraries")}"
103+
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "files", "default")}"
104+
sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "templates", "default")}"
105+
unless File.exists?(File.join(dir, ENV["COOKBOOK"], "recipes", "default.rb"))
106+
open(File.join(dir, ENV["COOKBOOK"], "recipes", "default.rb"), "w") do |file|
107+
file.puts <<-EOH
108+
#
109+
# Cookbook Name:: #{ENV["COOKBOOK"]}
110+
# Recipe:: default
111+
#
112+
# Copyright #{Time.now.year}, #{COMPANY_NAME}
113+
#
114+
EOH
115+
case NEW_COOKBOOK_LICENSE
116+
when :apachev2
117+
file.puts <<-EOH
118+
# Licensed under the Apache License, Version 2.0 (the "License");
119+
# you may not use this file except in compliance with the License.
120+
# You may obtain a copy of the License at
121+
#
122+
# http://www.apache.org/licenses/LICENSE-2.0
123+
#
124+
# Unless required by applicable law or agreed to in writing, software
125+
# distributed under the License is distributed on an "AS IS" BASIS,
126+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
127+
# See the License for the specific language governing permissions and
128+
# limitations under the License.
129+
#
130+
EOH
131+
when :none
132+
file.puts <<-EOH
133+
# All rights reserved - Do Not Redistribute
134+
#
135+
EOH
136+
end
137+
end
138+
end
139+
end
140+
141+
desc "Create a new self-signed SSL certificate for FQDN=foo.example.com"
142+
task :ssl_cert do
143+
$expect_verbose = true
144+
fqdn = ENV["FQDN"]
145+
fqdn =~ /^(.+?)\.(.+)$/
146+
hostname = $1
147+
domain = $2
148+
raise "Must provide FQDN!" unless fqdn && hostname && domain
149+
puts "** Creating self signed SSL Certificate for #{fqdn}"
150+
sh("(cd #{CADIR} && openssl genrsa 2048 > #{fqdn}.key)")
151+
sh("(cd #{CADIR} && chmod 644 #{fqdn}.key)")
152+
puts "* Generating Self Signed Certificate Request"
153+
tf = Tempfile.new("#{fqdn}.ssl-conf")
154+
ssl_config = <<EOH
155+
[ req ]
156+
distinguished_name = req_distinguished_name
157+
prompt = no
158+
159+
[ req_distinguished_name ]
160+
C = #{SSL_COUNTRY_NAME}
161+
ST = #{SSL_STATE_NAME}
162+
L = #{SSL_LOCALITY_NAME}
163+
O = #{COMPANY_NAME}
164+
OU = #{SSL_ORGANIZATIONAL_UNIT_NAME}
165+
CN = #{fqdn}
166+
emailAddress = #{SSL_EMAIL_ADDRESS}
167+
EOH
168+
tf.puts(ssl_config)
169+
tf.close
170+
sh("(cd #{CADIR} && openssl req -config '#{tf.path}' -new -x509 -nodes -sha1 -days 3650 -key #{fqdn}.key > #{fqdn}.crt)")
171+
sh("(cd #{CADIR} && openssl x509 -noout -fingerprint -text < #{fqdn}.crt > #{fqdn}.info)")
172+
sh("(cd #{CADIR} && cat #{fqdn}.crt #{fqdn}.key > #{fqdn}.pem)")
173+
sh("(cd #{CADIR} && chmod 644 #{fqdn}.pem)")
174+
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
# Cookbook Name:: chef
3+
# Attribute File:: client.rb
4+
#
5+
# Copyright 2008, Engine Yard, Inc.
6+
#
7+
# All rights reserved - Do Not Redistribute
8+
#
9+
10+
log_level :info
11+
log_location STDOUT
12+
file_store_path "/var/chef/file_store"
13+
file_cache_path "/var/chef/cache"
14+
ssl_verify_mode :verify_none
15+
registration_url "http://127.0.0.1:4000"
16+
openid_url "http://127.0.0.1:4001"
17+
template_url "http://127.0.0.1:4000"
18+
remotefile_url "http://127.0.0.1:4000"
19+
search_url "http://127.0.0.1:4000"
20+
21+

example-repository/config/rake.rb

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
###
2+
# Company and SSL Details
3+
###
4+
5+
# The company name - used for SSL certificates, and in various other places
6+
COMPANY_NAME = "Example Com"
7+
8+
# The Country Name to use for SSL Certificates
9+
SSL_COUNTRY_NAME = "US"
10+
11+
# The State Name to use for SSL Certificates
12+
SSL_STATE_NAME = "Washington"
13+
14+
# The Locality Name for SSL - typically, the city
15+
SSL_LOCALITY_NAME = "Seattle"
16+
17+
# What department?
18+
SSL_ORGANIZATIONAL_UNIT_NAME = "Operations"
19+
20+
# The SSL contact email address
21+
SSL_EMAIL_ADDRESS = "ops@example.com"
22+
23+
# License for new Cookbooks
24+
# Can be :apachev2 or :none
25+
NEW_COOKBOOK_LICENSE = :apachev2
26+
27+
##########################
28+
# Chef Repository Layout #
29+
##########################
30+
31+
# Where to find upstream cookbooks
32+
COOKBOOK_PATH = "/var/chef/cookbooks"
33+
34+
# Where to find site-local modifications to upstream cookbooks
35+
SITE_COOKBOOK_PATH = "/var/chef/site-cookbooks"
36+
37+
# Chef Config Path
38+
CHEF_CONFIG_PATH = "/etc/chef"
39+
40+
# The location of the Chef Server Config file (on the server)
41+
CHEF_SERVER_CONFIG = File.join(CHEF_CONFIG_PATH, "server.rb")
42+
43+
# The location of the Chef Client Config file (on the client)
44+
CHEF_CLIENT_CONFIG = File.join(CHEF_CONFIG_PATH, "client.rb")
45+
46+
###
47+
# Useful Extras (which you probably don't need to change)
48+
###
49+
50+
# The top of the repository checkout
51+
TOPDIR = File.expand_path(File.join(File.dirname(__FILE__), ".."))
52+
53+
# Where to store certificates generated with ssl_cert
54+
CADIR = File.expand_path(File.join(TOPDIR, "certificates"))

0 commit comments

Comments
 (0)