Merb could not be reached"
18 |
--------------------------------------------------------------------------------
/features/data/config/client.rb:
--------------------------------------------------------------------------------
1 | supportdir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
2 | tmpdir = File.expand_path(File.join(File.dirname(__FILE__), "..", "tmp"))
3 |
4 | log_level :error
5 | log_location STDOUT
6 | file_cache_path File.join(tmpdir, "cache")
7 | ssl_verify_mode :verify_none
8 | registration_url "http://127.0.0.1:4000"
9 | openid_url "http://127.0.0.1:4001"
10 | template_url "http://127.0.0.1:4000"
11 | remotefile_url "http://127.0.0.1:4000"
12 | search_url "http://127.0.0.1:4000"
13 | role_url "http://127.0.0.1:4000"
14 | couchdb_database 'chef_integration'
15 |
--------------------------------------------------------------------------------
/chef-server-slice/lib/chef-server-slice/slicetasks.rb:
--------------------------------------------------------------------------------
1 | namespace :slices do
2 | namespace :chefserverslice do
3 |
4 | # add your own chefserver tasks here
5 |
6 | # # Uncomment the following lines and edit the pre defined tasks
7 | #
8 | # # implement this to test for structural/code dependencies
9 | # # like certain directories or availability of other files
10 | # desc "Test for any dependencies"
11 | # task :preflight do
12 | # end
13 | #
14 | # # implement this to perform any database related setup steps
15 | # desc "Migrate the database"
16 | # task :migrate do
17 | # end
18 |
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/chef-server/config.ru:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 | require 'merb-core'
3 | require 'chef'
4 |
5 | Chef::Config.from_file(File.join("/etc", "chef", "server.rb"))
6 |
7 | Merb::Config.setup(:merb_root => File.expand_path(File.dirname(__FILE__)),
8 | :environment => ENV['RACK_ENV'], :init_file => File.dirname(__FILE__) / "config/init.rb")
9 | Merb.environment = Merb::Config[:environment]
10 | Merb.root = Merb::Config[:merb_root]
11 | Merb::BootLoader.run
12 |
13 | # Uncomment if your app is mounted at a suburi
14 | #if prefix = ::Merb::Config[:path_prefix]
15 | # use Merb::Rack::PathPrefix, prefix
16 | #end
17 |
18 | run Merb::Rack::Application.new
19 |
20 |
--------------------------------------------------------------------------------
/chef-server/config/dependencies.rb:
--------------------------------------------------------------------------------
1 | # dependencies are generated using a strict version, don't forget to edit the dependency versions when upgrading.
2 | merb_gems_version = "> 1.0"
3 |
4 | # For more information about each component, please read http://wiki.merbivore.com/faqs/merb_components
5 | dependency "merb-core", merb_gems_version
6 | dependency "merb-assets", merb_gems_version
7 | dependency "merb-helpers", merb_gems_version
8 | dependency "merb-slices", merb_gems_version
9 | if defined?(CHEF_SERVER_VERSION)
10 | dependency "chef-server-slice", CHEF_SERVER_VERSION unless defined?(ChefServerSlice)
11 | else
12 | dependency "chef-server-slice" unless defined?(ChefServerSlice)
13 | end
14 |
--------------------------------------------------------------------------------
/chef-server-slice/app/views/roles/_navigation.html.haml:
--------------------------------------------------------------------------------
1 | .secondary-navigation
2 | %ul
3 | %li{ :class => "first #{active == 'index' ? "active" : ''}"}= link_to('List', slice_url(:roles))
4 | %li{ :class => (active == 'create' ? "active" : '')}= link_to('Create', slice_url(:new_role))
5 | - if active != 'create' && active != 'index'
6 | %li{ :class => (active == 'show' ? "active" : '')}= link_to('Show', slice_url(:role, @role.name))
7 | %li{ :class => (active == 'edit' ? "active" : '')}= link_to('Edit', slice_url(:edit_role, @role.name))
8 | %li= link_to('Delete', slice_url(:role, @role.name), :method => "delete", :confirm => "Really delete Role #{@role.name}? There is no undo.")
9 | .clear
10 |
--------------------------------------------------------------------------------
/features/data/cookbooks/synchronize_deps/metadata.json:
--------------------------------------------------------------------------------
1 | {
2 | "maintainer_email": "youremail@example.com",
3 | "recipes": {
4 | "synchronize_deps": ""
5 | },
6 | "suggestions": {
7 |
8 | },
9 | "license": "Apache v2.0",
10 | "conflicting": {
11 |
12 | },
13 | "dependencies": {
14 | "synchronize": [
15 |
16 | ]
17 | },
18 | "attributes": {
19 |
20 | },
21 | "name": "synchronize_deps",
22 | "providing": {
23 | "synchronize_deps": [
24 |
25 | ]
26 | },
27 | "replacing": {
28 |
29 | },
30 | "long_description": "",
31 | "description": "A fabulous new cookbook",
32 | "maintainer": "Your Name",
33 | "recommendations": {
34 |
35 | },
36 | "platforms": {
37 |
38 | }
39 | }
--------------------------------------------------------------------------------
/features/steps/packages.rb:
--------------------------------------------------------------------------------
1 | Given /^that I have the (.+) package system installed$/ do |package_system|
2 | unless package_system_available?(package_system)
3 | pending "This Cucumber feature will not execute, as it is missing the #{package_system} packaging system."
4 | end
5 | end
6 |
7 | Then /^there should be a binary on the path called '(.+)'$/ do |binary_name|
8 | binary_name.strip!
9 | result = `which #{binary_name}`
10 | result.should_not =~ /not found/
11 | end
12 |
13 | Then /^there should not be a binary on the path called '(.+)'$/ do |binary_name|
14 | binary_name.strip!
15 | result = `which #{binary_name}`.strip
16 |
17 | unless result.empty?
18 | result.should =~ /not found/
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/features/data/cookbooks/roles/recipes/default.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: roles
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
--------------------------------------------------------------------------------
/chef/config/server.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Example Chef Server Config
3 |
4 | log_level :debug
5 |
6 | cookbook_path File.join(File.dirname(__FILE__), "..", "examples", "config", "cookbooks")
7 | node_path File.join(File.dirname(__FILE__), "..", "examples", "config", "nodes")
8 | file_store_path File.join(File.dirname(__FILE__), "..", "examples", "store")
9 | openid_store_path File.join(File.dirname(__FILE__), "..", "examples", "openid-db")
10 | openid_cstore_path File.join(File.dirname(__FILE__), "..", "examples", "openid-cstore")
11 | search_index_path File.join(File.dirname(__FILE__), "..", "examples", "search_index")
12 |
13 | # openid_providers [ "localhost:4001", "openid.hjksolutions.com" ]
14 |
15 | Chef::Log::Formatter.show_time = false
16 |
--------------------------------------------------------------------------------
/features/data/cookbooks/metadata/recipes/default.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: metadata
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
--------------------------------------------------------------------------------
/features/data/cookbooks/search/recipes/default.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: search
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
--------------------------------------------------------------------------------
/features/data/cookbooks/manage_files/recipes/default.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: files
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 |
--------------------------------------------------------------------------------
/features/data/cookbooks/run_interval/recipes/default.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: run_interval
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
--------------------------------------------------------------------------------
/features/data/cookbooks/synchronize/recipes/default.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: synchronize
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
--------------------------------------------------------------------------------
/features/data/cookbooks/directory_provider/recipes/default.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: directory_provider
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
--------------------------------------------------------------------------------
/features/data/cookbooks/synchronize_deps/recipes/default.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: synchronize_deps
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
--------------------------------------------------------------------------------
/chef/examples/user_index.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | #
3 | # Create a users index, based on /etc/passwd
4 |
5 | require 'etc'
6 | require File.join(File.dirname(__FILE__), "..", "lib", "chef")
7 |
8 | Chef::Config[:log_level] = :info
9 | r = Chef::REST.new("http://localhost:4000")
10 |
11 | users = Array.new
12 | Etc.passwd do |passwd|
13 | Chef::Log.info("Ensuring we have #{passwd.name}")
14 | r.post_rest("search/user/entries",
15 | {
16 | :id => passwd.name,
17 | :name => passwd.name,
18 | :uid => passwd.uid,
19 | :gid => passwd.gid,
20 | :gecos => passwd.gecos,
21 | :dir => passwd.dir,
22 | :shell => passwd.shell,
23 | :change => passwd.change,
24 | :expire => passwd.expire
25 | }
26 | )
27 | end
28 |
--------------------------------------------------------------------------------
/chef-server-slice/app/views/nodes/_navigation.html.haml:
--------------------------------------------------------------------------------
1 | .secondary-navigation
2 | %ul
3 | %li{ :class => "first #{active == 'index' ? "active" : ''}"}= link_to('List', slice_url(:nodes))
4 | %li{ :class => (active == 'create' ? "active" : '')}= link_to('Create', slice_url(:new_node))
5 | - if active != 'create' && active != 'index'
6 | %li{ :class => (active == 'show' ? "active" : '')}= link_to('Show', slice_url(:node, escape_node_id(@node.name)))
7 | %li{ :class => (active == 'edit' ? "active" : '')}= link_to('Edit', slice_url(:edit_node, escape_node_id(@node.name)))
8 | %li= link_to('Delete', slice_url(:node, escape_node_id(@node.name)), :method => "delete", :confirm => "Really delete node #{@node.name}? There is no undo.")
9 | .clear
10 |
--------------------------------------------------------------------------------
/features/data/cookbooks/delayed_notifications/recipes/default.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: delayed_notifications
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
--------------------------------------------------------------------------------
/features/data/cookbooks/transfer_remote_files/recipes/default.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: transfer_remote_files
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
--------------------------------------------------------------------------------
/features/steps/request_steps.rb:
--------------------------------------------------------------------------------
1 | When /^I '(.+)' the path '(.+)'$/ do |http_method, request_uri|
2 | begin
3 | self.response = rest.send("#{http_method}_rest".downcase.to_sym, request_uri)
4 | self.inflated_response = self.response
5 | rescue
6 | self.exception = $!
7 | end
8 | end
9 |
10 | When /^I '(.+)' the '(.+)' to the path '(.+)'$/ do |http_method, stash_key, request_uri|
11 | begin
12 | self.response = rest.send("#{http_method}_rest".downcase.to_sym, request_uri, stash[stash_key])
13 | self.inflated_response = response
14 | rescue
15 | self.exception = $!
16 | end
17 | end
18 |
19 | When /^I authenticate as '(.+)'$/ do |reg|
20 | begin
21 | rest.authenticate(reg, 'tclown')
22 | rescue
23 | self.exception = $!
24 | end
25 | end
26 |
27 |
--------------------------------------------------------------------------------
/chef-server/config/rack.rb:
--------------------------------------------------------------------------------
1 | # use PathPrefix Middleware if :path_prefix is set in Merb::Config
2 | if prefix = ::Merb::Config[:path_prefix]
3 | use Merb::Rack::PathPrefix, prefix
4 | end
5 |
6 | # comment this out if you are running merb behind a load balancer
7 | # that serves static files
8 | use Merb::Rack::Static, Merb.dir_for(:public)
9 |
10 | Merb::Slices.config.each do |slice_module, config|
11 | slice_module = Object.full_const_get(slice_module.to_s.camel_case) if slice_module.class.in?(String, Symbol)
12 | slice_module.send("public_components").each do |component|
13 | slice_static_dir = slice_module.send("dir_for", :public)
14 | use Merb::Rack::Static, slice_static_dir
15 | end
16 | end
17 |
18 | # this is our main merb application
19 | run Merb::Rack::Application.new
20 |
--------------------------------------------------------------------------------
/chef/lib/chef/application/agent.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: AJ Christensen ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 |
18 | require 'chef/application'
--------------------------------------------------------------------------------
/chef/lib/chef/application/server.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: AJ Christensen ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 |
18 | require 'chef/application'
--------------------------------------------------------------------------------
/features/data/cookbooks/recipe_include/recipes/default.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: recipe_include
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | include_recipe "recipe_include::second"
21 |
22 |
--------------------------------------------------------------------------------
/features/data/cookbooks/manage_files/recipes/touch_a_file.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: files
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | file "#{node[:tmpdir]}/touch_test.txt" do
21 | action :touch
22 | end
--------------------------------------------------------------------------------
/features/data/cookbooks/manage_files/recipes/create_a_file.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: files
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | file "#{node[:tmpdir]}/create_a_file.txt" do
21 | action :create
22 | end
--------------------------------------------------------------------------------
/chef-server/contrib/el/chef-server.config:
--------------------------------------------------------------------------------
1 | #
2 | # Chef Server Config File
3 | #
4 |
5 | log_level :info
6 | ssl_verify_mode :verify_none
7 | registration_url "http://cserver:4000"
8 | openid_url "http://cserver:4001"
9 | template_url "http://cserver:4000"
10 | remotefile_url "http://cserver:4000"
11 | search_url "http://cserver:4000"
12 | cookbook_path [ "/var/lib/chef/site-cookbooks", "/var/lib/chef/cookbooks" ]
13 |
14 | merb_root "/var/lib/chef/merb"
15 | node_path "/etc/chef/node"
16 | file_store_path "/var/lib/chef/store"
17 | search_index_path "/var/lib/chef/search_index"
18 | openid_store_path "/var/lib/chef/openid/db"
19 | openid_cstore_path "/var/lib/chef/openid/cstore"
20 | file_cache_path "/var/lib/chef/cache"
21 |
22 | Chef::Log::Formatter.show_time = false
23 |
--------------------------------------------------------------------------------
/chef-server/public/merb.fcgi:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | require 'rubygems'
4 | require 'merb-core'
5 |
6 | # this is Merb.root, change this if you have some funky setup.
7 | merb_root = File.expand_path(File.dirname(__FILE__) / '../')
8 |
9 | # If the fcgi process runs as apache, make sure
10 | # we have an inlinedir set for Rubyinline action-args to work
11 | unless ENV["INLINEDIR"] || ENV["HOME"]
12 | tmpdir = merb_root / "tmp"
13 | unless File.directory?(tmpdir)
14 | Dir.mkdir(tmpdir)
15 | end
16 | ENV["INLINEDIR"] = tmpdir
17 | end
18 |
19 | # start merb with the fcgi adapter, add options or change the log dir here
20 | Merb.start(:adapter => 'fcgi',
21 | :merb_root => merb_root,
22 | :log_file => merb_root /'log'/'merb.log')
--------------------------------------------------------------------------------
/features/data/cookbooks/transfer_remote_files/recipes/transfer_a_file_from_a_specific_cookbook.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: transfer_remote_files
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | transfer_cookbook "from_definition.txt"
21 |
--------------------------------------------------------------------------------
/features/data/cookbooks/manage_files/recipes/delete_a_file_that_does_not_already_exist.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: files
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | file "#{node[:tmpdir]}/create_a_file.txt" do
21 | action :delete
22 | end
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | Chef NOTICE
2 | ===========
3 |
4 | Developed at Opscode (http://www.opscode.com).
5 |
6 | Contributors and Copyright holders:
7 |
8 | * Copyright 2008, Adam Jacob
9 | * Copyright 2008, Arjuna Christensen
10 | * Copyright 2008, Bryan McLellan
11 | * Copyright 2008, Ezra Zygmuntowicz
12 | * Copyright 2009, Sean Cribbs
13 | * Copyright 2009, Christopher Brown
14 | * Copyright 2009, Thom May
15 | * Copyright 2009, Joe Williams
16 |
17 | Chef incorporates code modified from Open4 (http://www.codeforpeople.com/lib/ruby/open4/), which was written by Ara T. Howard.
18 |
19 | Chef incorporates code modified from Merb (http://www.merbivore.com), which is Copyright (c) 2008 Engine Yard.
20 |
--------------------------------------------------------------------------------
/features/data/cookbooks/directory_provider/recipes/delete_nonexistent.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: directory_
3 | # Recipe:: delete_nonexistent
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | directory "#{node[:tmpdir]}/particles" do
21 | action :delete
22 | end
23 |
24 |
--------------------------------------------------------------------------------
/features/data/cookbooks/execute_commands/recipes/default.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: execute_commands
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | execute "create-mastodon" do
21 | command "echo wewt > #{node[:tmpdir]}/mastodon_rocks"
22 | end
23 |
--------------------------------------------------------------------------------
/features/data/cookbooks/manage_files/recipes/set_the_owner_of_a_created_file.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: files
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | file "#{node[:tmpdir]}/create_a_file.txt" do
21 | owner 'nobody'
22 | action :create
23 | end
--------------------------------------------------------------------------------
/features/data/cookbooks/execute_commands/recipes/umask.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: execute_commands
3 | # Recipe:: umask
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | execute "create-mastodon" do
21 | umask '777'
22 | command "echo wewt > /mastodon_rocks_umask"
23 | end
24 |
--------------------------------------------------------------------------------
/features/language/recipe_inclusion.feature:
--------------------------------------------------------------------------------
1 | @language @recipe_inclusion
2 | Feature: Recipe Inclusion
3 | In order to encapsulate functionality and re-use it
4 | As a developer
5 | I want to include a recipe from another one
6 |
7 | Scenario: Include a recipe directly
8 | Given a validated node
9 | And it includes the recipe 'recipe_include'
10 | When I run the chef-client
11 | Then the run should exit '0'
12 | And a file named 'fire_once' should contain 'mars_volta' only '1' time
13 |
14 | Scenario: Include a recipe multipe times
15 | Given a validated node
16 | And it includes the recipe 'recipe_include'
17 | And it includes the recipe 'recipe_include::second'
18 | When I run the chef-client
19 | Then the run should exit '0'
20 | And a file named 'fire_once' should contain 'mars_volta' only '1' time
21 |
22 |
--------------------------------------------------------------------------------
/chef-server-slice/app/views/nodes/_resource.html.haml:
--------------------------------------------------------------------------------
1 | .resource
2 | %h3= "#{h resource.to_s} (#{resource.class})"
3 | %table
4 | - resource.instance_variables.sort.each do |v|
5 | - attr_name = v.gsub(/\@/, "")
6 | - unless attr_name == "collection"
7 | %tr.attr_group
8 | %td.attr_name
9 | = "#{h attr_name}"
10 | %td.attr_value
11 | - value = resource.instance_variable_get(v)
12 | - if value.kind_of?(String)
13 | = "#{h value}"
14 | - elsif value.kind_of?(Array)
15 | = "#{h value.join(", ")}"
16 | - elsif value.kind_of?(Symbol)
17 | = "#{h value.to_s}"
18 | - elsif attr_name == "actions"
19 | = partial(:action, :actions => value)
20 | - else
21 | = "#{h value.inspect}"
22 |
23 |
--------------------------------------------------------------------------------
/features/data/cookbooks/integration_setup/recipes/default.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: integration_setup
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | directory node[:int][:tmpdir] do
21 | owner "root"
22 | mode 1777
23 | action :create
24 | end
25 |
26 |
--------------------------------------------------------------------------------
/features/provider/directory/delete_directories.feature:
--------------------------------------------------------------------------------
1 | Feature: Delete Directories
2 | In order to save time
3 | As a Developer
4 | I want to manage directories declaratively
5 |
6 | Scenario: Delete a directory
7 | Given a validated node
8 | And it includes the recipe 'directory_provider::delete'
9 | When I run the chef-client at log level 'info'
10 | Then the run should exit '0'
11 | And a directory named 'particles' should not exist
12 | And 'stdout' should have 'INFO: Deleting directory'
13 |
14 | Scenario: Delete a directory that already does not exist
15 | Given a validated node
16 | And it includes the recipe 'directory_provider::delete_nonexistent'
17 | When I run the chef-client at log level 'info'
18 | Then the run should exit '0'
19 | And 'stdout' should not have 'INFO: Deleting directory'
20 |
21 |
--------------------------------------------------------------------------------
/features/data/cookbooks/directory_provider/recipes/create.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: directory_provider
3 | # Recipe:: create
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | directory "#{node[:tmpdir]}/isis" do
21 | mode "755"
22 | owner "nobody"
23 | action :create
24 | end
25 |
26 |
--------------------------------------------------------------------------------
/features/data/cookbooks/manage_files/recipes/delete_a_file.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: files
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | include_recipe 'manage_files::create_a_file'
21 |
22 | file "#{node[:tmpdir]}/create_a_file.txt" do
23 | action :delete
24 | end
--------------------------------------------------------------------------------
/features/data/cookbooks/recipe_include/recipes/second.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: recipe_include
3 | # Recipe:: second
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | execute "append to #{node[:tmpdir]}/fire_once" do
21 | command "echo mars_volta >> #{node[:tmpdir]}/fire_once"
22 | end
23 |
24 |
--------------------------------------------------------------------------------
/features/steps/webrat_steps.rb:
--------------------------------------------------------------------------------
1 | # Commonly used webrat steps
2 | # http://github.com/brynary/webrat
3 |
4 | When /^I go to \/(.*)$/ do |path|
5 | visit path
6 | end
7 |
8 | When /^I press "(.*)"$/ do |button|
9 | click_button(button)
10 | end
11 |
12 | When /^I follow "(.*)"$/ do |link|
13 | click_link(link)
14 | end
15 |
16 | When /^I fill in "(.*)" with "(.*)"$/ do |field, value|
17 | fill_in(field, :with => value)
18 | end
19 |
20 | When /^I select "(.*)" from "(.*)"$/ do |value, field|
21 | select(value, :from => field)
22 | end
23 |
24 | When /^I check "(.*)"$/ do |field|
25 | check(field)
26 | end
27 |
28 | When /^I uncheck "(.*)"$/ do |field|
29 | uncheck(field)
30 | end
31 |
32 | When /^I choose "(.*)"$/ do |field|
33 | choose(field)
34 | end
35 |
36 | When /^I attach the file at "(.*)" to "(.*)" $/ do |path, field|
37 | attach_file(field, path)
38 | end
39 |
--------------------------------------------------------------------------------
/chef-server/tasks/merb.thor/utils.rb:
--------------------------------------------------------------------------------
1 | class String
2 | def /(other)
3 | (Pathname.new(self) + other).to_s
4 | end
5 | end
6 |
7 | module ColorfulMessages
8 |
9 | # red
10 | def error(*messages)
11 | puts messages.map { |msg| "\033[1;31m#{msg}\033[0m" }
12 | end
13 |
14 | # yellow
15 | def warning(*messages)
16 | puts messages.map { |msg| "\033[1;33m#{msg}\033[0m" }
17 | end
18 |
19 | # green
20 | def success(*messages)
21 | puts messages.map { |msg| "\033[1;32m#{msg}\033[0m" }
22 | end
23 |
24 | alias_method :message, :success
25 |
26 | # magenta
27 | def note(*messages)
28 | puts messages.map { |msg| "\033[1;35m#{msg}\033[0m" }
29 | end
30 |
31 | # blue
32 | def info(*messages)
33 | puts messages.map { |msg| "\033[1;34m#{msg}\033[0m" }
34 | end
35 |
36 | end
37 |
38 | module ThorUI
39 | extend ColorfulMessages
40 | end
41 |
--------------------------------------------------------------------------------
/features/data/cookbooks/integration_setup/attributes/integration.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: integration_setup
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | require 'tmpdir'
21 |
22 | int(Mash.new)
23 | int[:tmpdir] = File.join(Dir.tmpdir, "chef_integration")
24 |
25 | tmpdir int[:tmpdir]
--------------------------------------------------------------------------------
/features/data/cookbooks/transfer_remote_files/recipes/should_prefer_the_file_for_this_specific_host.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: transfer_remote_files
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | remote_file "#{node[:tmpdir]}/host_specific.txt" do
21 | source "host_specific.txt"
22 | end
--------------------------------------------------------------------------------
/chef-server-slice/app/views/roles/index.html.haml:
--------------------------------------------------------------------------------
1 | .block#block-tables
2 | .content
3 | %h2.title Roles
4 | .inner
5 | = partial('navigation', :active => 'index')
6 | .content
7 | .inner
8 | %table.table
9 | %tr
10 | %th.first Name
11 | %th Description
12 | %th.last
13 | - even = false;
14 | - @role_list.each do |role|
15 | %tr{ :class => even ? "even" : "odd" }
16 | %td= link_to(role.name, slice_url(:role, role.name))
17 | %td= role.description
18 | %td
19 | = link_to('Edit', slice_url(:edit_role, role.name))
20 | |
21 | = link_to('Delete', slice_url(:role, role.name), :method => "delete", :confirm => "Really delete Role #{role.name}? there is no undo.")
22 | - even ? even = false: even = true
23 |
--------------------------------------------------------------------------------
/features/data/cookbooks/execute_commands/recipes/debug.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | execute "debug-log" do
20 | command "ruby -e 'puts \"whats up\"; STDERR.puts \"doc!\"'"
21 | end
22 |
23 |
--------------------------------------------------------------------------------
/chef-server/lib/tasks/package.rake:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 | require 'rake/gempackagetask'
3 |
4 | spec = Gem::Specification.new do |s|
5 | s.name = GEM
6 | s.version = CHEF_SERVER_VERSION
7 | s.platform = Gem::Platform::RUBY
8 | s.has_rdoc = true
9 | s.extra_rdoc_files = ["README.rdoc", "LICENSE" ]
10 | s.summary = SUMMARY
11 | s.description = s.summary
12 | s.author = AUTHOR
13 | s.email = EMAIL
14 | s.homepage = HOMEPAGE
15 |
16 | %w{stomp stompserver ferret
17 | merb-core merb-haml merb-assets
18 | merb-helpers mongrel haml
19 | ruby-openid json syntax}.each { |gem| s.add_dependency gem }
20 |
21 | s.bindir = "bin"
22 | s.executables = %w( chef-server chef-indexer )
23 | s.files = %w(LICENSE README.rdoc) + Dir.glob("{app,bin,config,lib,public}/**/*")
24 | end
25 |
26 | Rake::GemPackageTask.new(spec) do |pkg|
27 | pkg.gem_spec = spec
28 | end
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/chef-server/tasks/merb.thor/app_script.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # This was added by Merb's bundler
4 |
5 | require "rubygems"
6 | require File.join(File.dirname(__FILE__), "common")
7 |
8 | gems_dir = File.join(File.dirname(__FILE__), '..', 'gems')
9 |
10 | if File.directory?(gems_dir)
11 | $BUNDLE = true
12 | Gem.clear_paths
13 | Gem.path.replace([File.expand_path(gems_dir)])
14 | ENV["PATH"] = "#{File.dirname(__FILE__)}:#{ENV["PATH"]}"
15 |
16 | gem_file = File.join(gems_dir, "specifications", "<%= spec.name %>-*.gemspec")
17 |
18 | if local_gem = Dir[gem_file].last
19 | version = File.basename(local_gem)[/-([\.\d]+)\.gemspec$/, 1]
20 | end
21 | end
22 |
23 | version ||= "<%= Gem::Requirement.default %>"
24 |
25 | if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
26 | version = $1
27 | ARGV.shift
28 | end
29 |
30 | gem '<%= @spec.name %>', version
31 | load '<%= bin_file_name %>'
--------------------------------------------------------------------------------
/features/data/cookbooks/transfer_remote_files/recipes/transfer_a_file_from_a_cookbook.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: transfer_remote_files
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | remote_file "#{node[:tmpdir]}/transfer_a_file_from_a_cookbook.txt" do
21 | source "transfer_a_file_from_a_cookbook.txt"
22 | end
--------------------------------------------------------------------------------
/chef-server-slice/app/helpers/status_helper.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Joe Williams (joe@joetify.com)
3 | # Copyright:: Copyright (c) 2009 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 | require 'chef' / 'node'
19 |
20 | module Merb
21 | module ChefServerSlice
22 | module StatusHelper
23 | end
24 |
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/chef-server-slice/app/views/roles/show.html.haml:
--------------------------------------------------------------------------------
1 | .block#block-tables
2 | .content
3 | %h2.title= "Role #{h @role.name}"
4 | .inner
5 | = partial("navigation", :active => "show")
6 | .content
7 | .inner
8 | .left
9 | %h3 Description
10 | = @role.description
11 |
12 | .left
13 | %h3 Recipes
14 | %table#recipes.table
15 | %tr
16 | %th.first Position
17 | %th.last Name
18 | - @role.recipes.each_index do |i|
19 | %tr
20 | %td.position= i
21 | %td= @role.recipes[i]
22 | .left
23 | %h3 Default Attributes
24 | = build_tree('defattrs', @role.default_attributes)
25 |
26 | .left
27 | %h3 Override Attributes
28 | = build_tree('overattrs', @role.override_attributes)
29 |
30 |
--------------------------------------------------------------------------------
/chef/spec/unit/log_spec.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | require 'tempfile'
20 | require 'logger'
21 | require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
22 |
23 | describe Chef::Log do
24 | end
--------------------------------------------------------------------------------
/features/data/cookbooks/search/recipes/search_data.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: search
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | node.save
21 | sleep 5
22 | search(:node, "*") do |entry|
23 | Chef::Log.error(entry.inspect)
24 | entry["search_files"].each do |filename|
25 | file "#{node[:tmpdir]}/#{filename}"
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/features/data/cookbooks/directory_provider/recipes/delete.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: directory_provider
3 | # Recipe:: delete
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | r = directory "#{node[:tmpdir]}/particles" do
21 | action :nothing
22 | end
23 | r.run_action(:create)
24 |
25 | directory "#{node[:tmpdir]}/particles" do
26 | action :delete
27 | end
28 |
29 |
30 |
--------------------------------------------------------------------------------
/features/data/cookbooks/transfer_remote_files/recipes/transfer_a_non-existent_file_from_a_cookbook.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: transfer_remote_files
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | remote_file "#{node[:tmpdir]}/transfer_a_non-existent_file_from_a_cookbook.txt" do
21 | source "transfer_a_non-existent_file_from_a_cookbook.txt"
22 | end
23 |
--------------------------------------------------------------------------------
/chef/bin/chef-client:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | #
3 | # ./chef-client - Run the chef client
4 | #
5 | # Author:: AJ Christensen ()
6 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
7 | # License:: Apache License, Version 2.0
8 | #
9 | # Licensed under the Apache License, Version 2.0 (the "License");
10 | # you may not use this file except in compliance with the License.
11 | # You may obtain a copy of the License at
12 | #
13 | # http://www.apache.org/licenses/LICENSE-2.0
14 | #
15 | # Unless required by applicable law or agreed to in writing, software
16 | # distributed under the License is distributed on an "AS IS" BASIS,
17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | # See the License for the specific language governing permissions and
19 | # limitations under the License.
20 |
21 | $: << File.join(File.dirname(__FILE__), "..", "lib")
22 |
23 | require 'rubygems'
24 | require 'chef/application/client'
25 |
26 | Chef::Application::Client.new.run
--------------------------------------------------------------------------------
/chef-server/bin/chef-indexer:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | #
3 | # ./chef-indexer - Run the chef indexer
4 | #
5 | # Author:: AJ Christensen ()
6 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
7 | # License:: Apache License, Version 2.0
8 | #
9 | # Licensed under the Apache License, Version 2.0 (the "License");
10 | # you may not use this file except in compliance with the License.
11 | # You may obtain a copy of the License at
12 | #
13 | # http://www.apache.org/licenses/LICENSE-2.0
14 | #
15 | # Unless required by applicable law or agreed to in writing, software
16 | # distributed under the License is distributed on an "AS IS" BASIS,
17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | # See the License for the specific language governing permissions and
19 | # limitations under the License.
20 |
21 | $: << File.join(File.dirname(__FILE__), "..", "lib")
22 |
23 | require 'rubygems'
24 | require 'chef/application/indexer'
25 |
26 | Chef::Application::Indexer.new.run
--------------------------------------------------------------------------------
/chef/spec/unit/chef_spec.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
20 |
21 | describe Chef do
22 | it "should have a version defined" do
23 | Chef::VERSION.should match(/(\d+)\.(\d+)\.(\d+)/)
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/features/data/config/server.rb:
--------------------------------------------------------------------------------
1 | supportdir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
2 | tmpdir = File.expand_path(File.join(File.dirname(__FILE__), "..", "tmp"))
3 |
4 | log_level :debug
5 | log_location STDOUT
6 | file_cache_path File.join(tmpdir, "cache")
7 | ssl_verify_mode :verify_none
8 | registration_url "http://127.0.0.1:4000"
9 | openid_url "http://127.0.0.1:4001"
10 | template_url "http://127.0.0.1:4000"
11 | remotefile_url "http://127.0.0.1:4000"
12 | search_url "http://127.0.0.1:4000"
13 | role_url "http://127.0.0.1:4000"
14 | cookbook_path File.join(supportdir, "cookbooks")
15 | openid_store_path File.join(tmpdir, "openid", "store")
16 | openid_cstore_path File.join(tmpdir, "openid", "cstore")
17 | search_index_path File.join(tmpdir, "search_index")
18 | role_path File.join(supportdir, "roles")
19 | validation_token 'ceelo'
20 | couchdb_database 'chef_integration'
21 |
22 | Chef::Log::Formatter.show_time = true
23 |
--------------------------------------------------------------------------------
/chef-server-slice/app/views/openid_server/decide.html.haml:
--------------------------------------------------------------------------------
1 | %form{:method => "post", :action => url(:openid_server_decision)}
2 | %table
3 | %tr
4 | %td Site:
5 | %td= @oidreq.trust_root
6 | - if @oidreq.id_select
7 | %tr
8 | %td{:colspan => "2"}
9 | You entered the server identifier at the relying party.
10 | You will need to send an identifier of your choosing.
11 | Enter a username and password below.
12 | %tr
13 | %td Identity to send:
14 | %td
15 | %input{:type => "text", :name => "id_to_send", :size => "25"}
16 | - else
17 | %tr
18 | %td Identity:
19 | %td= @oidreq.identity
20 | %tr
21 | %td
22 | %label{:for => "password"} Password:
23 | %td
24 | %input{:type => "password", :name => "password"}
25 | %input{:type => "submit", :name => "submit", :value => "Authenticate"}
26 | %input{:type => "submit", :name => "cancel", :value => "Cancel"}
27 |
28 |
--------------------------------------------------------------------------------
/chef-server/config/init.rb:
--------------------------------------------------------------------------------
1 | # Go to http://wiki.merbivore.com/pages/init-rb
2 |
3 | require 'config/dependencies.rb'
4 | unless defined?(Chef)
5 | gem "chef", "=" + CHEF_SERVER_VERSION if CHEF_SERVER_VERSION
6 | require 'chef'
7 | end
8 |
9 | use_test :rspec
10 | use_template_engine :haml
11 |
12 | Merb::Config.use do |c|
13 | c[:use_mutex] = false
14 | c[:session_id_key] = '_chef_server_session_id'
15 | c[:session_secret_key] = Chef::Config.manage_secret_key
16 | c[:session_store] = 'cookie'
17 | c[:exception_details] = true
18 | c[:reload_classes] = false
19 | c[:log_level] = Chef::Config[:log_level]
20 | c[:log_stream] = Chef::Config[:log_location]
21 | end
22 |
23 | Merb::BootLoader.before_app_loads do
24 | # This will get executed after dependencies have been loaded but before your app's classes have loaded.
25 | end
26 |
27 | Merb::BootLoader.after_app_loads do
28 | # This will get executed after your app's classes have been loaded.
29 | OpenID::Util.logger = Merb.logger
30 | end
31 |
--------------------------------------------------------------------------------
/chef/bin/chef-solo:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | #
3 | # ./chef-solo - Run the chef client, in stand-alone mode
4 | #
5 | # Author:: AJ Christensen ()
6 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
7 | # License:: Apache License, Version 2.0
8 | #
9 | # Licensed under the Apache License, Version 2.0 (the "License");
10 | # you may not use this file except in compliance with the License.
11 | # You may obtain a copy of the License at
12 | #
13 | # http://www.apache.org/licenses/LICENSE-2.0
14 | #
15 | # Unless required by applicable law or agreed to in writing, software
16 | # distributed under the License is distributed on an "AS IS" BASIS,
17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | # See the License for the specific language governing permissions and
19 | # limitations under the License.
20 |
21 | $: << File.join(File.dirname(__FILE__), "..", "lib")
22 |
23 | require 'rubygems'
24 | require 'chef/application/solo'
25 |
26 | Chef::Application::Solo.new.run
27 |
--------------------------------------------------------------------------------
/features/api/nodes/show_node_api.feature:
--------------------------------------------------------------------------------
1 | @api @nodes @nodes_show
2 | Feature: Show a node via the REST API
3 | In order to know what the details are for a node
4 | As a Developer
5 | I want to show the details for a specific node
6 |
7 | Scenario: Show a node
8 | Given a 'registration' named 'bobo' exists
9 | And a 'node' named 'webserver' exists
10 | When I authenticate as 'bobo'
11 | And I 'GET' the path '/nodes/webserver'
12 | Then the inflated response should respond to 'name' with 'webserver'
13 |
14 | Scenario: Show a missing node
15 | Given a 'registration' named 'bobo' exists
16 | And there are no nodes
17 | When I authenticate as 'bobo'
18 | And I 'GET' the path '/nodes/bobo'
19 | Then I should get a '404 "Not Found"' exception
20 |
21 | Scenario: Show a node without authenticating
22 | Given a 'node' named 'webserver' exists
23 | And I 'GET' the path '/nodes/webserver'
24 | Then I should get a '401 "Unauthorized"' exception
25 |
26 |
--------------------------------------------------------------------------------
/features/data/cookbooks/execute_commands/recipes/4k.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | execute "create-4k-file" do
20 | command "dd if=/dev/random of=#{node[:tmpdir]}/execute-4k.txt bs=1024 count=5"
21 | end
22 |
23 | execute "read-4k-file" do
24 | command "cat #{node[:tmpdir]}/execute-4k.txt"
25 | end
26 |
--------------------------------------------------------------------------------
/features/api/nodes/delete_node_api.feature:
--------------------------------------------------------------------------------
1 | @api @nodes @nodes_delete
2 | Feature: Delete a node via the REST API
3 | In order to remove a node
4 | As a Developer
5 | I want to delete a node via the REST API
6 |
7 | Scenario: Delete a node
8 | Given a 'registration' named 'bobo' exists
9 | And a 'node' named 'webserver' exists
10 | When I authenticate as 'bobo'
11 | And I 'DELETE' the path '/nodes/webserver'
12 | Then the inflated response should respond to 'name' with 'webserver'
13 |
14 | Scenario: Delete a node that does not exist
15 | Given a 'registration' named 'bobo' exists
16 | And there are no nodes
17 | When I authenticate as 'bobo'
18 | When I 'DELETE' the path '/nodes/webserver'
19 | Then I should get a '404 "Not Found"' exception
20 |
21 | Scenario: Delete a node without authenticating
22 | Given a 'node' named 'webserver'
23 | When I 'DELETE' the path '/nodes/webserver'
24 | Then I should get a '401 "Unauthorized"' exception
25 |
26 |
--------------------------------------------------------------------------------
/features/api/roles/delete_role_api.feature:
--------------------------------------------------------------------------------
1 | @api @roles @roles_delete
2 | Feature: Delete a Role via the REST API
3 | In order to remove a role
4 | As a Developer
5 | I want to delete a role via the REST API
6 |
7 | Scenario: Delete a Role
8 | Given a 'registration' named 'bobo' exists
9 | And a 'role' named 'webserver' exists
10 | When I authenticate as 'bobo'
11 | And I 'DELETE' the path '/roles/webserver'
12 | Then the inflated response should respond to 'name' with 'webserver'
13 |
14 | Scenario: Delete a Role that does not exist
15 | Given a 'registration' named 'bobo' exists
16 | And there are no roles
17 | When I authenticate as 'bobo'
18 | When I 'DELETE' the path '/roles/webserver'
19 | Then I should get a '404 "Not Found"' exception
20 |
21 | Scenario: Delete a Role without authenticating
22 | Given a 'role' named 'webserver'
23 | When I 'DELETE' the path '/roles/webserver'
24 | Then I should get a '401 "Unauthorized"' exception
25 |
26 |
--------------------------------------------------------------------------------
/features/api/roles/show_roles_api.feature:
--------------------------------------------------------------------------------
1 | @api @roles @roles_show
2 | Feature: Show a role via the REST API
3 | In order to know what the details are for a Role
4 | As a Developer
5 | I want to show the details for a specific Role
6 |
7 | Scenario: Show a role
8 | Given a 'registration' named 'bobo' exists
9 | And a 'role' named 'webserver' exists
10 | When I authenticate as 'bobo'
11 | And I 'GET' the path '/roles/webserver'
12 | Then the inflated response should respond to 'name' with 'webserver'
13 |
14 | Scenario: Show a missing role
15 | Given a 'registration' named 'bobo' exists
16 | And there are no roles
17 | When I authenticate as 'bobo'
18 | And I 'GET' the path '/roles/bobo'
19 | Then I should get a '404 "Not Found"' exception
20 |
21 | Scenario: Show a role without authenticating
22 | Given a 'role' named 'webserver' exists
23 | And I 'GET' the path '/roles/webserver'
24 | Then I should get a '401 "Unauthorized"' exception
25 |
26 |
27 |
--------------------------------------------------------------------------------
/chef-server-slice/app/helpers/openid_server_helpers.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | module Merb
20 | module ChefServerSlice
21 | module OpenidServerHelper
22 |
23 | def url_for_user
24 | url(:openid_node, :username => session[:username])
25 | end
26 |
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/chef-server/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | require "rubygems"
2 |
3 | # Add the local gems dir if found within the app root; any dependencies loaded
4 | # hereafter will try to load from the local gems before loading system gems.
5 | if (local_gem_dir = File.join(File.dirname(__FILE__), '..', 'gems')) && $BUNDLE.nil?
6 | $BUNDLE = true; Gem.clear_paths; Gem.path.unshift(local_gem_dir)
7 | end
8 |
9 | require "merb-core"
10 | require "spec" # Satisfies Autotest and anyone else not using the Rake tasks
11 |
12 | # this loads all plugins required in your init file so don't add them
13 | # here again, Merb will do it for you
14 | Merb.start_environment(:testing => true, :adapter => 'runner', :environment => ENV['MERB_ENV'] || 'test')
15 |
16 | Spec::Runner.configure do |config|
17 | config.include(Merb::Test::ViewHelper)
18 | config.include(Merb::Test::RouteHelper)
19 | config.include(Merb::Test::ControllerHelper)
20 |
21 | config.before(:all) do
22 | DataMapper.auto_migrate! if Merb.orm == :datamapper
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/chef-server-slice/app/helpers/search_helper.rb:
--------------------------------------------------------------------------------
1 | module Merb
2 | module ChefServerSlice
3 | module SearchHelper
4 | def output_path(attributes)
5 | res = Hash.new
6 | attributes.each do |path|
7 | parts = path.split("/")
8 | unless parts[0].nil?
9 | parts.shift if parts[0].length == 0
10 | end
11 | res[path] = ohai_walk(parts)
12 | end
13 | res
14 | end
15 |
16 | def ohai_walk(path)
17 | unless path[0]
18 | @@ohai.to_json
19 | else
20 | ohai_walk_r(@@ohai, path)
21 | end
22 | end
23 |
24 | def ohai_walk_r(ohai, path)
25 | hop = (ohai.is_a?(Array) ? path.shift.to_i : path.shift)
26 | if ohai[hop]
27 | if path[0]
28 | ohai_walk_r(ohai[hop], path)
29 | else
30 | ohai[hop].to_json
31 | end
32 | else
33 | nil
34 | end
35 | end
36 | end
37 | end
38 | end # Merb
39 |
--------------------------------------------------------------------------------
/features/data/cookbooks/delayed_notifications/recipes/notify_a_resource_from_a_single_source.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: delayed_notifications
3 | # Recipe:: notify_a_resource_from_a_single_source
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | file "#{node[:tmpdir]}/notified_file.txt" do
21 | action :nothing
22 | end
23 |
24 | execute "echo foo" do
25 | notifies :create, resources("file[#{node[:tmpdir]}/notified_file.txt]"), :delayed
26 | end
--------------------------------------------------------------------------------
/features/provider/package/macports.feature:
--------------------------------------------------------------------------------
1 | @provider @package @macports
2 | Feature: Macports integration
3 | In order to easily manage my OS X machines
4 | As a Developer
5 | I want to manage packages installed on OS X machines
6 |
7 | Scenario Outline: OS X package management
8 | Given that I have the MacPorts package system installed
9 | When I run chef-solo with the '' recipe
10 | Then the run should exit ''
11 | And there be a binary on the path called ''
12 |
13 | Examples:
14 | | recipe | binary | should | exitcode |
15 | | packages::macports_install_yydecode | yydecode | should | 0 |
16 | | packages::macports_remove_yydecode | yydecode | should not | 0 |
17 | | packages::macports_upgrade_yydecode | yydecode | should | 0 |
18 | | packages::macports_purge_yydecode | yydecode | should not | 0 |
19 | | packages::macports_install_bad_package | fdsafdsa | should not | 1 |
20 |
--------------------------------------------------------------------------------
/features/chef-client/cookbook_sync.feature:
--------------------------------------------------------------------------------
1 | @client
2 | Feature: Synchronize cookbooks from the server
3 | In order to configure a system according to a centralized repository
4 | As an Administrator
5 | I want to synchronize cookbooks to the edge nodes
6 |
7 | Scenario: Synchronize specific cookbooks
8 | Given a validated node
9 | And it includes the recipe 'synchronize'
10 | When I run the chef-client with '-l info'
11 | Then the run should exit '0'
12 | And 'stdout' should have 'INFO: Storing updated cookbooks/synchronize/recipes/default.rb in the cache.'
13 |
14 | Scenario: Synchronize dependent cookbooks
15 | Given a validated node
16 | And it includes the recipe 'synchronize_deps'
17 | When I run the chef-client with '-l info'
18 | Then the run should exit '0'
19 | And 'stdout' should have 'INFO: Storing updated cookbooks/synchronize_deps/recipes/default.rb in the cache.'
20 | And 'stdout' should have 'INFO: Storing updated cookbooks/synchronize/recipes/default.rb in the cache.'
21 |
22 |
--------------------------------------------------------------------------------
/features/cookbooks/metadata.feature:
--------------------------------------------------------------------------------
1 | @cookbooks
2 | Feature: Cookbook Metadata
3 | In order to understand cookbooks without evaluating them
4 | As an Administrator
5 | I want to automatically generate metadata about cookbooks
6 |
7 | Scenario: Generate metadata for all cookbooks
8 | Given a local cookbook repository
9 | When I run the rake task to generate cookbook metadata
10 | Then the run should exit '0'
11 | And 'stdout' should have 'Generating metadata for metadata'
12 | And 'stdout' should have 'Generating metadata for execute_commands'
13 | And a file named 'cookbooks_dir/cookbooks/metadata/metadata.json' should exist
14 |
15 | Scenario: Generate metadata for a specific cookbook
16 | Given a local cookbook repository
17 | When I run the rake task to generate cookbook metadata for 'metadata'
18 | Then the run should exit '0'
19 | And 'stdout' should have 'Generating metadata for metadata'
20 | And a file named 'cookbooks_dir/cookbooks/metadata/metadata.json' should exist
21 |
22 |
--------------------------------------------------------------------------------
/chef/spec/lib/chef/provider/easy.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | class Chef
20 | class Provider
21 | class Easy < Chef::Provider
22 | def load_current_resource
23 | true
24 | end
25 |
26 | def action_sell
27 | true
28 | end
29 |
30 | def action_buy
31 | true
32 | end
33 | end
34 | end
35 | end
36 |
--------------------------------------------------------------------------------
/chef/spec/lib/chef/provider/snakeoil.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | class Chef
20 | class Provider
21 | class SnakeOil < Chef::Provider
22 | def load_current_resource
23 | true
24 | end
25 |
26 | def action_sell
27 | true
28 | end
29 |
30 | def action_buy
31 | true
32 | end
33 | end
34 | end
35 | end
36 |
--------------------------------------------------------------------------------
/features/api/nodes/create_node_api.feature:
--------------------------------------------------------------------------------
1 | @api @nodes @nodes_create
2 | Feature: Create a node via the REST API
3 | In order to create nodes programatically
4 | As a Devleoper
5 | I want to create nodes via the REST API
6 |
7 | Scenario: Create a new node
8 | Given a 'registration' named 'bobo' exists
9 | And a 'node' named 'webserver'
10 | When I authenticate as 'bobo'
11 | And I 'POST' the 'node' to the path '/nodes'
12 | And the inflated responses key 'uri' should match '^http://.+/nodes/webserver$'
13 |
14 | Scenario: Create a node that already exists
15 | Given a 'registration' named 'bobo' exists
16 | And an 'node' named 'webserver'
17 | When I authenticate as 'bobo'
18 | And I 'POST' the 'node' to the path '/nodes'
19 | And I 'POST' the 'node' to the path '/nodes'
20 | Then I should get a '403 "Forbidden"' exception
21 |
22 | Scenario: Create a new node without authenticating
23 | Given a 'node' named 'webserver'
24 | When I 'POST' the 'node' to the path '/nodes'
25 | Then I should get a '401 "Unauthorized"' exception
26 |
--------------------------------------------------------------------------------
/features/api/roles/create_role_api.feature:
--------------------------------------------------------------------------------
1 | @api @roles @roles_create
2 | Feature: Create a role via the REST API
3 | In order to create roles programatically
4 | As a Devleoper
5 | I want to create roles via the REST API
6 |
7 | Scenario: Create a new role
8 | Given a 'registration' named 'bobo' exists
9 | And a 'role' named 'webserver'
10 | When I authenticate as 'bobo'
11 | And I 'POST' the 'role' to the path '/roles'
12 | And the inflated responses key 'uri' should match '^http://.+/roles/webserver$'
13 |
14 | Scenario: Create a role that already exists
15 | Given a 'registration' named 'bobo' exists
16 | And an 'role' named 'webserver'
17 | When I authenticate as 'bobo'
18 | And I 'POST' the 'role' to the path '/roles'
19 | And I 'POST' the 'role' to the path '/roles'
20 | Then I should get a '403 "Forbidden"' exception
21 |
22 | Scenario: Create a new role without authenticating
23 | Given a 'role' named 'webserver'
24 | When I 'POST' the 'role' to the path '/roles'
25 | Then I should get a '401 "Unauthorized"' exception
26 |
27 |
--------------------------------------------------------------------------------
/chef/lib/chef/resource/bash.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | require 'chef/resource/script'
20 |
21 | class Chef
22 | class Resource
23 | class Bash < Chef::Resource::Script
24 |
25 | def initialize(name, collection=nil, node=nil)
26 | super(name, collection, node)
27 | @resource_name = :bash
28 | @interpreter = "bash"
29 | end
30 |
31 | end
32 | end
33 | end
--------------------------------------------------------------------------------
/chef/lib/chef/resource/csh.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | require 'chef/resource/script'
20 |
21 | class Chef
22 | class Resource
23 | class Csh < Chef::Resource::Script
24 |
25 | def initialize(name, collection=nil, node=nil)
26 | super(name, collection, node)
27 | @resource_name = :csh
28 | @interpreter = "csh"
29 | end
30 |
31 | end
32 | end
33 | end
--------------------------------------------------------------------------------
/chef/lib/chef/resource/perl.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | require 'chef/resource/script'
20 |
21 | class Chef
22 | class Resource
23 | class Perl < Chef::Resource::Script
24 |
25 | def initialize(name, collection=nil, node=nil)
26 | super(name, collection, node)
27 | @resource_name = :perl
28 | @interpreter = "perl"
29 | end
30 |
31 | end
32 | end
33 | end
--------------------------------------------------------------------------------
/chef/lib/chef/resource/python.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | require 'chef/resource/script'
20 |
21 | class Chef
22 | class Resource
23 | class Python < Chef::Resource::Script
24 |
25 | def initialize(name, collection=nil, node=nil)
26 | super(name, collection, node)
27 | @resource_name = :python
28 | @interpreter = "python"
29 | end
30 |
31 | end
32 | end
33 | end
--------------------------------------------------------------------------------
/chef/lib/chef/resource/ruby.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | require 'chef/resource/script'
20 |
21 | class Chef
22 | class Resource
23 | class Ruby < Chef::Resource::Script
24 |
25 | def initialize(name, collection=nil, node=nil)
26 | super(name, collection, node)
27 | @resource_name = :ruby
28 | @interpreter = "ruby"
29 | end
30 |
31 | end
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/chef/lib/chef/resource/macports_package.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: David Balatero ()
3 | # Copyright:: Copyright (c) 2009 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | class Chef
20 | class Resource
21 | class MacportsPackage < Chef::Resource::Package
22 | def initialize(name, collection = nil, node = nil)
23 | super(name, collection, node)
24 | @resource_name = :macports_package
25 | @provider = Chef::Provider::Package::Macports
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/chef/lib/chef/mixin/checksum.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | require 'digest/sha2'
20 |
21 | class Chef
22 | module Mixin
23 | module Checksum
24 |
25 | def checksum(file)
26 | digest = Digest::SHA256.new
27 | fh = ::File.open(file)
28 | fh.each do |line|
29 | digest.update(line)
30 | end
31 | digest.hexdigest
32 | end
33 |
34 | end
35 | end
36 | end
--------------------------------------------------------------------------------
/chef/lib/chef/mixin/check_helper.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 |
18 | class Chef
19 | module Mixin
20 | module CheckHelper
21 | def set_if_args(thing, arguments)
22 | raise ArgumentError, "Must call set_if_args with a block!" unless Kernel.block_given?
23 | if arguments != nil
24 | yield(arguments)
25 | else
26 | thing
27 | end
28 | end
29 | end
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/features/data/cookbooks/delayed_notifications/recipes/notify_a_resource_from_multiple_sources.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: delayed_notifications
3 | # Recipe:: notify_a_resource_from_multiple_sources
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | execute "bob dylan" do
21 | command "echo 'bob dylan' >> #{node[:tmpdir]}/notified_file.txt"
22 | action :nothing
23 | end
24 |
25 | execute "echo foo" do
26 | notifies :run, resources("execute[bob dylan]"), :delayed
27 | end
28 |
29 | execute "echo bar" do
30 | notifies :run, resources("execute[bob dylan]"), :delayed
31 | end
32 |
--------------------------------------------------------------------------------
/chef-server-slice/app/views/nodes/index.html.haml:
--------------------------------------------------------------------------------
1 | .block#block-tables
2 | .content
3 | %h2.title Node List
4 | .inner
5 | = partial('navigation', :active => 'index')
6 | .content
7 | .inner
8 | %table.table
9 | %tr
10 | %th.first{:colspan => 2} Name
11 | %th
12 | %th.last
13 | - even = false
14 | - if @node_list.empty?
15 | %td{:colspan => 4}= "You appear to have no nodes - try connecting one, or validating an existing #{link_to('registration', slice_url(:registrations))}"
16 | - else
17 | - @node_list.each do |node|
18 | %tr{:class => even ? "even": "odd" }
19 | %td{:colspan => 2}= link_to node, slice_url(:node, { :id => escape_node_id(node) } )
20 | %td
21 | = link_to('Edit', slice_url(:edit_node, escape_node_id(node)))
22 | |
23 | = link_to('Delete', slice_url(:node, escape_node_id(node)), :method => "delete", :confirm => "Really delete Node #{node}? There is no undo.")
24 | - even ? even = false: even = true
25 |
26 |
--------------------------------------------------------------------------------
/features/steps/recipe_steps.rb:
--------------------------------------------------------------------------------
1 | Given /^the cookbook has a '(.+)' named '(.+)' in the '(.+)' specific directory$/ do |file_type, filename, specificity|
2 | cookbook_name, recipe_name = recipe.split('::')
3 | type_dir = file_type == 'file' ? 'files' : 'templates'
4 | specific_dir = nil
5 | case specificity
6 | when "host"
7 | specific_dir = "host-#{client.node[:fqdn]}"
8 | when "platform-version"
9 | specific_dir = "#{client.node[:platform]}-#{client.node[:platform_version]}"
10 | when "platform"
11 | specific_dir = client.node[:platform]
12 | when "default"
13 | specific_dir = "default"
14 | end
15 | new_file_dir = File.expand_path(
16 | File.join(
17 | File.dirname(__FILE__),
18 | "..",
19 | "data",
20 | "cookbooks",
21 | cookbook_name,
22 | type_dir,
23 | specific_dir
24 | )
25 | )
26 | cleanup_dirs << new_file_dir unless new_file_dir =~ /default$/
27 | system("mkdir -p #{new_file_dir}")
28 | new_file_name = File.join(new_file_dir, filename)
29 | cleanup_files << new_file_name
30 | new_file = File.open(new_file_name, "w")
31 | new_file.puts(specificity)
32 | new_file.close
33 | end
34 |
--------------------------------------------------------------------------------
/chef-server-slice/app/controllers/status.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Joe Williams (joe@joetify.com)
3 | # Copyright:: Copyright (c) 2009 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | require 'chef' / 'node'
20 |
21 | class ChefServerSlice::Status < ChefServerSlice::Application
22 |
23 | provides :html, :json
24 | before :login_required
25 |
26 | def index
27 | @status = Chef::CouchDB.new.get_view("nodes", "status")["rows"].inject([]) do |result, item|
28 | result << item["value"]
29 | result
30 | end
31 | display @status
32 | end
33 |
34 | end
35 |
--------------------------------------------------------------------------------
/chef/lib/chef/resource/portage_package.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | require 'chef/resource/package'
20 |
21 | class Chef
22 | class Resource
23 | class PortagePackage < Chef::Resource::Package
24 |
25 | def initialize(name, collection=nil, node=nil)
26 | super(name, collection, node)
27 | @resource_name = :portage_package
28 | @provider = Chef::Provider::Package::Portage
29 | end
30 |
31 | end
32 | end
33 | end
--------------------------------------------------------------------------------
/chef-server-slice/app/helpers/cookbooks_helper.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | module Merb
20 | module ChefServerSlice
21 | module CookbooksHelper
22 | def syntax_highlight(code)
23 | converter = Syntax::Convertors::HTML.for_syntax "ruby"
24 | if File.exists?(code)
25 | converter.convert(File.read(code), false)
26 | else
27 | converter.convert(code, false)
28 | end
29 | end
30 | end
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/chef/lib/chef/resource/apt_package.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | require 'chef/resource/package'
20 | require 'chef/provider/package/apt'
21 |
22 | class Chef
23 | class Resource
24 | class AptPackage < Chef::Resource::Package
25 |
26 | def initialize(name, collection=nil, node=nil)
27 | super(name, collection, node)
28 | @resource_name = :apt_package
29 | @provider = Chef::Provider::Package::Apt
30 | end
31 |
32 | end
33 | end
34 | end
--------------------------------------------------------------------------------
/chef/lib/chef/resource/dpkg_package.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | require 'chef/resource/package'
20 | require 'chef/provider/package/dpkg'
21 |
22 | class Chef
23 | class Resource
24 | class DpkgPackage < Chef::Resource::Package
25 |
26 | def initialize(name, collection=nil, node=nil)
27 | super(name, collection, node)
28 | @resource_name = :dpkg_package
29 | @provider = Chef::Provider::Package::Dpkg
30 | end
31 |
32 | end
33 | end
34 | end
--------------------------------------------------------------------------------
/chef-server-slice/app/controllers/exceptions.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Author:: Christopher Brown ()
4 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
5 | # License:: Apache License, Version 2.0
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | class ChefServerSlice::Exceptions < ChefServerSlice::Application
21 |
22 | provides :html, :json
23 |
24 | def standard_error
25 | Merb.logger.warn(request.content_type)
26 | if request.accept =~ /application\/json/
27 | display({ "error" => request.exceptions })
28 | else
29 | raise request.exceptions.first
30 | end
31 | end
32 |
33 | end
34 |
--------------------------------------------------------------------------------
/features/api/nodes/update_node_api.feature:
--------------------------------------------------------------------------------
1 | @api @nodes @nodes_update
2 | Feature: Update a node
3 | In order to keep my node data up-to-date
4 | As a Developer
5 | I want to update my node via the API
6 |
7 | Scenario Outline: Update a node
8 | Given a 'registration' named 'bobo' exists
9 | And a 'node' named 'webserver' exists
10 | And sending the method '' to the 'node' with ''
11 | When I authenticate as 'bobo'
12 | When I 'PUT' the 'node' to the path '/nodes/webserver'
13 | Then the inflated response should respond to '' with ''
14 | When I 'GET' the path '/nodes/webserver'
15 | Then the inflated response should respond to '' with ''
16 |
17 | Examples:
18 | | method | updated_value |
19 | | run_list | [ "recipe[one]", "recipe[two]" ] |
20 | | snakes | really arent so bad |
21 |
22 | Scenario: Update a node without authenticating
23 | Given a 'node' named 'webserver'
24 | And sending the method 'snakes' to the 'node' with 'night train'
25 | When I 'PUT' the 'node' to the path '/nodes/webserver'
26 | Then I should get a '401 "Unauthorized"' exception
27 |
28 |
--------------------------------------------------------------------------------
/features/data/cookbooks/delayed_notifications/recipes/notify_different_resources_for_different_actions.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: delayed_notifications
3 | # Recipe:: notify_different_resources_for_different_actions
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | file "#{node[:tmpdir]}/notified_file_2.txt" do
21 | action :nothing
22 | end
23 |
24 | file "#{node[:tmpdir]}/notified_file_3.txt" do
25 | action :nothing
26 | end
27 |
28 | execute "echo foo" do
29 | notifies([{resources("file[#{node[:tmpdir]}/notified_file_2.txt]") => [:create, :delayed]},
30 | {resources("file[#{node[:tmpdir]}/notified_file_3.txt]") => [:create, :delayed]}])
31 | end
32 |
--------------------------------------------------------------------------------
/features/steps/couchdb_steps.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | Before do
20 | system("mkdir -p #{tmpdir}")
21 | cdb = Chef::CouchDB.new(Chef::Config[:couchdb_url])
22 | cdb.create_db
23 | Chef::Node.create_design_document
24 | Chef::Role.create_design_document
25 | Chef::Role.sync_from_disk_to_couchdb
26 | Chef::OpenIDRegistration.create_design_document
27 | end
28 |
29 | After do
30 | r = Chef::REST.new(Chef::Config[:couchdb_url])
31 | r.delete_rest("#{Chef::Config[:couchdb_database]}/")
32 | system("rm -rf #{tmpdir}")
33 | end
34 |
--------------------------------------------------------------------------------
/chef/lib/chef/log.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Author:: AJ Christensen (<@aj@opsocde.com>)
4 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
5 | # License:: Apache License, Version 2.0
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 |
19 | require 'chef'
20 | require 'mixlib/log'
21 |
22 | class Chef
23 | class Log
24 | extend Mixlib::Log
25 |
26 | # This is here for compatability, before we moved to
27 | # Mixlib::Log.
28 | class Formatter
29 | def self.show_time=(arg)
30 | Mixlib::Log::Formatter.show_time = arg
31 | end
32 |
33 | def self.show_time
34 | Mixlib::Log::Formatter.show_time
35 | end
36 | end
37 | end
38 | end
39 |
40 |
--------------------------------------------------------------------------------
/features/data/Rakefile:
--------------------------------------------------------------------------------
1 | #
2 | # Rakefile for Chef Server Repository
3 | #
4 | # Author:: Adam Jacob ()
5 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
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 | $: << File.join(File.dirname(__FILE__), "..", "..", "chef", "lib")
22 |
23 | require 'rubygems'
24 | require 'chef'
25 | require 'json'
26 |
27 | # Make sure you have loaded constants first
28 | require File.join(File.dirname(__FILE__), 'config', 'rake')
29 |
30 | # And choosen a VCS
31 | if File.directory?(File.join(TOPDIR, ".svn"))
32 | $vcs = :svn
33 | elsif File.directory?(File.join(TOPDIR, ".git"))
34 | $vcs = :git
35 | end
36 |
37 | load 'chef/tasks/chef_repo.rake'
38 |
39 |
--------------------------------------------------------------------------------
/chef-server-slice/app/helpers/global_helpers.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | module Merb
20 | module ChefServerSlice
21 |
22 | module GlobalHelpers
23 | # helpers defined here available to all views.
24 | def resource_collection(collection)
25 | html = "
"
26 | collection.each do |resource|
27 | html << "
#{resource.class}
"
28 | end
29 | html << "
"
30 | html
31 | end
32 |
33 | def node_escape(node)
34 | node.gsub(/\./, '_')
35 | end
36 |
37 | end
38 | end
39 | end
40 |
--------------------------------------------------------------------------------
/features/data/cookbooks/transfer_remote_files/recipes/change_remote_file_perms_trickery.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Cookbook Name:: change_remote_file_perms_trickery
3 | # Recipe:: default
4 | #
5 | # Copyright 2009, Opscode
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | # The "trickery" comes from the fact that chef waits until all Resources are defined before actually
21 |
22 | r = remote_file "#{node[:tmpdir]}/transfer_a_file_from_a_cookbook.txt" do
23 | source "transfer_a_file_from_a_cookbook.txt"
24 | mode 0600
25 | action :nothing
26 | end
27 | # This creates the file out-of-band ()
28 | r.run_action(:create)
29 |
30 | remote_file "#{node[:tmpdir]}/transfer_a_file_from_a_cookbook.txt" do
31 | source "transfer_a_file_from_a_cookbook.txt"
32 | mode 0644
33 | end
34 |
--------------------------------------------------------------------------------
/features/api/roles/update_roles_api.feature:
--------------------------------------------------------------------------------
1 | @api @roles @roles_update
2 | Feature: Update a role
3 | In order to keep my role data up-to-date
4 | As a Developer
5 | I want to update my role via the API
6 |
7 | Scenario Outline: Update a role
8 | Given a 'registration' named 'bobo' exists
9 | And a 'role' named 'webserver' exists
10 | And sending the method '' to the 'role' with ''
11 | When I authenticate as 'bobo'
12 | When I 'PUT' the 'role' to the path '/roles/webserver'
13 | Then the inflated response should respond to '' with ''
14 | When I 'GET' the path '/roles/webserver'
15 | Then the inflated response should respond to '' with ''
16 |
17 | Examples:
18 | | method | updated_value |
19 | | description | gorilla |
20 | | recipes | [ "one", "two" ] |
21 | | default_attributes | { "a": "d" } |
22 | | override_attributes | { "c": "e" } |
23 |
24 | Scenario: Update a role without authenticating
25 | Given a 'role' named 'webserver'
26 | And sending the method 'description' to the 'role' with 'Is easy'
27 | When I 'PUT' the 'role' to the path '/roles/webserver'
28 | Then I should get a '401 "Unauthorized"' exception
29 |
30 |
--------------------------------------------------------------------------------
/features/language/delayed_notifications.feature:
--------------------------------------------------------------------------------
1 | Feature: Delayed Notifications
2 | In order to not impact the system we are configuring unduly
3 | As a developer
4 | I want to be able to trigger an action on a resource only at the end of a run
5 |
6 | Scenario: Notify a resource from a single source
7 | Given a validated node
8 | And it includes the recipe 'delayed_notifications::notify_a_resource_from_a_single_source'
9 | When I run the chef-client
10 | Then the run should exit '0'
11 | And a file named 'notified_file.txt' should exist
12 |
13 | Scenario: Notify a resource from multiple sources
14 | Given a validated node
15 | And it includes the recipe 'delayed_notifications::notify_a_resource_from_multiple_sources'
16 | When I run the chef-client
17 | Then the run should exit '0'
18 | And a file named 'notified_file.txt' should contain 'bob dylan' only '1' time
19 |
20 | Scenario: Notify different resources for different actions
21 | Given a validated node
22 | And it includes the recipe 'delayed_notifications::notify_different_resources_for_different_actions'
23 | When I run the chef-client
24 | Then the run should exit '0'
25 | And a file named 'notified_file_2.txt' should exist
26 | And a file named 'notified_file_3.txt' should exist
27 |
28 |
--------------------------------------------------------------------------------
/chef/lib/chef/mixin/deep_merge.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2009 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 |
18 | class Chef
19 | module Mixin
20 | class DeepMerge
21 | def self.merge(first, second)
22 | first = first.to_hash if first.kind_of?(Mash)
23 | second = second.to_hash if second.kind_of?(Mash)
24 | # Originally From: http://www.ruby-forum.com/topic/142809
25 | # Author: Stefan Rusterholz
26 | merger = proc do |key,v1,v2|
27 | v1.respond_to?(:keys) && v2.respond_to?(:keys) ? v1.merge(v2, &merger) : v2
28 | end
29 |
30 | Mash.new(first.merge(second, &merger))
31 | end
32 | end
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/chef/spec/lib/chef/resource/cat.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | class Chef
20 | class Resource
21 | class Cat < Chef::Resource
22 |
23 | attr_accessor :action
24 |
25 | def initialize(name, collection=nil, node=nil)
26 | @resource_name = :cat
27 | super(name, collection, node)
28 | @action = "sell"
29 | end
30 |
31 | def pretty_kitty(arg=nil)
32 | set_if_args(@pretty_kitty, arg) do
33 | case arg
34 | when true, false
35 | @pretty_kitty = arg
36 | end
37 | end
38 | end
39 | end
40 | end
41 | end
42 |
--------------------------------------------------------------------------------
/chef/lib/chef/provider.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | class Chef
20 | class Provider
21 |
22 | attr_accessor :node, :new_resource, :current_resource
23 |
24 | def initialize(node, new_resource)
25 | @node = node
26 | @new_resource = new_resource
27 | @current_resource = nil
28 | end
29 |
30 | def load_current_resource
31 | raise Chef::Exceptions::Override, "You must override load_current_resource in #{self.to_s}"
32 | end
33 |
34 | def action_nothing
35 | Chef::Log.debug("Doing nothing for #{@new_resource.to_s}")
36 | true
37 | end
38 |
39 | end
40 | end
41 |
--------------------------------------------------------------------------------
/chef/lib/chef/mixin/from_file.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
4 | # License:: Apache License, Version 2.0
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | class Chef
20 | module Mixin
21 | module FromFile
22 |
23 | # Loads a given ruby file, and runs instance_eval against it in the context of the current
24 | # object.
25 | #
26 | # Raises an IOError if the file cannot be found, or is not readable.
27 | def from_file(filename)
28 | if File.exists?(filename) && File.readable?(filename)
29 | self.instance_eval(IO.read(filename), filename, 1)
30 | else
31 | raise IOError, "Cannot open or read #{filename}!"
32 | end
33 | end
34 | end
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/chef-server-slice/app/helpers/nodes_helper.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Author:: Adam Jacob ()
3 | # Author:: AJ Christensen ()
4 | # Copyright:: Copyright (c) 2008 Opscode, Inc.
5 | # License:: Apache License, Version 2.0
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | module Merb
21 | module ChefServerSlice
22 | module NodesHelper
23 | def recipe_list(node)
24 | response = ""
25 | node.recipes.each do |recipe|
26 | response << "