├── chef-server ├── spec │ ├── spec.opts │ └── spec_helper.rb ├── app │ ├── controllers │ │ ├── application.rb │ │ └── exceptions.rb │ ├── helpers │ │ └── global_helpers.rb │ └── views │ │ └── layout │ │ └── application.html.erb ├── autotest │ └── discover.rb ├── public │ ├── javascripts │ │ └── application.js │ ├── favicon.ico │ ├── images │ │ └── merb.jpg │ ├── robots.txt │ ├── .htaccess │ └── merb.fcgi ├── lib │ ├── views │ │ └── exceptions │ │ │ └── bad_request.html.haml │ └── tasks │ │ ├── uninstall.rake │ │ ├── install.rake │ │ └── package.rake ├── merb │ ├── session │ │ └── session.rb │ └── merb-auth │ │ ├── strategies.rb │ │ └── setup.rb ├── config │ ├── environments │ │ ├── production.rb │ │ ├── staging.rb │ │ ├── rake.rb │ │ ├── test.rb │ │ └── development.rb │ ├── dependencies.rb │ ├── rack.rb │ ├── init.rb │ └── router.rb ├── tasks │ └── merb.thor │ │ ├── utils.rb │ │ └── app_script.rb ├── Rakefile └── bin │ └── chef-server ├── chef ├── examples │ ├── mrepo │ │ └── Rakefile │ ├── search_index │ │ ├── segments │ │ └── segments_0 │ ├── config │ │ ├── cookbooks │ │ │ ├── tempfile │ │ │ │ ├── attributes │ │ │ │ │ └── second.rb │ │ │ │ └── recipes │ │ │ │ │ └── default.rb │ │ │ ├── fakefile │ │ │ │ ├── files │ │ │ │ │ └── default │ │ │ │ │ │ ├── remote_test │ │ │ │ │ │ ├── another │ │ │ │ │ │ │ ├── window.txt │ │ │ │ │ │ │ └── turn │ │ │ │ │ │ │ │ └── the_page.txt │ │ │ │ │ │ └── mycat.txt │ │ │ │ │ │ └── the_park.txt │ │ │ │ ├── attributes │ │ │ │ │ └── first.rb │ │ │ │ ├── libraries │ │ │ │ │ └── test.rb │ │ │ │ ├── templates │ │ │ │ │ └── default │ │ │ │ │ │ └── monkey.erb │ │ │ │ └── definitions │ │ │ │ │ └── test.rb │ │ │ ├── rubygems_server │ │ │ │ ├── attributes │ │ │ │ │ └── first.rb │ │ │ │ ├── files │ │ │ │ │ └── default │ │ │ │ │ │ └── packages │ │ │ │ │ │ ├── net-scp-1.0.1.gem │ │ │ │ │ │ ├── net-ssh-2.0.3.gem │ │ │ │ │ │ ├── net-sftp-2.0.1.gem │ │ │ │ │ │ └── net-ssh-gateway-1.0.0.gem │ │ │ │ └── recipes │ │ │ │ │ └── default.rb │ │ │ └── servicetest │ │ │ │ └── recipes │ │ │ │ └── default.rb │ │ ├── nodes │ │ │ ├── default.rb │ │ │ ├── adam.rb │ │ │ ├── latte.rb │ │ │ └── junglist.gen.nz.rb │ │ └── chef-solo.rb │ ├── search_syntax.rb │ ├── node.rb │ ├── config.rb │ ├── user_index.rb │ └── sample_recipe.rb ├── spec │ ├── data │ │ ├── bad-config.rb │ │ ├── cookbooks │ │ │ ├── openldap │ │ │ │ ├── attributes │ │ │ │ │ ├── smokey.rb │ │ │ │ │ └── default.rb │ │ │ │ ├── templates │ │ │ │ │ └── default │ │ │ │ │ │ └── test.erb │ │ │ │ ├── recipes │ │ │ │ │ ├── default.rb │ │ │ │ │ ├── gigantor.rb │ │ │ │ │ └── one.rb │ │ │ │ ├── files │ │ │ │ │ └── default │ │ │ │ │ │ └── .dotfile │ │ │ │ ├── definitions │ │ │ │ │ ├── client.rb │ │ │ │ │ └── server.rb │ │ │ │ └── ignore │ │ │ └── apache2 │ │ │ │ └── recipes │ │ │ │ └── default.rb │ │ ├── compile │ │ │ ├── cookbooks │ │ │ │ └── test │ │ │ │ │ ├── attributes │ │ │ │ │ └── george.rb │ │ │ │ │ ├── recipes │ │ │ │ │ ├── default.rb │ │ │ │ │ ├── one.rb │ │ │ │ │ └── two.rb │ │ │ │ │ └── definitions │ │ │ │ │ └── new_cat.rb │ │ │ └── nodes │ │ │ │ └── compile.rb │ │ ├── kitchen │ │ │ └── openldap │ │ │ │ ├── attributes │ │ │ │ ├── robinson.rb │ │ │ │ └── default.rb │ │ │ │ ├── definitions │ │ │ │ ├── client.rb │ │ │ │ └── drewbarrymore.rb │ │ │ │ └── recipes │ │ │ │ ├── woot.rb │ │ │ │ ├── ignoreme.rb │ │ │ │ └── gigantor.rb │ │ ├── seattle.txt │ │ ├── config.rb │ │ ├── definitions │ │ │ └── test.rb │ │ ├── recipes │ │ │ └── test.rb │ │ └── nodes │ │ │ ├── test.rb │ │ │ ├── default.rb │ │ │ └── test.example.com.rb │ ├── spec.opts │ ├── rcov.opts │ ├── unit │ │ ├── chef_spec.rb │ │ ├── resource │ │ │ ├── csh_spec.rb │ │ │ ├── bash_spec.rb │ │ │ ├── perl_spec.rb │ │ │ ├── ruby_spec.rb │ │ │ ├── python_spec.rb │ │ │ ├── apt_package_spec.rb │ │ │ ├── gem_package_spec.rb │ │ │ ├── portage_package_spec.rb │ │ │ ├── http_request_spec.rb │ │ │ ├── script_spec.rb │ │ │ └── remote_file_spec.rb │ │ └── provider_spec.rb │ ├── lib │ │ └── chef │ │ │ ├── provider │ │ │ ├── easy.rb │ │ │ └── snakeoil.rb │ │ │ └── resource │ │ │ ├── one_two_three_four.rb │ │ │ ├── cat.rb │ │ │ └── zen_master.rb │ └── spec_helper.rb ├── docs │ └── design │ │ └── HighLevel.graffle ├── History.txt ├── config │ └── server.rb ├── lib │ ├── chef │ │ ├── resource │ │ │ ├── bash.rb │ │ │ ├── csh.rb │ │ │ ├── perl.rb │ │ │ ├── ruby.rb │ │ │ ├── python.rb │ │ │ ├── gem_package.rb │ │ │ ├── portage_package.rb │ │ │ ├── apt_package.rb │ │ │ ├── script.rb │ │ │ ├── remote_file.rb │ │ │ ├── http_request.rb │ │ │ ├── template.rb │ │ │ ├── group.rb │ │ │ └── link.rb │ │ ├── mixin │ │ │ ├── checksum.rb │ │ │ ├── check_helper.rb │ │ │ ├── from_file.rb │ │ │ └── generate_url.rb │ │ ├── exceptions.rb │ │ ├── provider.rb │ │ └── provider │ │ │ └── script.rb │ └── chef.rb ├── tasks │ └── rspec.rb └── Rakefile ├── example-repository ├── log │ ├── merb.main.pid │ └── merb.main.log ├── cookbooks │ ├── tempfile │ │ ├── files │ │ │ └── default │ │ │ │ └── packages │ │ │ │ ├── blank │ │ │ │ └── test │ │ ├── attributes │ │ │ └── second.rb │ │ └── recipes │ │ │ └── default.rb │ ├── remote_file │ │ ├── files │ │ │ └── default │ │ │ │ └── seattle.txt │ │ └── recipes │ │ │ └── default.rb │ ├── CHEF-87 │ │ ├── files │ │ │ └── default │ │ │ │ └── .dotfile │ │ └── recipes │ │ │ └── default.rb │ ├── fakefile │ │ ├── files │ │ │ └── default │ │ │ │ ├── remote_test │ │ │ │ ├── another │ │ │ │ │ ├── window.txt │ │ │ │ │ └── turn │ │ │ │ │ │ └── the_page.txt │ │ │ │ └── mycat.txt │ │ │ │ └── the_park.txt │ │ ├── attributes │ │ │ └── first.rb │ │ ├── libraries │ │ │ └── test.rb │ │ ├── templates │ │ │ └── default │ │ │ │ └── monkey.erb │ │ └── definitions │ │ │ └── test.rb │ ├── rubygems_server │ │ ├── attributes │ │ │ └── first.rb │ │ ├── files │ │ │ └── default │ │ │ │ └── packages │ │ │ │ ├── net-scp-1.0.1.gem │ │ │ │ ├── net-sftp-2.0.1.gem │ │ │ │ ├── net-ssh-2.0.3.gem │ │ │ │ └── net-ssh-gateway-1.0.0.gem │ │ └── recipes │ │ │ └── default.rb │ ├── CHEF-72 │ │ ├── files │ │ │ └── default │ │ │ │ └── chef-72.txt │ │ ├── templates │ │ │ └── default │ │ │ │ └── chef-72.txt.erb │ │ └── recipes │ │ │ └── default.rb │ ├── template-test │ │ ├── templates │ │ │ └── default │ │ │ │ └── whazzit.erb │ │ └── recipes │ │ │ └── default.rb │ ├── CHEF-72-define │ │ ├── files │ │ │ └── default │ │ │ │ └── chef-72.txt │ │ ├── templates │ │ │ └── default │ │ │ │ └── chef-72.txt.erb │ │ ├── recipes │ │ │ └── default.rb │ │ └── definitions │ │ │ ├── define_remote_file.rb │ │ │ └── define_template.rb │ ├── template_caching_test │ │ ├── templates │ │ │ └── default │ │ │ │ └── test_render.erb │ │ └── recipes │ │ │ └── default.rb │ ├── CHEF-37 │ │ └── files │ │ │ └── default │ │ │ └── embrace.txt │ ├── CHEF-94 │ │ ├── attributes │ │ │ └── gnomes.rb │ │ ├── definitions │ │ │ └── gnome.rb │ │ └── recipes │ │ │ └── default.rb │ ├── servicetest │ │ └── recipes │ │ │ └── default.rb │ ├── CHEF-59 │ │ └── recipes │ │ │ └── default.rb │ ├── CHEF-57 │ │ └── recipes │ │ │ └── default.rb │ ├── CHEF-56 │ │ └── recipes │ │ │ └── default.rb │ ├── CHEF-44 │ │ └── recipes │ │ │ └── default.rb │ ├── CHEF-88 │ │ └── recipes │ │ │ └── default.rb │ ├── prior_resource_test │ │ └── recipes │ │ │ └── default.rb │ ├── http_request │ │ └── recipes │ │ │ └── default.rb │ ├── CHEF-90 │ │ └── recipes │ │ │ └── default.rb │ ├── CHEF-97 │ │ └── recipes │ │ │ └── default.rb │ └── global-onlyif │ │ └── recipes │ │ └── default.rb └── config │ ├── client.rb │ ├── server.rb │ ├── solo.rb │ └── rake.rb ├── chef-server-slice ├── public │ ├── javascripts │ │ └── master.js │ └── images │ │ ├── merb.jpg │ │ └── indicator.gif ├── app │ ├── views │ │ ├── cookbooks │ │ │ ├── _attribute_file.html.haml │ │ │ ├── _syntax_highlight.html.haml │ │ │ ├── index.html.haml │ │ │ ├── attribute_files.html.haml │ │ │ └── show.html.haml │ │ ├── main │ │ │ └── index.html.erb │ │ ├── exceptions │ │ │ └── bad_request.json.erb │ │ ├── nodes │ │ │ ├── show.html.haml │ │ │ ├── compile.html.haml │ │ │ ├── index.html.haml │ │ │ ├── _node.html.haml │ │ │ ├── _action.html.haml │ │ │ └── _resource.html.haml │ │ ├── openid_consumer │ │ │ ├── start.html.haml │ │ │ └── index.html.haml │ │ ├── status │ │ │ └── index.html.haml │ │ ├── openid_login │ │ │ └── index.html.haml │ │ ├── search │ │ │ ├── _search_form.html.haml │ │ │ ├── index.html.haml │ │ │ └── show.html.haml │ │ ├── openid_register │ │ │ ├── show.html.haml │ │ │ └── index.html.haml │ │ ├── search_entries │ │ │ ├── show.html.haml │ │ │ └── index.html.haml │ │ ├── cookbook_templates │ │ │ └── index.html.haml │ │ ├── openid_server │ │ │ └── decide.html.haml │ │ └── layout │ │ │ └── chef_server_slice.html.haml │ ├── helpers │ │ ├── search_helper.rb │ │ ├── exceptions_helper.rb │ │ ├── openid_server_helper.rb │ │ ├── search_entries_helper.rb │ │ ├── cookbook_attributes_helper.rb │ │ ├── cookbook_files_helper.rb │ │ ├── cookbook_libraries_helper.rb │ │ ├── openid_consumer_helper.rb │ │ ├── openid_register_helper.rb │ │ ├── cookbook_recipes_helper.rb │ │ ├── cookbook_templates_helper.rb │ │ ├── cookbook_definitions_helper.rb │ │ ├── openid_server_helpers.rb │ │ ├── cookbooks_helper.rb │ │ ├── global_helpers.rb │ │ ├── nodes_helper.rb │ │ └── status_helper.rb │ └── controllers │ │ ├── main.rb │ │ ├── status.rb │ │ ├── exceptions.rb │ │ ├── cookbooks.rb │ │ └── search.rb ├── stubs │ └── app │ │ └── controllers │ │ ├── main.rb │ │ └── application.rb ├── config │ └── router.rb ├── spec │ ├── requests │ │ ├── exceptions_spec.rb │ │ ├── openid_server_spec.rb │ │ ├── cookbook_files_spec.rb │ │ ├── search_entries_spec.rb │ │ ├── cookbook_recipes_spec.rb │ │ ├── openid_consumer_spec.rb │ │ ├── cookbook_libraries_spec.rb │ │ ├── cookbook_templates_spec.rb │ │ ├── cookbook_attributes_spec.rb │ │ ├── cookbook_definitions_spec.rb │ │ ├── search_spec.rb │ │ ├── nodes_spec.rb │ │ ├── openid_register_spec.rb │ │ ├── main_spec.rb │ │ └── cookbooks_spec.rb │ └── chef-server-slice_spec.rb ├── NOTICE ├── TODO ├── lib │ └── chef-server-slice │ │ └── slicetasks.rb └── bin │ └── chef-server ├── features ├── data │ ├── cookbooks │ │ ├── transfer_remote_files_definition │ │ │ ├── files │ │ │ │ └── default │ │ │ │ │ └── easy.txt │ │ │ └── definitions │ │ │ │ └── transfer.rb │ │ ├── transfer_remote_files │ │ │ ├── files │ │ │ │ └── default │ │ │ │ │ └── transfer_a_file_from_a_cookbook.txt │ │ │ └── recipes │ │ │ │ ├── default.rb │ │ │ │ ├── transfer_a_file_from_a_specific_cookbook.rb │ │ │ │ ├── should_prefer_the_file_for_this_specific_host.rb │ │ │ │ └── transfer_a_file_from_a_cookbook.rb │ │ ├── manage_files │ │ │ └── recipes │ │ │ │ ├── default.rb │ │ │ │ ├── touch_a_file.rb │ │ │ │ ├── create_a_file.rb │ │ │ │ ├── delete_a_file_that_does_not_already_exist.rb │ │ │ │ ├── set_the_owner_of_a_created_file.rb │ │ │ │ └── delete_a_file.rb │ │ ├── delayed_notifications │ │ │ └── recipes │ │ │ │ ├── default.rb │ │ │ │ ├── notify_a_resource_from_a_single_source.rb │ │ │ │ └── notify_a_resource_from_multiple_sources.rb │ │ └── integration_setup │ │ │ ├── recipes │ │ │ └── default.rb │ │ │ └── attributes │ │ │ └── integration.rb │ └── config │ │ ├── client.rb │ │ └── server.rb ├── delayed_notifications.feature ├── steps │ ├── couchdb.rb │ ├── recipe.rb │ ├── nodes.rb │ └── run_client.rb ├── support │ └── env.rb └── manage_files.feature ├── .gitignore └── NOTICE /chef-server/spec/spec.opts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chef/examples/mrepo/Rakefile: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example-repository/log/merb.main.pid: -------------------------------------------------------------------------------- 1 | 44404 -------------------------------------------------------------------------------- /chef-server-slice/public/javascripts/master.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chef/examples/search_index/segments: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chef/spec/data/bad-config.rb: -------------------------------------------------------------------------------- 1 | monkey_soup("tastes nice") -------------------------------------------------------------------------------- /chef/spec/spec.opts: -------------------------------------------------------------------------------- 1 | --color 2 | --loadby 3 | mtime 4 | -------------------------------------------------------------------------------- /chef/spec/rcov.opts: -------------------------------------------------------------------------------- 1 | --exclude 2 | spec,bin,/Library/Ruby 3 | -------------------------------------------------------------------------------- /example-repository/cookbooks/tempfile/files/default/packages/blank: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /chef/spec/data/cookbooks/openldap/attributes/smokey.rb: -------------------------------------------------------------------------------- 1 | smokey "robinson" -------------------------------------------------------------------------------- /example-repository/cookbooks/tempfile/attributes/second.rb: -------------------------------------------------------------------------------- 1 | monkey "poots" -------------------------------------------------------------------------------- /chef/examples/config/cookbooks/tempfile/attributes/second.rb: -------------------------------------------------------------------------------- 1 | monkey "poots" -------------------------------------------------------------------------------- /chef/spec/data/compile/cookbooks/test/attributes/george.rb: -------------------------------------------------------------------------------- 1 | george "washington" -------------------------------------------------------------------------------- /example-repository/cookbooks/remote_file/files/default/seattle.txt: -------------------------------------------------------------------------------- 1 | Is a nice town. -------------------------------------------------------------------------------- /chef-server/app/controllers/application.rb: -------------------------------------------------------------------------------- 1 | class Application < Merb::Controller 2 | end -------------------------------------------------------------------------------- /chef/spec/data/cookbooks/apache2/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Nothing ot see here 3 | # -------------------------------------------------------------------------------- /chef/spec/data/kitchen/openldap/attributes/robinson.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Smokey lives here 3 | # -------------------------------------------------------------------------------- /chef/spec/data/kitchen/openldap/definitions/client.rb: -------------------------------------------------------------------------------- 1 | # 2 | # A sad client 3 | # 4 | -------------------------------------------------------------------------------- /chef/spec/data/kitchen/openldap/recipes/woot.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Such a funny word.. 3 | # 4 | -------------------------------------------------------------------------------- /chef-server-slice/app/views/cookbooks/_attribute_file.html.haml: -------------------------------------------------------------------------------- 1 | %h3= name 2 | %pre= contents -------------------------------------------------------------------------------- /chef/spec/data/kitchen/openldap/recipes/ignoreme.rb: -------------------------------------------------------------------------------- 1 | # 2 | # this file will never be seen 3 | # -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-87/files/default/.dotfile: -------------------------------------------------------------------------------- 1 | This is an example dotfile! 2 | -------------------------------------------------------------------------------- /example-repository/cookbooks/fakefile/files/default/remote_test/another/window.txt: -------------------------------------------------------------------------------- 1 | appleseed? -------------------------------------------------------------------------------- /example-repository/cookbooks/fakefile/files/default/remote_test/mycat.txt: -------------------------------------------------------------------------------- 1 | is a very nice kitty -------------------------------------------------------------------------------- /example-repository/cookbooks/rubygems_server/attributes/first.rb: -------------------------------------------------------------------------------- 1 | rubygems("are awesome") 2 | -------------------------------------------------------------------------------- /chef/examples/config/cookbooks/fakefile/files/default/remote_test/another/window.txt: -------------------------------------------------------------------------------- 1 | appleseed? -------------------------------------------------------------------------------- /chef/examples/config/cookbooks/fakefile/files/default/remote_test/mycat.txt: -------------------------------------------------------------------------------- 1 | is a very nice kitty -------------------------------------------------------------------------------- /chef/examples/config/cookbooks/rubygems_server/attributes/first.rb: -------------------------------------------------------------------------------- 1 | rubygems("are awesome") 2 | -------------------------------------------------------------------------------- /chef/spec/data/cookbooks/openldap/templates/default/test.erb: -------------------------------------------------------------------------------- 1 | We could be diving for pearls! 2 | -------------------------------------------------------------------------------- /chef/spec/data/seattle.txt: -------------------------------------------------------------------------------- 1 | Seattle is a great town. Next time you visit, you should buy me a beer. -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-72/files/default/chef-72.txt: -------------------------------------------------------------------------------- 1 | Oh I, want to give you some love... -------------------------------------------------------------------------------- /example-repository/cookbooks/template-test/templates/default/whazzit.erb: -------------------------------------------------------------------------------- 1 | Who is the <%= @whosa %> -------------------------------------------------------------------------------- /chef/spec/data/kitchen/openldap/attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Nothing to see here, move along 3 | # 4 | -------------------------------------------------------------------------------- /chef/spec/data/kitchen/openldap/recipes/gigantor.rb: -------------------------------------------------------------------------------- 1 | cat "blanket" do 2 | pretty_kitty true 3 | end -------------------------------------------------------------------------------- /example-repository/cookbooks/tempfile/files/default/packages/test: -------------------------------------------------------------------------------- 1 | You would like that, wouldn't you? -------------------------------------------------------------------------------- /chef-server/autotest/discover.rb: -------------------------------------------------------------------------------- 1 | Autotest.add_discovery { "merb" } 2 | Autotest.add_discovery { "rspec" } -------------------------------------------------------------------------------- /chef-server/public/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // Common JavaScript code across your application goes here. -------------------------------------------------------------------------------- /chef/spec/data/cookbooks/openldap/recipes/default.rb: -------------------------------------------------------------------------------- 1 | cat "blanket" do 2 | pretty_kitty true 3 | end 4 | -------------------------------------------------------------------------------- /chef/spec/data/cookbooks/openldap/recipes/gigantor.rb: -------------------------------------------------------------------------------- 1 | cat "blanket" do 2 | pretty_kitty false 3 | end 4 | -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-72/templates/default/chef-72.txt.erb: -------------------------------------------------------------------------------- 1 | By default, we should <%= @sing %> -------------------------------------------------------------------------------- /features/data/cookbooks/transfer_remote_files_definition/files/default/easy.txt: -------------------------------------------------------------------------------- 1 | easy like saturday morning -------------------------------------------------------------------------------- /chef-server/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/chef/master/chef-server/public/favicon.ico -------------------------------------------------------------------------------- /chef/spec/data/kitchen/openldap/definitions/drewbarrymore.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Was in people magazine this month... 3 | # -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-72-define/files/default/chef-72.txt: -------------------------------------------------------------------------------- 1 | I want to give you some good, good love! -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-72-define/templates/default/chef-72.txt.erb: -------------------------------------------------------------------------------- 1 | Its all in my pocket! <%= @sing %> -------------------------------------------------------------------------------- /example-repository/cookbooks/template_caching_test/templates/default/test_render.erb: -------------------------------------------------------------------------------- 1 | I'm number <%= @number %>! -------------------------------------------------------------------------------- /chef-server-slice/app/views/cookbooks/_syntax_highlight.html.haml: -------------------------------------------------------------------------------- 1 | %h3= name 2 | %div.ruby= syntax_highlight(contents) -------------------------------------------------------------------------------- /chef-server-slice/app/views/main/index.html.erb: -------------------------------------------------------------------------------- 1 | <%= slice.description %> (v. <%= slice.version %>) -------------------------------------------------------------------------------- /chef-server-slice/stubs/app/controllers/main.rb: -------------------------------------------------------------------------------- 1 | class ChefServerSlice::Main < ChefServerSlice::Application 2 | end 3 | -------------------------------------------------------------------------------- /chef-server/public/images/merb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/chef/master/chef-server/public/images/merb.jpg -------------------------------------------------------------------------------- /chef/docs/design/HighLevel.graffle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/chef/master/chef/docs/design/HighLevel.graffle -------------------------------------------------------------------------------- /chef/spec/data/cookbooks/openldap/files/default/.dotfile: -------------------------------------------------------------------------------- 1 | I am here to test .dotfiles work in file directories. 2 | -------------------------------------------------------------------------------- /example-repository/cookbooks/fakefile/files/default/remote_test/another/turn/the_page.txt: -------------------------------------------------------------------------------- 1 | Classic rock is awesome. 2 | -------------------------------------------------------------------------------- /chef-server-slice/app/views/exceptions/bad_request.json.erb: -------------------------------------------------------------------------------- 1 | <%= { :error => params[:exception], :code => 400 }.to_json %> -------------------------------------------------------------------------------- /chef-server-slice/stubs/app/controllers/application.rb: -------------------------------------------------------------------------------- 1 | class ChefServerSlice::Application < Merb::Controller 2 | end 3 | -------------------------------------------------------------------------------- /chef-server/lib/views/exceptions/bad_request.html.haml: -------------------------------------------------------------------------------- 1 | - request.exceptions.each do |exception| 2 | = exception.message -------------------------------------------------------------------------------- /chef/examples/config/cookbooks/fakefile/files/default/remote_test/another/turn/the_page.txt: -------------------------------------------------------------------------------- 1 | Classic rock is awesome. 2 | -------------------------------------------------------------------------------- /chef/examples/search_index/segments_0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/chef/master/chef/examples/search_index/segments_0 -------------------------------------------------------------------------------- /chef/spec/data/compile/cookbooks/test/recipes/default.rb: -------------------------------------------------------------------------------- 1 | 2 | cat "einstein" do 3 | pretty_kitty true 4 | end 5 | 6 | -------------------------------------------------------------------------------- /features/data/cookbooks/transfer_remote_files/files/default/transfer_a_file_from_a_cookbook.txt: -------------------------------------------------------------------------------- 1 | easy like sunday morning 2 | -------------------------------------------------------------------------------- /chef-server-slice/public/images/merb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/chef/master/chef-server-slice/public/images/merb.jpg -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-37/files/default/embrace.txt: -------------------------------------------------------------------------------- 1 | "You couldn't dam that river, and maybe I don't give a damn anyway" -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-94/attributes/gnomes.rb: -------------------------------------------------------------------------------- 1 | gnome Mash.new 2 | gnome[:underpants] = [ :one, :two, :three, :four, :five ] -------------------------------------------------------------------------------- /chef-server-slice/public/images/indicator.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/chef/master/chef-server-slice/public/images/indicator.gif -------------------------------------------------------------------------------- /chef/spec/data/config.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Sample Chef Config File 3 | # 4 | 5 | cookbook_path "/etc/chef/cookbook", "/etc/chef/site-cookbook" 6 | 7 | -------------------------------------------------------------------------------- /chef-server-slice/app/views/nodes/show.html.haml: -------------------------------------------------------------------------------- 1 | - throw_content(:header, "Node #{h @node.name}") 2 | .node 3 | = partial(:node, :node => @node) -------------------------------------------------------------------------------- /chef/spec/data/compile/nodes/compile.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # Nodes should have a unique name 3 | ## 4 | name "compile" 5 | recipes "test", "test::one", "test::two" 6 | -------------------------------------------------------------------------------- /chef/spec/data/definitions/test.rb: -------------------------------------------------------------------------------- 1 | define :rico_suave, :rich => "smooth" do 2 | zen_master "test" do 3 | something "#{params[:rich]}" 4 | end 5 | end -------------------------------------------------------------------------------- /chef/spec/data/recipes/test.rb: -------------------------------------------------------------------------------- 1 | 2 | file "/etc/nsswitch.conf" do 3 | action :create 4 | owner "root" 5 | group "root" 6 | mode 0644 7 | end 8 | -------------------------------------------------------------------------------- /chef-server-slice/app/helpers/search_helper.rb: -------------------------------------------------------------------------------- 1 | module Merb 2 | module ChefServerSlice 3 | module SearchHelper 4 | 5 | end 6 | end 7 | end # Merb 8 | -------------------------------------------------------------------------------- /chef-server-slice/config/router.rb: -------------------------------------------------------------------------------- 1 | # This file is here so slice can be testing as a stand alone application. 2 | 3 | #Merb::Router.prepare do 4 | # ... 5 | #end -------------------------------------------------------------------------------- /chef-server/app/helpers/global_helpers.rb: -------------------------------------------------------------------------------- 1 | module Merb 2 | module GlobalHelpers 3 | # helpers defined here available to all views. 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /example-repository/log/merb.main.log: -------------------------------------------------------------------------------- 1 | Thu, 09 Oct 2008 21:27:28 GMT ~ info ~ Logfile created 2 | Thu, 09 Oct 2008 21:27:28 GMT ~ info ~ Logfile created 3 | -------------------------------------------------------------------------------- /chef-server-slice/app/controllers/main.rb: -------------------------------------------------------------------------------- 1 | class ChefServerSlice::Main < ChefServerSlice::Application 2 | 3 | def index 4 | render 5 | end 6 | 7 | end 8 | -------------------------------------------------------------------------------- /chef-server-slice/app/helpers/exceptions_helper.rb: -------------------------------------------------------------------------------- 1 | module Merb 2 | module ChefServerSlice 3 | module ExceptionsHelper 4 | end 5 | end 6 | end # Merb 7 | -------------------------------------------------------------------------------- /chef/examples/config/cookbooks/fakefile/attributes/first.rb: -------------------------------------------------------------------------------- 1 | Chef::Log.debug("You are the first of fakefile's attributes") 2 | friends("you said we wuz visiting em") -------------------------------------------------------------------------------- /chef/spec/data/compile/cookbooks/test/recipes/one.rb: -------------------------------------------------------------------------------- 1 | cat "loulou" do 2 | pretty_kitty true 3 | end 4 | 5 | new_cat "birthday" do 6 | pretty_kitty false 7 | end 8 | -------------------------------------------------------------------------------- /example-repository/cookbooks/fakefile/attributes/first.rb: -------------------------------------------------------------------------------- 1 | Chef::Log.debug("You are the first of fakefile's attributes") 2 | friends("you said we wuz visiting em") 3 | -------------------------------------------------------------------------------- /chef-server-slice/app/helpers/openid_server_helper.rb: -------------------------------------------------------------------------------- 1 | module Merb 2 | module ChefServerSlice 3 | module OpenidServerHelper 4 | end 5 | end 6 | end # Merb 7 | -------------------------------------------------------------------------------- /chef/spec/data/compile/cookbooks/test/recipes/two.rb: -------------------------------------------------------------------------------- 1 | cat "peanut" do 2 | pretty_kitty true 3 | end 4 | 5 | new_cat "fat peanut" do 6 | pretty_kitty false 7 | end 8 | -------------------------------------------------------------------------------- /chef/examples/config/cookbooks/fakefile/files/default/the_park.txt: -------------------------------------------------------------------------------- 1 | Is very pretty on a Saturday at 7:50 in August. Hottest day of the year so far in Seattle. 2 | 3 | something -------------------------------------------------------------------------------- /chef/examples/config/cookbooks/fakefile/libraries/test.rb: -------------------------------------------------------------------------------- 1 | class Chef 2 | class Recipe 3 | def bork 4 | Chef::Log.debug("Bork bork bork") 5 | end 6 | end 7 | end -------------------------------------------------------------------------------- /example-repository/cookbooks/fakefile/files/default/the_park.txt: -------------------------------------------------------------------------------- 1 | Is very pretty on a Saturday at 7:50 in August. Hottest day of the year so far in Seattle. 2 | 3 | something -------------------------------------------------------------------------------- /example-repository/cookbooks/fakefile/libraries/test.rb: -------------------------------------------------------------------------------- 1 | class Chef 2 | class Recipe 3 | def bork 4 | Chef::Log.debug("Bork bork bork") 5 | end 6 | end 7 | end -------------------------------------------------------------------------------- /chef-server-slice/app/helpers/search_entries_helper.rb: -------------------------------------------------------------------------------- 1 | module Merb 2 | module ChefServerSlice 3 | module SearchEntriesHelper 4 | 5 | end 6 | end 7 | 8 | end # Merb 9 | -------------------------------------------------------------------------------- /chef-server-slice/app/views/openid_consumer/start.html.haml: -------------------------------------------------------------------------------- 1 | <%= @form_text %> 2 | -------------------------------------------------------------------------------- /chef-server-slice/app/helpers/cookbook_attributes_helper.rb: -------------------------------------------------------------------------------- 1 | module Merb 2 | module ChefServerSlice 3 | module CookbookAttributesHelper 4 | 5 | end 6 | end 7 | end # Merb 8 | -------------------------------------------------------------------------------- /chef-server-slice/app/helpers/cookbook_files_helper.rb: -------------------------------------------------------------------------------- 1 | module Merb 2 | module ChefServerSlice 3 | module CookbookFilesHelper 4 | 5 | end 6 | 7 | end 8 | end # Merb 9 | -------------------------------------------------------------------------------- /chef-server-slice/app/helpers/cookbook_libraries_helper.rb: -------------------------------------------------------------------------------- 1 | module Merb 2 | module ChefServerSlice 3 | module CookbookLibrariesHelper 4 | 5 | end 6 | end 7 | end # Merb 8 | -------------------------------------------------------------------------------- /chef-server-slice/app/helpers/openid_consumer_helper.rb: -------------------------------------------------------------------------------- 1 | module Merb 2 | module ChefServerSlice 3 | module OpenidConsumerHelper 4 | 5 | end 6 | end 7 | 8 | end # Merb 9 | -------------------------------------------------------------------------------- /chef-server-slice/app/helpers/openid_register_helper.rb: -------------------------------------------------------------------------------- 1 | module Merb 2 | module ChefServerSlice 3 | module OpenidRegisterHelper 4 | 5 | end 6 | end 7 | 8 | end # Merb 9 | -------------------------------------------------------------------------------- /chef-server-slice/app/helpers/cookbook_recipes_helper.rb: -------------------------------------------------------------------------------- 1 | module Merb 2 | module ChefServerSlice 3 | module CookbookRecipesHelper 4 | 5 | end 6 | 7 | end 8 | end # Merb 9 | -------------------------------------------------------------------------------- /chef-server-slice/app/helpers/cookbook_templates_helper.rb: -------------------------------------------------------------------------------- 1 | module Merb 2 | module ChefServerSlice 3 | module CookbookTemplatesHelper 4 | 5 | end 6 | 7 | end 8 | end # Merb 9 | -------------------------------------------------------------------------------- /chef/spec/data/cookbooks/openldap/definitions/client.rb: -------------------------------------------------------------------------------- 1 | define :openldap_client, :mothra => "a big monster" do 2 | cat "#{params[:name]}" do 3 | pretty_kitty true 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /chef/spec/data/cookbooks/openldap/definitions/server.rb: -------------------------------------------------------------------------------- 1 | define :openldap_server, :mothra => "a big monster" do 2 | cat "#{params[:name]}" do 3 | pretty_kitty true 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /chef-server-slice/app/helpers/cookbook_definitions_helper.rb: -------------------------------------------------------------------------------- 1 | module Merb 2 | module ChefServerSlice 3 | module CookbookDefinitionsHelper 4 | 5 | end 6 | 7 | end 8 | end # Merb 9 | -------------------------------------------------------------------------------- /chef/spec/data/compile/cookbooks/test/definitions/new_cat.rb: -------------------------------------------------------------------------------- 1 | define :new_cat, :is_pretty => true do 2 | cat "#{params[:name]}" do 3 | pretty_kitty params[:is_pretty] 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /chef-server/lib/tasks/uninstall.rake: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'rake/gempackagetask' 3 | 4 | task :uninstall do 5 | sh %{sudo gem uninstall #{GEM} -x -v #{CHEF_SERVER_VERSION}} 6 | end 7 | 8 | -------------------------------------------------------------------------------- /chef/spec/data/cookbooks/openldap/ignore: -------------------------------------------------------------------------------- 1 | # 2 | # The ignore file allows you to skip files in cookbooks with the same name that appear 3 | # later in the search path. 4 | # 5 | 6 | recipes/ignoreme.rb -------------------------------------------------------------------------------- /chef/examples/config/nodes/default.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # Nodes can set arbitrary arguments 3 | ## 4 | owner "Adam Jacob" 5 | 6 | ## 7 | # Nodes should have recipes 8 | ## 9 | recipes "tempfile", "fakefile" 10 | -------------------------------------------------------------------------------- /chef-server/lib/tasks/install.rake: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'rake/gempackagetask' 3 | 4 | task :install => :package do 5 | sh %{sudo gem install pkg/#{GEM}-#{CHEF_SERVER_VERSION} --no-rdoc --no-ri} 6 | end 7 | 8 | -------------------------------------------------------------------------------- /chef/examples/config/cookbooks/rubygems_server/files/default/packages/net-scp-1.0.1.gem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/chef/master/chef/examples/config/cookbooks/rubygems_server/files/default/packages/net-scp-1.0.1.gem -------------------------------------------------------------------------------- /chef/examples/config/cookbooks/rubygems_server/files/default/packages/net-ssh-2.0.3.gem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/chef/master/chef/examples/config/cookbooks/rubygems_server/files/default/packages/net-ssh-2.0.3.gem -------------------------------------------------------------------------------- /example-repository/cookbooks/rubygems_server/files/default/packages/net-scp-1.0.1.gem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/chef/master/example-repository/cookbooks/rubygems_server/files/default/packages/net-scp-1.0.1.gem -------------------------------------------------------------------------------- /example-repository/cookbooks/rubygems_server/files/default/packages/net-sftp-2.0.1.gem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/chef/master/example-repository/cookbooks/rubygems_server/files/default/packages/net-sftp-2.0.1.gem -------------------------------------------------------------------------------- /example-repository/cookbooks/rubygems_server/files/default/packages/net-ssh-2.0.3.gem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/chef/master/example-repository/cookbooks/rubygems_server/files/default/packages/net-ssh-2.0.3.gem -------------------------------------------------------------------------------- /chef/examples/config/cookbooks/rubygems_server/files/default/packages/net-sftp-2.0.1.gem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/chef/master/chef/examples/config/cookbooks/rubygems_server/files/default/packages/net-sftp-2.0.1.gem -------------------------------------------------------------------------------- /chef-server-slice/spec/requests/exceptions_spec.rb: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') 2 | 3 | describe "/exceptions" do 4 | before(:each) do 5 | @response = request("/exceptions") 6 | end 7 | end -------------------------------------------------------------------------------- /example-repository/cookbooks/rubygems_server/files/default/packages/net-ssh-gateway-1.0.0.gem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/chef/master/example-repository/cookbooks/rubygems_server/files/default/packages/net-ssh-gateway-1.0.0.gem -------------------------------------------------------------------------------- /chef-server-slice/app/views/status/index.html.haml: -------------------------------------------------------------------------------- 1 | - throw_content(:header, "Status") 2 | - @node_list.each do |node| 3 | .node 4 | %h3= node 5 | = get_info(node) 6 | %br 7 | %strong Recipes: 8 | = recipe_list(node) 9 | -------------------------------------------------------------------------------- /chef-server-slice/spec/requests/openid_server_spec.rb: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') 2 | 3 | describe "/openid_server" do 4 | before(:each) do 5 | @response = request("/openid_server") 6 | end 7 | end -------------------------------------------------------------------------------- /chef/examples/config/cookbooks/rubygems_server/files/default/packages/net-ssh-gateway-1.0.0.gem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/chef/master/chef/examples/config/cookbooks/rubygems_server/files/default/packages/net-ssh-gateway-1.0.0.gem -------------------------------------------------------------------------------- /chef-server-slice/spec/requests/cookbook_files_spec.rb: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') 2 | 3 | describe "/cookbook_files" do 4 | before(:each) do 5 | @response = request("/cookbook_files") 6 | end 7 | end -------------------------------------------------------------------------------- /chef-server-slice/spec/requests/search_entries_spec.rb: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') 2 | 3 | describe "/search_entries" do 4 | before(:each) do 5 | @response = request("/search_entries") 6 | end 7 | end -------------------------------------------------------------------------------- /chef-server/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-Agent: * 5 | # Disallow: / -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-94/definitions/gnome.rb: -------------------------------------------------------------------------------- 1 | define :gnome do 2 | params[:underpants].each do |undies| 3 | execute "echo gnome #{undies}" do 4 | command "echo 'gnome has underpants #{undies}'" 5 | end 6 | end 7 | end -------------------------------------------------------------------------------- /chef-server-slice/app/views/nodes/compile.html.haml: -------------------------------------------------------------------------------- 1 | = partial(:node, :node => @output[:node]) 2 | .resource_collection 3 | %h1 Resource Collection 4 | - @output[:collection].each do |resource| 5 | = partial(:resource, :resource => resource) 6 | -------------------------------------------------------------------------------- /chef-server-slice/spec/requests/cookbook_recipes_spec.rb: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') 2 | 3 | describe "/cookbook_recipes" do 4 | before(:each) do 5 | @response = request("/cookbook_recipes") 6 | end 7 | end -------------------------------------------------------------------------------- /chef-server-slice/spec/requests/openid_consumer_spec.rb: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') 2 | 3 | describe "/openid_consumer" do 4 | before(:each) do 5 | @response = request("/openid_consumer") 6 | end 7 | end -------------------------------------------------------------------------------- /chef/examples/config/cookbooks/rubygems_server/recipes/default.rb: -------------------------------------------------------------------------------- 1 | remote_directory "/srv/gems" do 2 | owner "www-data" 3 | mode 0755 4 | source "packages" 5 | files_owner "www-data" 6 | files_group "www-data" 7 | files_mode 0644 8 | end 9 | -------------------------------------------------------------------------------- /example-repository/cookbooks/rubygems_server/recipes/default.rb: -------------------------------------------------------------------------------- 1 | remote_directory "/srv/gems" do 2 | owner "www-data" 3 | mode 0755 4 | source "packages" 5 | files_owner "www-data" 6 | files_group "www-data" 7 | files_mode 0644 8 | end 9 | -------------------------------------------------------------------------------- /chef-server-slice/spec/requests/cookbook_libraries_spec.rb: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') 2 | 3 | describe "/cookbook_libraries" do 4 | before(:each) do 5 | @response = request("/cookbook_libraries") 6 | end 7 | end -------------------------------------------------------------------------------- /chef-server-slice/spec/requests/cookbook_templates_spec.rb: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') 2 | 3 | describe "/cookbook_templates" do 4 | before(:each) do 5 | @response = request("/cookbook_templates") 6 | end 7 | end -------------------------------------------------------------------------------- /chef-server-slice/spec/requests/cookbook_attributes_spec.rb: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') 2 | 3 | describe "/cookbook_attributes" do 4 | before(:each) do 5 | @response = request("/cookbook_attributes") 6 | end 7 | end -------------------------------------------------------------------------------- /features/data/cookbooks/transfer_remote_files_definition/definitions/transfer.rb: -------------------------------------------------------------------------------- 1 | define :transfer_cookbook do 2 | remote_file "#{node[:tmpdir]}/#{params[:name]}" do 3 | source "easy.txt" 4 | cookbook "transfer_remote_files_definition" 5 | end 6 | end -------------------------------------------------------------------------------- /chef-server-slice/spec/requests/cookbook_definitions_spec.rb: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') 2 | 3 | describe "/cookbook_definitions" do 4 | before(:each) do 5 | @response = request("/cookbook_definitions") 6 | end 7 | end -------------------------------------------------------------------------------- /chef/examples/config/cookbooks/fakefile/templates/default/monkey.erb: -------------------------------------------------------------------------------- 1 | This is a <%= @one %> with <%= @el_che %> 2 | 3 | It was rendered on a system with the ipaddress of <%= @node[:ipaddress] %> 4 | 5 | But it's all about the conquest, with <%= @node[:fqdn ] %> 6 | -------------------------------------------------------------------------------- /example-repository/cookbooks/fakefile/templates/default/monkey.erb: -------------------------------------------------------------------------------- 1 | This is a <%= @one %> with <%= @el_che %> 2 | 3 | It was rendered on a system with the ipaddress of <%= @node[:ipaddress] %> 4 | 5 | But it's all about the conquest, with <%= @node[:fqdn ] %> 6 | -------------------------------------------------------------------------------- /chef-server-slice/app/views/cookbooks/index.html.haml: -------------------------------------------------------------------------------- 1 | - throw_content(:header, "Cookbooks") 2 | - @cl.each do |cookbook| 3 | .index 4 | %table 5 | %tr 6 | %td 7 | %a{ :href => slice_url(:cookbook, { :id => cookbook.name }) }= cookbook.name 8 | -------------------------------------------------------------------------------- /chef-server-slice/app/views/cookbooks/attribute_files.html.haml: -------------------------------------------------------------------------------- 1 | - throw_content(:header, "All Attributes Files") 2 | - @attribute_files.each do |af_hash| 3 | %h2= "#{af_hash[:cookbook]}" 4 | = partial(:attribute_file, :name => af_hash[:name], :contents => af_hash[:contents]) -------------------------------------------------------------------------------- /chef/examples/config/nodes/adam.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # Nodes should have a unique name 3 | ## 4 | name "adam" 5 | 6 | ## 7 | # Nodes can set arbitrary arguments 8 | ## 9 | owner "Adam Jacob" 10 | 11 | ## 12 | # Nodes should have recipes 13 | ## 14 | recipes "tempfile", "fakefile" 15 | -------------------------------------------------------------------------------- /chef/examples/config/nodes/latte.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # Nodes should have a unique name 3 | ## 4 | name "latte.local" 5 | 6 | ## 7 | # Nodes can set arbitrary arguments 8 | ## 9 | owner "Adam Jacob" 10 | 11 | ## 12 | # Nodes should have recipes 13 | ## 14 | recipes "tempfile", "fakefile" 15 | -------------------------------------------------------------------------------- /chef-server-slice/app/views/openid_login/index.html.haml: -------------------------------------------------------------------------------- 1 | - throw_content(:header, "Login") 2 | #login-form 3 | %form{ :method => "get", :action => url(:openid_login_submit) } 4 | %input{ :type => "text", :name => "username" }/ 5 | %input{ :type => "submit", :value => "Log In"}/ 6 | -------------------------------------------------------------------------------- /chef/examples/config/nodes/junglist.gen.nz.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # Nodes should have a unique name 3 | ## 4 | name "junglist.gen.nz" 5 | 6 | ## 7 | # Nodes can set arbitrary arguments 8 | ## 9 | owner "AJ Christensen" 10 | 11 | ## 12 | # Nodes should have recipes 13 | ## 14 | recipes "servicetest" 15 | -------------------------------------------------------------------------------- /chef-server-slice/app/views/search/_search_form.html.haml: -------------------------------------------------------------------------------- 1 | %form{ :method => "get", :action => slice_url(:search, { :id => index_name }) } 2 | Q: 3 | %input{ :type => "text", :name => "q" } 4 | A: 5 | %input{ :type => "text", :name => "a" } 6 | %input{ :type => "submit", :value => "Search #{index_name}" } 7 | -------------------------------------------------------------------------------- /chef-server/merb/session/session.rb: -------------------------------------------------------------------------------- 1 | module Merb 2 | module Session 3 | 4 | # The Merb::Session module gets mixed into Merb::SessionContainer to allow 5 | # app-level functionality; it will be included and methods will be available 6 | # through request.session as instance methods. 7 | 8 | end 9 | end -------------------------------------------------------------------------------- /chef/examples/search_syntax.rb: -------------------------------------------------------------------------------- 1 | search(:users, "allowed:#{node[:hostname]} or allowed:#{node[:tags]}") do |u| 2 | user "#{u['username']}" do 3 | uid "#{u['uid']}" 4 | gid "#{u['gid']}" 5 | username "#{u['username']}" 6 | homedir "#{u['homedir']}" 7 | action :create 8 | end 9 | end 10 | 11 | -------------------------------------------------------------------------------- /chef-server/app/controllers/exceptions.rb: -------------------------------------------------------------------------------- 1 | class Exceptions < Merb::Controller 2 | 3 | # handle NotFound exceptions (404) 4 | def not_found 5 | render :format => :html 6 | end 7 | 8 | # handle NotAcceptable exceptions (406) 9 | def not_acceptable 10 | render :format => :html 11 | end 12 | 13 | end -------------------------------------------------------------------------------- /chef/spec/data/nodes/test.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # Nodes should have a unique name 3 | ## 4 | name "test.example.com short" 5 | 6 | ## 7 | # Nodes can set arbitrary arguments 8 | ## 9 | sunshine "in" 10 | something "else" 11 | 12 | ## 13 | # Nodes should have recipes 14 | ## 15 | recipes "operations-master", "operations-monitoring" 16 | -------------------------------------------------------------------------------- /chef/spec/data/nodes/default.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # Nodes should have a unique name 3 | ## 4 | name "test.example.com default" 5 | 6 | ## 7 | # Nodes can set arbitrary arguments 8 | ## 9 | sunshine "in" 10 | something "else" 11 | 12 | ## 13 | # Nodes should have recipes 14 | ## 15 | recipes "operations-master", "operations-monitoring" 16 | -------------------------------------------------------------------------------- /chef/spec/data/nodes/test.example.com.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # Nodes should have a unique name 3 | ## 4 | name "test.example.com" 5 | 6 | ## 7 | # Nodes can set arbitrary arguments 8 | ## 9 | sunshine "in" 10 | something "else" 11 | 12 | ## 13 | # Nodes should have recipes 14 | ## 15 | recipes "operations-master", "operations-monitoring" 16 | -------------------------------------------------------------------------------- /chef-server-slice/app/views/nodes/index.html.haml: -------------------------------------------------------------------------------- 1 | - throw_content(:header, "Node List") 2 | - @node_list.each do |node| 3 | .node 4 | %a{ :href => slice_url(:node, { :id => node.gsub(/\./, "_") }) } 5 | = node 6 | - if session[:level] == :admin 7 | = delete_button slice_url(:node, { :id => node.gsub(/\./, "_") }), "Delete" 8 | -------------------------------------------------------------------------------- /chef-server-slice/app/views/search/index.html.haml: -------------------------------------------------------------------------------- 1 | - throw_content(:header, "Search Indexes") 2 | - @search_indexes.each do |index| 3 | .index 4 | %table 5 | %tr 6 | %td 7 | %a{ :href => slice_url(:search, { :id => index }) }= index 8 | %td 9 | = partial(:search_form, :index_name => index) 10 | -------------------------------------------------------------------------------- /chef/examples/node.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # Nodes should have a unique name 3 | ## 4 | name "ops1prod" 5 | 6 | ## 7 | # Nodes can set arbitrary arguments 8 | ## 9 | sunshine "in" 10 | something "else" 11 | that "is a cool ass trick" 12 | 13 | ## 14 | # Nodes should have recipes 15 | ## 16 | recipes "operations-master", "operations-monitoring" 17 | 18 | -------------------------------------------------------------------------------- /chef/spec/data/cookbooks/openldap/recipes/one.rb: -------------------------------------------------------------------------------- 1 | ## 2 | # Nodes should have a unique name 3 | ## 4 | name "test.example.com default" 5 | 6 | ## 7 | # Nodes can set arbitrary arguments 8 | ## 9 | sunshine "in" 10 | something "else" 11 | 12 | ## 13 | # Nodes should have recipes 14 | ## 15 | recipes "operations-master", "operations-monitoring" 16 | -------------------------------------------------------------------------------- /example-repository/cookbooks/servicetest/recipes/default.rb: -------------------------------------------------------------------------------- 1 | service "puppet-client" do 2 | service_name "puppet" 3 | pattern "puppetd" 4 | action :enable 5 | end 6 | 7 | file "/tmp/foo" do 8 | owner "aj" 9 | mode 0644 10 | action :create 11 | notifies :start, resources(:service => "puppet-client"), :immediate 12 | end 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | coverage 2 | doc 3 | .DS_Store 4 | packages/chef-server/db 5 | examples/search_index 6 | examples/store 7 | examples/openid-cstore 8 | examples/openid-db 9 | chef/pkg 10 | chef-server/pkg 11 | chef-server-slice/pkg 12 | chef/log 13 | chef-server/log 14 | log 15 | couchdb.stderr 16 | couchdb.stdout 17 | features/data/tmp/** 18 | *.swp 19 | -------------------------------------------------------------------------------- /chef/examples/config/cookbooks/servicetest/recipes/default.rb: -------------------------------------------------------------------------------- 1 | service "puppet-client" do 2 | service_name "puppet" 3 | pattern "puppetd" 4 | action :enable 5 | end 6 | 7 | file "/tmp/foo" do 8 | owner "aj" 9 | mode 0644 10 | action :create 11 | notifies :start, resources(:service => "puppet-client"), :immediate 12 | end 13 | -------------------------------------------------------------------------------- /chef-server-slice/NOTICE: -------------------------------------------------------------------------------- 1 | Chef NOTICE 2 | =========== 3 | 4 | Developed at HJK Solutions (http://www.hjksolutions.com). 5 | 6 | Contributors and Copyright holders: 7 | 8 | * Copyright 2008, Adam Jacob 9 | * Copyright 2008, Arjuna Christensen 10 | * Copyright 2008, Ezra Zygmuntowicz 11 | -------------------------------------------------------------------------------- /chef-server-slice/app/views/openid_register/show.html.haml: -------------------------------------------------------------------------------- 1 | - throw_content(:header, "Registered OpenID Node #{@registered_node.name}") 2 | %ol 3 | %li 4 | %a{ :href => slice_url(:openid_node , { :id => @registered_node.name.gsub(/\./, "_") }) } OpenID URL 5 | %li= "Validated: #{@registered_node.validated}" 6 | %li= "Admin: #{@registered_node.admin}" 7 | -------------------------------------------------------------------------------- /chef-server-slice/app/views/search_entries/show.html.haml: -------------------------------------------------------------------------------- 1 | - throw_content(:header, "Search Index #{h params[:search_id]} entry #{h params[:id]}") 2 | .search_result 3 | %h3= "#{h @entry[:index_name]} (#{h @entry[:id]})" 4 | %table 5 | - @entry.each do |k, v| 6 | %tr.attr_group 7 | %td.attr_name= k 8 | %td.attr_value= v.kind_of?(Array) ? v.join(",") : v -------------------------------------------------------------------------------- /chef-server/config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Merb.logger.info("Loaded PRODUCTION Environment...") 2 | Merb::Config.use { |c| 3 | c[:exception_details] = false 4 | c[:reload_classes] = false 5 | c[:log_level] = :error 6 | 7 | c[:log_file] = Merb.root / "log" / "production.log" 8 | # or redirect logger using IO handle 9 | # c[:log_stream] = STDOUT 10 | } 11 | -------------------------------------------------------------------------------- /chef-server/config/environments/staging.rb: -------------------------------------------------------------------------------- 1 | Merb.logger.info("Loaded STAGING Environment...") 2 | Merb::Config.use { |c| 3 | c[:exception_details] = false 4 | c[:reload_classes] = false 5 | c[:log_level] = :error 6 | 7 | c[:log_file] = Merb.root / "log" / "staging.log" 8 | # or redirect logger using IO handle 9 | # c[:log_stream] = STDOUT 10 | } 11 | -------------------------------------------------------------------------------- /chef-server/config/environments/rake.rb: -------------------------------------------------------------------------------- 1 | Merb.logger.info("Loaded RAKE Environment...") 2 | Merb::Config.use { |c| 3 | c[:exception_details] = true 4 | c[:reload_classes] = false 5 | c[:log_auto_flush ] = true 6 | 7 | c[:log_stream] = STDOUT 8 | c[:log_file] = nil 9 | # Or redirect logging into a file: 10 | # c[:log_file] = Merb.root / "log" / "development.log" 11 | } 12 | -------------------------------------------------------------------------------- /chef-server-slice/app/views/search_entries/index.html.haml: -------------------------------------------------------------------------------- 1 | - throw_content(:header, "Search Index #{h params[:search_id]}") 2 | - @entries.each do |result| 3 | .search_result 4 | %h3= "#{h result[:index_name]} (#{h result[:id]})" 5 | %table 6 | - result.each do |k, v| 7 | %tr.attr_group 8 | %td.attr_name= k 9 | %td.attr_value= v.kind_of?(Array) ? v.join(",") : v -------------------------------------------------------------------------------- /chef-server-slice/app/views/cookbook_templates/index.html.haml: -------------------------------------------------------------------------------- 1 | - throw_content(:header, "Cookbook Templates") 2 | - @templates.each do |template, data| 3 | .index 4 | %table 5 | %tr 6 | %td 7 | %a{ :href => url(:cookbook_template, { :cookbook_id => params[:cookbook_id], :id => data[:link_name], :version => data[:version] }) } 8 | = "#{data[:version]} - #{data[:name]}" 9 | -------------------------------------------------------------------------------- /chef-server-slice/app/views/nodes/_node.html.haml: -------------------------------------------------------------------------------- 1 | - if session[:level] == :admin 2 | .edit_area#node{:to_update => node.name} 3 | %h2 Recipes 4 | %ol 5 | = recipe_list(node) 6 | %h2 Attributes 7 | %ol 8 | = attribute_list(node) 9 | - else 10 | #node 11 | %h2 Recipes 12 | %ol 13 | = recipe_list(node) 14 | %h2 Attributes 15 | %ol 16 | = attribute_list(node) -------------------------------------------------------------------------------- /chef-server/config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Merb.logger.info("Loaded TEST Environment...") 2 | Merb::Config.use { |c| 3 | c[:testing] = true 4 | c[:exception_details] = true 5 | c[:log_auto_flush ] = true 6 | # log less in testing environment 7 | c[:log_level] = :error 8 | 9 | #c[:log_file] = Merb.root / "log" / "test.log" 10 | # or redirect logger using IO handle 11 | c[:log_stream] = STDOUT 12 | } 13 | -------------------------------------------------------------------------------- /chef/examples/config/chef-solo.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Example Chef Solo Config 3 | 4 | cookbook_path File.join(File.dirname(__FILE__), "cookbooks") 5 | node_path File.join(File.dirname(__FILE__), "nodes") 6 | search_index_path File.join(File.dirname(__FILE__), "..", "search_index") 7 | log_level :info 8 | file_store_path "/tmp/chef" 9 | file_cache_path "/tmp/chef/cache" 10 | 11 | Chef::Log::Formatter.show_time = false 12 | -------------------------------------------------------------------------------- /example-repository/cookbooks/fakefile/definitions/test.rb: -------------------------------------------------------------------------------- 1 | define :monkey, :eats => "bananna" do 2 | file "/tmp/monkeynews-#{params[:name]}" do 3 | owner "root" 4 | mode 0644 5 | action :create 6 | end 7 | 8 | file "/tmp/monkeynews-#{params[:name]}-second-#{params[:eats]}" do 9 | owner "root" 10 | mode 0644 11 | notifies :touch, resources(:file => "/tmp/monkeynews-#{params[:name]}"), :immediately 12 | end 13 | end -------------------------------------------------------------------------------- /chef/examples/config.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Example config 3 | # 4 | 5 | nodes_from([ 6 | Chef::Node::YAML => { 7 | :search_path => [ "/etc/chef/nodes" ] 8 | }, 9 | Chef::Node::PuppetExternalNode => { 10 | :command => "" 11 | }, 12 | :rest => { 13 | :search_url => "http://localhost:3000/nodes/#{node_name}" 14 | }, 15 | :iclassify => { 16 | :search_url => "http://localhost:3000/nodes/#{node_name}" 17 | } 18 | ]) 19 | 20 | 21 | -------------------------------------------------------------------------------- /chef/examples/config/cookbooks/fakefile/definitions/test.rb: -------------------------------------------------------------------------------- 1 | define :monkey, :eats => "bananna" do 2 | file "/tmp/monkeynews-#{params[:name]}" do 3 | owner "root" 4 | mode 0644 5 | action :create 6 | end 7 | 8 | file "/tmp/monkeynews-#{params[:name]}-second-#{params[:eats]}" do 9 | owner "root" 10 | mode 0644 11 | notifies :touch, resources(:file => "/tmp/monkeynews-#{params[:name]}"), :immediately 12 | end 13 | end -------------------------------------------------------------------------------- /chef/spec/data/cookbooks/openldap/attributes/default.rb: -------------------------------------------------------------------------------- 1 | chef_env ||= nil 2 | case chef_env 3 | when "prod" 4 | ldap_server "ops1prod" 5 | ldap_basedn "dc=hjksolutions,dc=com" 6 | ldap_replication_password "yes" 7 | when "corp" 8 | ldap_server "ops1prod" 9 | ldap_basedn "dc=hjksolutions,dc=com" 10 | ldap_replication_password "yougotit" 11 | else 12 | ldap_server "ops1prod" 13 | ldap_basedn "dc=hjksolutions,dc=com" 14 | ldap_replication_password "forsure" 15 | end 16 | -------------------------------------------------------------------------------- /chef-server/merb/merb-auth/strategies.rb: -------------------------------------------------------------------------------- 1 | # This file is specifically for you to define your strategies 2 | # 3 | # You should declare you strategies directly and/or use 4 | # Merb::Authentication.activate!(:label_of_strategy) 5 | # 6 | # To load and set the order of strategy processing 7 | 8 | Merb::Slices::config[:"merb-auth-slice-password"][:no_default_strategies] = true 9 | 10 | Merb::Authentication.activate!(:default_password_form) 11 | Merb::Authentication.activate!(:default_basic_auth) -------------------------------------------------------------------------------- /chef-server-slice/app/views/nodes/_action.html.haml: -------------------------------------------------------------------------------- 1 | %table 2 | - actions.each do |action, resource_hash| 3 | %tr 4 | %td.action_name= action.to_s 5 | %td.action_resources 6 | %table 7 | - resource_hash.keys.sort{ |a,b| a.to_s <=> b.to_s }.each do |rk| 8 | %tr 9 | %td.action_when= rk.to_s 10 | %td 11 | - resource_hash[rk].each do |resource| 12 | = partial(:resource, :resource => resource) 13 | -------------------------------------------------------------------------------- /chef/History.txt: -------------------------------------------------------------------------------- 1 | === 1.0.0 / 2008-03-05 2 | 3 | * 1 major enhancement 4 | * Birthday! 5 | 6 | Sun Apr 27 20:30:43 PDT 2008 7 | * Compiled first full recipes, and actually passed them to a provider. :) 8 | 9 | Mon Jun 9 01:57:58 PDT 2008 10 | * Compiled first full recipes over a network, with registration and authorization. 11 | 12 | Thu Jul 10 19:59:46 PDT 2008 13 | * Search support functional! 14 | 15 | Sat Aug 16 17:46:34 PDT 2008 16 | * Compiled a template! 17 | * Remote files and directories 18 | -------------------------------------------------------------------------------- /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.10" 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 | dependency "chef-server-slice" 10 | -------------------------------------------------------------------------------- /example-repository/cookbooks/tempfile/recipes/default.rb: -------------------------------------------------------------------------------- 1 | file "/tmp/glen" do 2 | owner "adam" 3 | mode 0755 4 | action "create" 5 | end 6 | 7 | file "/tmp/metallica" do 8 | action [ :create, :touch, :delete ] 9 | end 10 | 11 | directory "/tmp/marginal" do 12 | owner "adam" 13 | mode 0755 14 | action :create 15 | end 16 | 17 | remote_directory "/tmp/rubygems" do 18 | owner "adam" 19 | mode 0755 20 | source "packages" 21 | files_owner "adam" 22 | files_group "adam" 23 | files_mode 0755 24 | end 25 | -------------------------------------------------------------------------------- /chef/examples/config/cookbooks/tempfile/recipes/default.rb: -------------------------------------------------------------------------------- 1 | file "/tmp/glen" do 2 | owner "adam" 3 | mode 0755 4 | action "create" 5 | end 6 | 7 | file "/tmp/metallica" do 8 | action [ :create, :touch, :delete ] 9 | end 10 | 11 | directory "/tmp/marginal" do 12 | owner "adam" 13 | mode 0755 14 | action :create 15 | end 16 | 17 | remote_directory "/tmp/rubygems" do 18 | owner "adam" 19 | mode 0755 20 | source "packages" 21 | files_owner "adam" 22 | files_group "adam" 23 | files_mode 0755 24 | end 25 | -------------------------------------------------------------------------------- /example-repository/config/client.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Chef Client Config File 3 | # 4 | # Will be overwritten 5 | # 6 | 7 | log_level :info 8 | log_location STDOUT 9 | file_store_path "/var/chef/file_store" 10 | file_cache_path "/var/chef/cache" 11 | ssl_verify_mode :verify_none 12 | registration_url "http://127.0.0.1:4000" 13 | openid_url "http://127.0.0.1:4001" 14 | template_url "http://127.0.0.1:4000" 15 | remotefile_url "http://127.0.0.1:4000" 16 | search_url "http://127.0.0.1:4000" 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /chef-server-slice/spec/requests/search_spec.rb: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') 2 | 3 | describe "/chefserverslice/search/" do 4 | before(:all) do 5 | mount_slice 6 | end 7 | 8 | describe "GET /" do 9 | before(:each) do 10 | @response = request("/chefserverslice/search/") 11 | end 12 | 13 | it "should be successful" do 14 | @response.status.should be_successful 15 | end 16 | end 17 | 18 | after(:all) do 19 | dismount_slice 20 | end 21 | 22 | end 23 | -------------------------------------------------------------------------------- /chef-server/config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Merb.logger.info("Loaded DEVELOPMENT Environment...") 2 | Merb::Config.use { |c| 3 | c[:exception_details] = true 4 | c[:reload_templates] = true 5 | c[:reload_classes] = true 6 | c[:reload_time] = 0.5 7 | c[:ignore_tampered_cookies] = true 8 | c[:log_auto_flush ] = true 9 | c[:log_level] = :debug 10 | 11 | c[:log_stream] = STDOUT 12 | c[:log_file] = nil 13 | # Or redirect logging into a file: 14 | # c[:log_file] = Merb.root / "log" / "development.log" 15 | } 16 | -------------------------------------------------------------------------------- /chef-server-slice/spec/requests/nodes_spec.rb: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') 2 | 3 | describe "/chefserverslice/nodes/" do 4 | 5 | before(:all) do 6 | mount_slice 7 | end 8 | 9 | describe "GET /" do 10 | before(:each) do 11 | @response = request("/chefserverslice/nodes/") 12 | end 13 | 14 | it "should be successful" do 15 | @response.status.should be_successful 16 | end 17 | end 18 | 19 | after(:all) do 20 | dismount_slice 21 | end 22 | 23 | end 24 | -------------------------------------------------------------------------------- /chef-server-slice/spec/chef-server-slice_spec.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/spec_helper' 2 | 3 | describe "ChefServerSlice (module)" do 4 | 5 | # Implement your ChefServerSlice specs here 6 | 7 | # To spec ChefServerSlice you need to hook it up to the router like this: 8 | 9 | before :all do 10 | Merb::Router.prepare { add_slice(:ChefServerSlice) } if standalone? 11 | end 12 | 13 | after :all do 14 | Merb::Router.reset! if standalone? 15 | end 16 | 17 | 18 | it "should have proper specs" 19 | 20 | end 21 | -------------------------------------------------------------------------------- /chef-server-slice/TODO: -------------------------------------------------------------------------------- 1 | TODO: 2 | 3 | - Fix Chefserverslice.description and Chefserverslice.version 4 | - Fix LICENSE with your name 5 | - Fix Rakefile with your name and contact info 6 | - Add your code to lib/chef-server-slice.rb 7 | - Add your Merb rake tasks to lib/chefserverslice/merbtasks.rb 8 | 9 | Remove anything that you don't need: 10 | 11 | - app/controllers/main.rb Chefserverslice::Main controller 12 | - app/views/layout/chefserver.html.erb 13 | - spec/controllers/main_spec.rb controller specs 14 | - public/* any public files 15 | - stubs/* any stub files -------------------------------------------------------------------------------- /chef-server-slice/app/views/search/show.html.haml: -------------------------------------------------------------------------------- 1 | - throw_content(:header, "Search Results") 2 | .search 3 | = partial(:search_form, :index_name => params[:id]) 4 | .query 5 | %h2= "Search Query was #{params[:q] ? params[:q] : '*'}" 6 | - @results.each do |result| 7 | .search_result 8 | %h3= "#{h result[:index_name]} (#{h result[:id]})" 9 | %table 10 | - result.sort { |a,b| a[0].to_s <=> b[0].to_s }.each do |k, v| 11 | %tr.attr_group 12 | %td.attr_name= k 13 | %td.attr_value= v.kind_of?(Array) ? v.join(",") : v 14 | -------------------------------------------------------------------------------- /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 | couchdb_database 'chef_integration' 14 | -------------------------------------------------------------------------------- /chef-server/app/views/layout/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Fresh Merb App 5 | 6 | 7 | 8 | 9 | <%#= message[:notice] %> 10 | <%= catch_content :for_layout %> 11 | 12 | -------------------------------------------------------------------------------- /chef-server/public/.htaccess: -------------------------------------------------------------------------------- 1 | # Sets the default handler for FastCGI scripts 2 | AddHandler fastcgi-script .fcgi 3 | 4 | # If Apache2 is used together with mod_fcgid, 5 | # uncomment the line below and comment in the line 6 | # above to set the correct script handler 7 | #AddHandler fcgid-script .fcgi 8 | 9 | RewriteEngine On 10 | 11 | RewriteRule ^$ index.html [QSA] 12 | RewriteRule ^([^.]+)$ $1.html [QSA] 13 | RewriteCond %{REQUEST_FILENAME} !-f 14 | RewriteRule ^(.*)$ merb.fcgi [QSA,L] 15 | 16 | 17 | ErrorDocument 500 "

Application Error

Merb could not be reached" 18 | -------------------------------------------------------------------------------- /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-slice/spec/requests/openid_register_spec.rb: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') 2 | 3 | describe "/chefserverslice/openid_register" do 4 | 5 | before(:all) do 6 | mount_slice 7 | end 8 | 9 | describe "GET /" do 10 | before(:each) do 11 | @response = request("/chefserverslice/registrations") 12 | end 13 | 14 | it "should be successful" do 15 | @response.status.should be_successful 16 | end 17 | 18 | it "should have registered nodes list" do 19 | @response.should have_tag(:h3, :content=>"Registered OpenID Nodes List") 20 | end 21 | end 22 | 23 | after(:all) do 24 | dismount_slice 25 | end 26 | 27 | end 28 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-72-define/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: CHEF-72-define 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-59/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: CHEF-59 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 | package "zsh" do 21 | action [ :install, :upgrade, :remove, :upgrade, :purge ] 22 | end -------------------------------------------------------------------------------- /chef-server-slice/spec/requests/main_spec.rb: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') 2 | 3 | describe "/chefserverslice/" do 4 | 5 | before(:all) do 6 | mount_slice 7 | end 8 | 9 | describe "GET /" do 10 | 11 | before(:each) do 12 | @response = request("/chefserverslice/") 13 | end 14 | 15 | it "should be successful" do 16 | @response.status.should be_successful 17 | end 18 | 19 | # This is just an example of what you can do 20 | # You can also use the other webrat methods to click links, 21 | # fill up forms etc... 22 | it "should render the default slice layout" do 23 | @response.should have_tag(:title, :content => "Chef Server") 24 | end 25 | 26 | end 27 | 28 | after(:all) do 29 | dismount_slice 30 | end 31 | 32 | end 33 | -------------------------------------------------------------------------------- /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') -------------------------------------------------------------------------------- /chef-server-slice/spec/requests/cookbooks_spec.rb: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') 2 | 3 | describe "/chefserverslice/" do 4 | 5 | before(:all) do 6 | mount_slice 7 | end 8 | 9 | describe "GET /" do 10 | 11 | before(:each) do 12 | @response = request("/chefserverslice/") 13 | end 14 | 15 | it "should be successful" do 16 | @response.status.should be_successful 17 | end 18 | 19 | # This is just an example of what you can do 20 | # You can also use the other webrat methods to click links, 21 | # fill up forms etc... 22 | it "should render the default slice layout" do 23 | @response.should have_tag(:title, :content => "Chef Server") 24 | end 25 | 26 | end 27 | 28 | after(:all) do 29 | dismount_slice 30 | end 31 | 32 | end 33 | -------------------------------------------------------------------------------- /example-repository/config/server.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Chef Server Config File 3 | # 4 | # Dynamically generated by Chef - local modifications will be replaced 5 | # 6 | 7 | 8 | log_level :info 9 | log_location STDOUT 10 | file_store_path "/var/chef/file_store" 11 | file_cache_path "/var/chef/cache" 12 | ssl_verify_mode :verify_none 13 | registration_url "http://127.0.0.1:4000" 14 | openid_url "http://127.0.0.1:4001" 15 | template_url "http://127.0.0.1:4000" 16 | remotefile_url "http://127.0.0.1:4000" 17 | search_url "http://127.0.0.1:4000" 18 | cookbook_path [ "/var/chef/site-cookbooks", "/var/chef/cookbooks" ] 19 | openid_store_path "/var/chef/openid/store" 20 | openid_cstore_path "/var/chef/openid/cstore" 21 | search_index_path "/var/chef/search_index" 22 | 23 | Chef::Log::Formatter.show_time = false 24 | -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-57/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: CHEF-57 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 | script "boo" do 21 | user 'adam' 22 | code "print 'I like cheese';" 23 | interpreter "perl" 24 | end -------------------------------------------------------------------------------- /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/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 -------------------------------------------------------------------------------- /chef-server/config/init.rb: -------------------------------------------------------------------------------- 1 | # Go to http://wiki.merbivore.com/pages/init-rb 2 | 3 | require 'config/dependencies.rb' 4 | require 'chef' 5 | 6 | use_test :rspec 7 | use_template_engine :haml 8 | 9 | Merb::Config.use do |c| 10 | c[:use_mutex] = false 11 | c[:session_id_key] = '_chef_server_session_id' 12 | c[:session_secret_key] = Chef::Config.manage_secret_key 13 | c[:session_store] = 'cookie' 14 | c[:exception_details] = true 15 | c[:reload_classes] = false 16 | c[:log_level] = Chef::Config[:log_level] 17 | c[:log_stream] = Chef::Config[:log_location] 18 | end 19 | 20 | Merb::BootLoader.before_app_loads do 21 | # This will get executed after dependencies have been loaded but before your app's classes have loaded. 22 | end 23 | 24 | Merb::BootLoader.after_app_loads do 25 | # This will get executed after your app's classes have been loaded. 26 | end 27 | -------------------------------------------------------------------------------- /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/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 -------------------------------------------------------------------------------- /example-repository/cookbooks/template-test/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: template-test 3 | # Recipe:: default 4 | # 5 | # Copyright 2008, Opscode, Inc. 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 | template "/tmp/whazzit" do 21 | variables({ 22 | :whosa => "whazzit" 23 | }) 24 | source "whazzit.erb" 25 | end -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-56/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: CHEF-56 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 | service "gpm" do 21 | supports :status => true, :restart => true 22 | action [ :restart, :stop, :disable, :start, :enable ] 23 | end 24 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-44/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: CHEF-44 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 | 21 | execute "sleepy" do 22 | command "echo 'one monster'; sleep 5" 23 | end 24 | 25 | 26 | execute "sleepy2" do 27 | command "sleep 5" 28 | end 29 | 30 | -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-87/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: CHEF-87 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 "/tmp/.dotfile" do 21 | source ".dotfile" 22 | end 23 | 24 | execute "cat /tmp/.dotfile" 25 | 26 | file "/tmp/.dotfile" do 27 | action :delete 28 | end -------------------------------------------------------------------------------- /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 | cookbook_path File.join(supportdir, "cookbooks") 14 | openid_store_path File.join(tmpdir, "openid", "store") 15 | openid_cstore_path File.join(tmpdir, "openid", "cstore") 16 | search_index_path File.join(tmpdir, "search_index") 17 | validation_token 'ceelo' 18 | couchdb_database 'chef_integration' 19 | 20 | Chef::Log::Formatter.show_time = true 21 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-88/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: CHEF-88 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 "/tmp/rabbitmq-server_1.4.0-1_all.deb" do 21 | source "http://www.rabbitmq.com/releases/rabbitmq-server/v1.4.0/rabbitmq-server_1.4.0-1_all.deb" 22 | mode 0644 23 | end 24 | -------------------------------------------------------------------------------- /example-repository/cookbooks/prior_resource_test/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: prior_resource_test 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 "/tmp/prior_resource_test" do 21 | backup 16 22 | action :create 23 | end 24 | 25 | file "/tmp/prior_resource_test" do 26 | action :delete 27 | end 28 | -------------------------------------------------------------------------------- /example-repository/config/solo.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Chef Server Config File 3 | # 4 | # Dynamically generated by Chef - local modifications will be replaced 5 | # 6 | 7 | 8 | log_level :info 9 | log_location STDOUT 10 | file_store_path "/var/chef/file_store" 11 | file_cache_path "/var/chef/cache" 12 | ssl_verify_mode :verify_none 13 | registration_url "http://127.0.0.1:4000" 14 | openid_url "http://127.0.0.1:4001" 15 | template_url "http://127.0.0.1:4000" 16 | remotefile_url "http://127.0.0.1:4000" 17 | search_url "http://127.0.0.1:4000" 18 | cookbook_path [ "/var/chef/site-cookbooks", "/var/chef/cookbooks" ] 19 | node_path "/var/chef/nodes" 20 | openid_store_path "/var/chef/openid/store" 21 | openid_cstore_path "/var/chef/openid/cstore" 22 | merb_log_path "/var/log/chef-server.log" 23 | search_index_path "/var/chef/search_index" 24 | 25 | Chef::Log::Formatter.show_time = false 26 | -------------------------------------------------------------------------------- /features/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 | 21 | 22 | -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-72-define/definitions/define_remote_file.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: CHEF-72-define 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 | define :define_remote_file do 21 | remote_file "/tmp/chef-72-remote-#{params[:name]}.txt" do 22 | source "chef-72.txt" 23 | cookbook "CHEF-72-define" 24 | end 25 | end -------------------------------------------------------------------------------- /example-repository/cookbooks/http_request/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: http_request 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 | [ :get, :put, :post, :delete].each do |method| 21 | http_request "http_request.txt" do 22 | url "http://www.opscode.com/chef/http_request.txt" 23 | epic_fail true 24 | action method 25 | end 26 | end -------------------------------------------------------------------------------- /example-repository/cookbooks/remote_file/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: CHEF-89 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 "/tmp/seattle.txt" do 21 | source "seattle.txt" 22 | action :create 23 | end 24 | 25 | remote_file "/tmp/chef-wiki-homepage.txt" do 26 | source "http://wiki.opscode.com/display/chef/Home" 27 | action :create 28 | end 29 | -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-72-define/definitions/define_template.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: CHEF-72-define 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 | define :define_template, :sing => 'ahh' do 21 | template "/tmp/chef-72-#{params[:name]}.txt" do 22 | source "chef-72.txt.erb" 23 | variables({:sing => params[:sing]}) 24 | cookbook "CHEF-72-define" 25 | end 26 | end -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-94/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: CHEF-94 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 | gnome "mygnome" do 21 | underpants :one, :two, :three, :four 22 | end 23 | 24 | gnome "mygnome" do 25 | underpants [ :one, :two ] 26 | end 27 | 28 | puts node[:gnome][:underpants].inspect 29 | 30 | gnome "mygnome" do 31 | underpants node[:gnome][:underpants] 32 | end -------------------------------------------------------------------------------- /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 | 25 | def index 26 | @node_list = Chef::Node.list 27 | display @node_list 28 | end 29 | 30 | end 31 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-90/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: CHEF-90 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 | results = search(:node, '*', [ 'ipaddress', 'hostname' ]) 21 | Chef::Log.info(results.inspect) 22 | 23 | search(:node, '*', [ 'ipaddress', 'hostname' ]) do |n| 24 | Chef::Log.info("#{n['ipaddress']} #{n['hostname']}") 25 | end 26 | 27 | Chef::Log.info(search(:node, '*').inspect) 28 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /example-repository/cookbooks/template_caching_test/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: template_caching_test 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 | [ "one", "two", "three", "four" ].each do |value| 21 | template "/tmp/test_render.txt" do 22 | source "test_render.erb" 23 | variables({ 24 | :number => value 25 | }) 26 | action :create 27 | end 28 | 29 | file "/tmp/test_render.txt" do 30 | action :delete 31 | end 32 | end -------------------------------------------------------------------------------- /chef-server-slice/app/views/cookbooks/show.html.haml: -------------------------------------------------------------------------------- 1 | - throw_content(:header, "Cookbook #{h @cookbook.name}") 2 | .cookbook 3 | - if @cookbook.lib_files.length > 0 4 | %h2 Library Files 5 | - @cookbook.lib_files.each do |f| 6 | = partial(:syntax_highlight, :name => File.basename(f), :contents => f) 7 | 8 | - if @cookbook.attribute_files.length > 0 9 | %h2 Attribute Files 10 | - @cookbook.attribute_files.each do |f| 11 | = partial(:syntax_highlight, :name => File.basename(f), :contents => f) 12 | 13 | - if @cookbook.definition_files.length > 0 14 | %h2 Definition Files 15 | - @cookbook.definition_files.each do |f| 16 | = partial(:syntax_highlight, :name => File.basename(f), :contents => f) 17 | 18 | - if @cookbook.recipe_files.length > 0 19 | %h2 Recipe Files 20 | - @cookbook.recipe_files.each do |f| 21 | = partial(:syntax_highlight, :name => File.basename(f), :contents => f) 22 | 23 | - if @cookbook.template_files.length > 0 24 | %h2 Template Files 25 | - @cookbook.template_files.each do |f| 26 | %h3= File.basename(f) 27 | %div= syntax_highlight(f) 28 | 29 | -------------------------------------------------------------------------------- /chef-server-slice/app/views/openid_register/index.html.haml: -------------------------------------------------------------------------------- 1 | - throw_content(:header, "Registered OpenID Nodes List") 2 | %table 3 | - @registered_nodes.each do |node| 4 | %tr 5 | %td 6 | %a{ :href => slice_url(:registration, { :id => node.name }) } 7 | = h node.name 8 | %td 9 | - if session[:level] == :admin 10 | %form{ :method => "post", :action => slice_url(:validate_registration, { :id => node.name })} 11 | - submit_name = node.validated ? "Invalidate" : "Validate" 12 | %input{ :type => "submit", :name => submit_name, :value => submit_name } 13 | %form{ :method => "post", :action => slice_url(:admin_registration, { :id => node.name })} 14 | - submit_name = node.admin ? "Remove Admin Rights" : "Admin" 15 | %input{ :type => "submit", :name => submit_name, :value => submit_name } 16 | %form{ :method => "post", :action => slice_url(:registration, { :id => node.name })} 17 | %input{ :type => "hidden", :name => "_method", :value => "delete" } 18 | %input{ :type => "submit", :name => "Delete", :value => "Delete" } 19 | -------------------------------------------------------------------------------- /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/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 -------------------------------------------------------------------------------- /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/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-server-slice/app/views/openid_consumer/index.html.haml: -------------------------------------------------------------------------------- 1 | - throw_content(:header, "OpenID Relaying Party") 2 | -if session[:alert] 3 | .alert= h session[:alert] 4 | -if session[:error] 5 | .error= h session[:error] 6 | -if session[:success] 7 | .success= h session[:success] 8 | #verify-form 9 | %form{ :method => "get", "accept-charset" => "UTF-8", :action => slice_url(:openid_consumer_login) } 10 | Identifier: 11 | %input.openid{ :type => "text", :name => "openid_identifier" }/ 12 | %input{ :type => "submit", :value => "Verify"}/ 13 | %br 14 | %input#immediate{ :name => "immediate", :type => "checkbox" }/ 15 | %label{:for => "immediate"} Use immediate mode 16 | %br 17 | %input#immediate{ :name => "use_sreg", :type => "checkbox" }/ 18 | %label{:for => "use_sreg"} Request registration data 19 | %br 20 | %input#immediate{ :name => "use_pape", :type => "checkbox" }/ 21 | %label{:for => "use_pape"} Request phishing-resistent auth policy 22 | %br 23 | %input#immediate{ :name => "force_post", :type => "checkbox" }/ 24 | %label{:for => "force_post"} Force the transaction to POST 25 | %br 26 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-97/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: CHEF-97 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 | # Should not execute 21 | execute "echo onlyif" do 22 | only_if "test -d /tmp/CHEF-97" 23 | end 24 | 25 | directory "/tmp/CHEF-97" 26 | 27 | # Should execute 28 | execute "echo onlyif" 29 | 30 | # Should not execute 31 | execute "echo notif" do 32 | not_if "test -d /tmp/CHEF-97" 33 | end 34 | 35 | directory "/tmp/CHEF-97" do 36 | action :delete 37 | end 38 | 39 | # Should execute 40 | execute "echo notif" 41 | 42 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /features/steps/couchdb.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::OpenIDRegistration.create_design_document 25 | end 26 | 27 | After do 28 | r = Chef::REST.new(Chef::Config[:couchdb_url]) 29 | r.delete_rest("#{Chef::Config[:couchdb_database]}/") 30 | system("rm -rf #{tmpdir}") 31 | 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)) 26 | else 27 | converter.convert(code) 28 | end 29 | end 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /chef/lib/chef/resource/gem_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 GemPackage < Chef::Resource::Package 24 | 25 | def initialize(name, collection=nil, node=nil) 26 | super(name, collection, node) 27 | @resource_name = :gem_package 28 | @provider = Chef::Provider::Package::Rubygems 29 | end 30 | 31 | end 32 | end 33 | end -------------------------------------------------------------------------------- /features/steps/recipe.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/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/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-server-slice/app/views/layout/chef_server_slice.html.haml: -------------------------------------------------------------------------------- 1 | !!! XML 2 | !!! 3 | %html 4 | %head 5 | %title Chef Server 6 | %meta{"http-equiv" => "content-type", :content => "text/html; charset=utf-8" } 7 | %link{:rel => "stylesheet", :href => "/stylesheets/master-highlight.css", :type => "text/css", :media => "screen", :charset => "utf-8" } 8 | = js_include_tag "jquery-1.3.1.min", "jquery.jeditable.mini", "jquery.livequery" 9 | = js_include_tag "chef" 10 | %body 11 | .header 12 | %a{:href => slice_url(:searches) } Search 13 | | 14 | %a{:href => slice_url(:nodes) } Nodes 15 | | 16 | %a{:href => slice_url(:status) } Status 17 | | 18 | %a{:href => slice_url(:cookbooks) } Cookbooks 19 | | 20 | %a{:href => slice_url(:registrations)} Registrations 21 | - if session[:openid] 22 | | 23 | %a{:href => slice_url(:openid_consumer_logout)}= "Logout #{h session[:openid]}" 24 | = "(#{session[:level].to_s})" 25 | - else 26 | | 27 | %a{:href => slice_url(:openid_consumer)} Login 28 | %h3= catch_content :header 29 | - unless message.empty? 30 | = message[:error] 31 | = message[:notice] 32 | = catch_content :for_layout 33 | -------------------------------------------------------------------------------- /chef/spec/lib/chef/provider/easy.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Adam Jacob () 3 | # Copyright:: Copyright (c) 2008 Opscode, Inc. 4 | # License:: GNU General Public License version 2 or later 5 | # 6 | # This program and entire repository is free software; you can 7 | # redistribute it and/or modify it under the terms of the GNU 8 | # General Public License as published by the Free Software 9 | # Foundation; either version 2 of the License, or any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | # 20 | 21 | class Chef 22 | class Provider 23 | class Easy < Chef::Provider 24 | def load_current_resource 25 | true 26 | end 27 | 28 | def action_sell 29 | true 30 | end 31 | 32 | def action_buy 33 | true 34 | end 35 | end 36 | end 37 | end -------------------------------------------------------------------------------- /chef/spec/lib/chef/provider/snakeoil.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Adam Jacob () 3 | # Copyright:: Copyright (c) 2008 Opscode, Inc. 4 | # License:: GNU General Public License version 2 or later 5 | # 6 | # This program and entire repository is free software; you can 7 | # redistribute it and/or modify it under the terms of the GNU 8 | # General Public License as published by the Free Software 9 | # Foundation; either version 2 of the License, or any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | # 20 | 21 | class Chef 22 | class Provider 23 | class SnakeOil < Chef::Provider 24 | def load_current_resource 25 | true 26 | end 27 | 28 | def action_sell 29 | true 30 | end 31 | 32 | def action_buy 33 | true 34 | end 35 | end 36 | end 37 | 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 | # handle NotFound exceptions (404) 25 | def not_found 26 | display params 27 | end 28 | 29 | # handle NotAcceptable exceptions (406) 30 | def not_acceptable 31 | display params 32 | end 33 | 34 | # handle BadRequest exceptions (400) 35 | def bad_request 36 | display params 37 | end 38 | 39 | end 40 | -------------------------------------------------------------------------------- /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 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /features/steps/nodes.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 | ### 20 | # Given 21 | ### 22 | Given /^a validated node$/ do 23 | @client.validation_token = Chef::Config[:validation_token] = 'ceelo' 24 | @client.build_node 25 | @client.node.recipes = "integration_setup" 26 | @client.register 27 | @client.authenticate 28 | end 29 | 30 | Given /^it includes the recipe '(.+)'$/ do |recipe| 31 | @recipe = recipe 32 | @client.node.recipes << recipe 33 | @client.save_node 34 | end 35 | 36 | ### 37 | # When 38 | ### 39 | When /^the node is converged$/ do 40 | @client.run 41 | end 42 | 43 | -------------------------------------------------------------------------------- /chef-server-slice/app/helpers/nodes_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 NodesHelper 22 | def recipe_list(node) 23 | response = "" 24 | node.recipes.each do |recipe| 25 | response << "
  • #{recipe}
  • " 26 | end 27 | response 28 | end 29 | 30 | def attribute_list(node) 31 | response = "" 32 | node.each_attribute do |k,v| 33 | response << "
  • #{k}: #{v}
  • " 34 | end 35 | response 36 | end 37 | end 38 | 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /chef/lib/chef/exceptions.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 | class Exceptions 20 | class Cron < RuntimeError; end 21 | class Exec < RuntimeError; end 22 | class FileNotFound < RuntimeError; end 23 | class Package < RuntimeError; end 24 | class Service < RuntimeError; end 25 | class Route < RuntimeError; end 26 | class SearchIndex < RuntimeError; end 27 | class Override < RuntimeError; end 28 | class UnsupportedAction < RuntimeError; end 29 | class MissingLibrary < RuntimeError; end 30 | class User < RuntimeError; end 31 | class Group < RuntimeError; end 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /example-repository/cookbooks/CHEF-72/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: CHEF-72 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 | template "/tmp/chef-72.txt" do 21 | source "chef-72.txt.erb" 22 | variables({:sing => "what"}) 23 | end 24 | 25 | define_template "jail" do 26 | sing "scarecrow" 27 | end 28 | 29 | remote_file "/tmp/chef-72-remote.txt" do 30 | source "chef-72.txt" 31 | end 32 | 33 | define_remote_file "jail" do 34 | source "chef-72.txt" 35 | end 36 | 37 | %w{/tmp/chef-72.txt /tmp/chef-72-jail.txt /tmp/chef-72-remote.txt /tmp/chef-72-remote-jail.txt}.each do |filename| 38 | execute "cat #{filename}" do 39 | command "cat #{filename}" 40 | end 41 | 42 | file filename do 43 | action :delete 44 | end 45 | end -------------------------------------------------------------------------------- /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/lib/chef/provider/script.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 'chef/provider/execute' 21 | 22 | class Chef 23 | class Provider 24 | class Script < Chef::Provider::Execute 25 | 26 | def action_run 27 | tf = Tempfile.new("chef-script") 28 | tf.puts(@new_resource.code) 29 | tf.close 30 | 31 | fr = Chef::Resource::File.new(tf.path, nil, @node) 32 | fr.owner(@new_resource.user) 33 | fr.group(@new_resource.group) 34 | fr.run_action(:create) 35 | 36 | @new_resource.command("#{@new_resource.interpreter} #{tf.path}") 37 | super 38 | end 39 | 40 | end 41 | end 42 | end -------------------------------------------------------------------------------- /chef/spec/lib/chef/resource/one_two_three_four.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: John Hampton () 3 | # Copyright:: Copyright (c) 2009 CleanOffer, 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 OneTwoThreeFour < Chef::Resource 22 | attr_reader :i_can_count 23 | 24 | def initialize(name, collection=nil, node=nil) 25 | @resource_name = :one_two_three_four 26 | super(name, collection, node) 27 | end 28 | 29 | def i_can_count(tf) 30 | @i_can_count = tf 31 | end 32 | 33 | def something(arg=nil) 34 | set_if_args(@something, arg) do 35 | case arg 36 | when true, false 37 | @something = arg 38 | end 39 | end 40 | end 41 | end 42 | end 43 | end -------------------------------------------------------------------------------- /chef/spec/unit/resource/csh_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::Resource::Csh do 22 | 23 | before(:each) do 24 | @resource = Chef::Resource::Csh.new("fakey_fakerton") 25 | end 26 | 27 | it "should create a new Chef::Resource::Csh" do 28 | @resource.should be_a_kind_of(Chef::Resource) 29 | @resource.should be_a_kind_of(Chef::Resource::Csh) 30 | end 31 | 32 | it "should have a resource name of :csh" do 33 | @resource.resource_name.should eql(:csh) 34 | end 35 | 36 | it "should have an interpreter of csh" do 37 | @resource.interpreter.should eql("csh") 38 | end 39 | 40 | end -------------------------------------------------------------------------------- /chef/spec/unit/resource/bash_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::Resource::Bash do 22 | 23 | before(:each) do 24 | @resource = Chef::Resource::Bash.new("fakey_fakerton") 25 | end 26 | 27 | it "should create a new Chef::Resource::Bash" do 28 | @resource.should be_a_kind_of(Chef::Resource) 29 | @resource.should be_a_kind_of(Chef::Resource::Bash) 30 | end 31 | 32 | it "should have a resource name of :bash" do 33 | @resource.resource_name.should eql(:bash) 34 | end 35 | 36 | it "should have an interpreter of bash" do 37 | @resource.interpreter.should eql("bash") 38 | end 39 | 40 | end -------------------------------------------------------------------------------- /chef/spec/unit/resource/perl_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::Resource::Perl do 22 | 23 | before(:each) do 24 | @resource = Chef::Resource::Perl.new("fakey_fakerton") 25 | end 26 | 27 | it "should create a new Chef::Resource::Perl" do 28 | @resource.should be_a_kind_of(Chef::Resource) 29 | @resource.should be_a_kind_of(Chef::Resource::Perl) 30 | end 31 | 32 | it "should have a resource name of :perl" do 33 | @resource.resource_name.should eql(:perl) 34 | end 35 | 36 | it "should have an interpreter of perl" do 37 | @resource.interpreter.should eql("perl") 38 | end 39 | 40 | end -------------------------------------------------------------------------------- /chef/spec/unit/resource/ruby_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::Resource::Ruby do 22 | 23 | before(:each) do 24 | @resource = Chef::Resource::Ruby.new("fakey_fakerton") 25 | end 26 | 27 | it "should create a new Chef::Resource::Ruby" do 28 | @resource.should be_a_kind_of(Chef::Resource) 29 | @resource.should be_a_kind_of(Chef::Resource::Ruby) 30 | end 31 | 32 | it "should have a resource name of :ruby" do 33 | @resource.resource_name.should eql(:ruby) 34 | end 35 | 36 | it "should have an interpreter of ruby" do 37 | @resource.interpreter.should eql("ruby") 38 | end 39 | 40 | end -------------------------------------------------------------------------------- /chef/spec/unit/resource/python_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::Resource::Python do 22 | 23 | before(:each) do 24 | @resource = Chef::Resource::Python.new("fakey_fakerton") 25 | end 26 | 27 | it "should create a new Chef::Resource::Python" do 28 | @resource.should be_a_kind_of(Chef::Resource) 29 | @resource.should be_a_kind_of(Chef::Resource::Python) 30 | end 31 | 32 | it "should have a resource name of :python" do 33 | @resource.resource_name.should eql(:python) 34 | end 35 | 36 | it "should have an interpreter of python" do 37 | @resource.interpreter.should eql("python") 38 | end 39 | 40 | end -------------------------------------------------------------------------------- /chef/spec/unit/resource/apt_package_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::Resource::AptPackage, "initialize" do 22 | 23 | before(:each) do 24 | @resource = Chef::Resource::AptPackage.new("foo") 25 | end 26 | 27 | it "should return a Chef::Resource::AptPackage" do 28 | @resource.should be_a_kind_of(Chef::Resource::AptPackage) 29 | end 30 | 31 | it "should set the resource_name to :apt_package" do 32 | @resource.resource_name.should eql(:apt_package) 33 | end 34 | 35 | it "should set the provider to Chef::Provider::Package::Apt" do 36 | @resource.provider.should eql(Chef::Provider::Package::Apt) 37 | end 38 | end -------------------------------------------------------------------------------- /example-repository/cookbooks/global-onlyif/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: global-onlyif 3 | # Recipe:: default 4 | # 5 | # Copyright 2008, 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 "/tmp/neverhappen" do 21 | only_if do false; end 22 | end 23 | 24 | file "/tmp/stillnothappening" do 25 | not_if do true; end 26 | end 27 | 28 | file "/tmp/seriouslynothappening" do 29 | only_if "false" 30 | end 31 | 32 | file "/tmp/yepstillnot" do 33 | not_if "true" 34 | end 35 | 36 | file "/tmp/shouldhappen" do 37 | only_if do true; end 38 | action [:create, :delete] 39 | end 40 | 41 | file "/tmp/shouldhappen" do 42 | only_if "true" 43 | action [:create, :delete] 44 | end 45 | 46 | file "/tmp/shouldhappen" do 47 | not_if do false; end 48 | action [:create, :delete] 49 | end 50 | 51 | file "/tmp/shouldhappen" do 52 | not_if "false" 53 | action [:create, :delete] 54 | end 55 | 56 | -------------------------------------------------------------------------------- /chef/spec/unit/resource/gem_package_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::Resource::GemPackage, "initialize" do 22 | 23 | before(:each) do 24 | @resource = Chef::Resource::GemPackage.new("foo") 25 | end 26 | 27 | it "should return a Chef::Resource::GemPackage" do 28 | @resource.should be_a_kind_of(Chef::Resource::GemPackage) 29 | end 30 | 31 | it "should set the resource_name to :gem_package" do 32 | @resource.resource_name.should eql(:gem_package) 33 | end 34 | 35 | it "should set the provider to Chef::Provider::Package::Rubygems" do 36 | @resource.provider.should eql(Chef::Provider::Package::Rubygems) 37 | end 38 | end -------------------------------------------------------------------------------- /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 | s.add_dependency "stomp" 17 | s.add_dependency "stompserver" 18 | s.add_dependency "ferret" 19 | s.add_dependency "merb-core" 20 | s.add_dependency "merb-haml" 21 | s.add_dependency "merb-assets" 22 | s.add_dependency "merb-helpers" 23 | s.add_dependency "mongrel" 24 | s.add_dependency "haml" 25 | s.add_dependency "ruby-openid" 26 | s.add_dependency "json" 27 | s.add_dependency "syntax" 28 | 29 | s.bindir = "bin" 30 | s.executables = %w( chef-server chef-indexer ) 31 | s.files = %w(LICENSE README.rdoc Rakefile) + 32 | [ "README.txt", 33 | "LICENSE", 34 | "NOTICE", 35 | "{app}/**/*", 36 | "{config}/**/*", 37 | "{doc}/**/*", 38 | "{lib}/**/*", 39 | "{log}/**/*", 40 | "{merb}/**/*", 41 | "{public}/**/*", 42 | "{slices}/**/*", 43 | "{spec}/**/*", 44 | "{tasks}/**/*",].inject([]) { |m,dir| m << Dir.glob(dir) }.flatten 45 | end 46 | 47 | Rake::GemPackageTask.new(spec) do |pkg| 48 | pkg.gem_spec = spec 49 | end 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /chef/spec/unit/resource/portage_package_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::Resource::PortagePackage, "initialize" do 22 | 23 | before(:each) do 24 | @resource = Chef::Resource::PortagePackage.new("foo") 25 | end 26 | 27 | it "should return a Chef::Resource::PortagePackage" do 28 | @resource.should be_a_kind_of(Chef::Resource::PortagePackage) 29 | end 30 | 31 | it "should set the resource_name to :portage_package" do 32 | @resource.resource_name.should eql(:portage_package) 33 | end 34 | 35 | it "should set the provider to Chef::Provider::Package::Portage" do 36 | @resource.provider.should eql(Chef::Provider::Package::Portage) 37 | end 38 | end -------------------------------------------------------------------------------- /chef/spec/lib/chef/resource/cat.rb: -------------------------------------------------------------------------------- 1 | # Author:: Adam Jacob () 2 | # Copyright:: Copyright (c) 2008 Opscode, Inc. 3 | # License:: GNU General Public License version 2 or later 4 | # 5 | # This program and entire repository is free software; you can 6 | # redistribute it and/or modify it under the terms of the GNU 7 | # General Public License as published by the Free Software 8 | # Foundation; either version 2 of the License, or any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | # 19 | 20 | class Chef 21 | class Resource 22 | class Cat < Chef::Resource 23 | 24 | attr_accessor :action 25 | 26 | def initialize(name, collection=nil, node=nil) 27 | @resource_name = :cat 28 | super(name, collection, node) 29 | @action = "sell" 30 | end 31 | 32 | def pretty_kitty(arg=nil) 33 | set_if_args(@pretty_kitty, arg) do 34 | case arg 35 | when true, false 36 | @pretty_kitty = arg 37 | end 38 | end 39 | end 40 | end 41 | end 42 | end -------------------------------------------------------------------------------- /chef/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # Author:: Adam Jacob () 2 | # Copyright:: Copyright (c) 2008 Opscode, Inc. 3 | # License:: GNU General Public License version 2 or later 4 | # 5 | # This program and entire repository is free software; you can 6 | # redistribute it and/or modify it under the terms of the GNU 7 | # General Public License as published by the Free Software 8 | # Foundation; either version 2 of the License, or any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | # 19 | 20 | $:.unshift(File.join(File.dirname(__FILE__), "..", "lib")) 21 | 22 | require 'chef' 23 | 24 | chef_lib_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) 25 | Dir[ 26 | File.expand_path( 27 | File.join( 28 | chef_lib_path, 'chef', '**', '*.rb' 29 | ) 30 | ) 31 | ].sort.each do |lib| 32 | lib_short_path = lib.match("^#{chef_lib_path}#{File::SEPARATOR}(.+)$")[1] 33 | require lib_short_path 34 | end 35 | Dir[File.join(File.dirname(__FILE__), 'lib', '**', '*.rb')].sort.each { |lib| require lib } 36 | 37 | Chef::Config.log_level(:fatal) 38 | -------------------------------------------------------------------------------- /chef/lib/chef/resource/script.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/execute' 20 | 21 | class Chef 22 | class Resource 23 | class Script < Chef::Resource::Execute 24 | 25 | def initialize(name, collection=nil, node=nil) 26 | super(name, collection, node) 27 | @resource_name = :script 28 | @command = name 29 | @code = nil 30 | @interpreter = nil 31 | end 32 | 33 | def code(arg=nil) 34 | set_or_return( 35 | :code, 36 | arg, 37 | :kind_of => [ String ] 38 | ) 39 | end 40 | 41 | def interpreter(arg=nil) 42 | set_or_return( 43 | :interpreter, 44 | arg, 45 | :kind_of => [ String ] 46 | ) 47 | end 48 | 49 | end 50 | end 51 | end -------------------------------------------------------------------------------- /chef/tasks/rspec.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'rake' 3 | require 'spec/rake/spectask' 4 | 5 | CHEF_ROOT = File.join(File.dirname(__FILE__), "..") 6 | 7 | task :default => :spec 8 | 9 | desc "Run all specs in spec directory" 10 | Spec::Rake::SpecTask.new(:spec) do |t| 11 | t.spec_opts = ['--options', "\"#{CHEF_ROOT}/spec/spec.opts\""] 12 | t.spec_files = FileList['spec/**/*_spec.rb'] 13 | end 14 | 15 | namespace :spec do 16 | desc "Run all specs in spec directory with RCov" 17 | Spec::Rake::SpecTask.new(:rcov) do |t| 18 | t.spec_opts = ['--options', "\"#{CHEF_ROOT}/spec/spec.opts\""] 19 | t.spec_files = FileList['spec/**/*_spec.rb'] 20 | t.rcov = true 21 | t.rcov_opts = lambda do 22 | IO.readlines("#{CHEF_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten 23 | end 24 | end 25 | 26 | desc "Print Specdoc for all specs" 27 | Spec::Rake::SpecTask.new(:doc) do |t| 28 | t.spec_opts = ["--format", "specdoc", "--dry-run"] 29 | t.spec_files = FileList['spec/**/*_spec.rb'] 30 | end 31 | 32 | [:unit].each do |sub| 33 | desc "Run the specs under spec/#{sub}" 34 | Spec::Rake::SpecTask.new(sub) do |t| 35 | t.spec_opts = ['--options', "\"#{CHEF_ROOT}/spec/spec.opts\""] 36 | t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"] 37 | end 38 | end 39 | 40 | desc "Translate/upgrade specs using the built-in translator" 41 | task :translate do 42 | translator = ::Spec::Translator.new 43 | dir = CHEF_ROOT + '/spec' 44 | translator.translate(dir, dir) 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /chef/lib/chef/resource/remote_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 | require 'chef/resource/file' 20 | 21 | class Chef 22 | class Resource 23 | class RemoteFile < Chef::Resource::File 24 | 25 | def initialize(name, collection=nil, node=nil) 26 | super(name, collection, node) 27 | @resource_name = :remote_file 28 | @action = "create" 29 | @source = nil 30 | @cookbook = nil 31 | end 32 | 33 | def source(args=nil) 34 | set_or_return( 35 | :source, 36 | args, 37 | :kind_of => String 38 | ) 39 | end 40 | 41 | def cookbook(args=nil) 42 | set_or_return( 43 | :cookbook, 44 | args, 45 | :kind_of => String 46 | ) 47 | end 48 | 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /chef-server-slice/bin/chef-server: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # 3 | # ./chef-server - Serving up piping hot infrastructure! 4 | # 5 | # Author:: Adam Jacob () 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 | # Based on the 'merb' command, by Ezra 22 | 23 | require "rubygems" 24 | require "merb-core" 25 | require "chef" 26 | 27 | if ARGV[0] && ARGV[0] =~ /^[^-]/ 28 | ARGV.push "-H" 29 | end 30 | unless %w[-a --adapter -i --irb-console -r --script-runner].any? { |o| ARGV.index(o) } 31 | ARGV.push *%w[-a mongrel] 32 | end 33 | ARGV.push *[ "-I", File.join(File.dirname(__FILE__), "..", "lib", "init.rb") ] 34 | 35 | if index = ARGV.index("-C") 36 | config = ARGV[index+1] 37 | ARGV.delete("-C") 38 | ARGV.delete(config) 39 | Chef::Config.from_file(File.expand_path(config)) 40 | else 41 | Chef::Config.from_file( 42 | File.join("/etc", "chef", "server.rb") 43 | ) 44 | end 45 | 46 | Merb.start 47 | -------------------------------------------------------------------------------- /chef/spec/lib/chef/resource/zen_master.rb: -------------------------------------------------------------------------------- 1 | # Author:: Adam Jacob () 2 | # Copyright:: Copyright (c) 2008 Opscode, Inc. 3 | # License:: GNU General Public License version 2 or later 4 | # 5 | # This program and entire repository is free software; you can 6 | # redistribute it and/or modify it under the terms of the GNU 7 | # General Public License as published by the Free Software 8 | # Foundation; either version 2 of the License, or any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | # 19 | 20 | class Chef 21 | class Resource 22 | class ZenMaster < Chef::Resource 23 | attr_reader :peace 24 | 25 | def initialize(name, collection=nil, node=nil) 26 | @resource_name = :zen_master 27 | super(name, collection, node) 28 | end 29 | 30 | def peace(tf) 31 | @peace = tf 32 | end 33 | 34 | def something(arg=nil) 35 | set_if_args(@something, arg) do 36 | case arg 37 | when true, false 38 | @something = arg 39 | end 40 | end 41 | end 42 | end 43 | end 44 | end -------------------------------------------------------------------------------- /chef-server/merb/merb-auth/setup.rb: -------------------------------------------------------------------------------- 1 | # This file is specifically setup for use with the merb-auth plugin. 2 | # This file should be used to setup and configure your authentication stack. 3 | # It is not required and may safely be deleted. 4 | # 5 | # To change the parameter names for the password or login field you may set either of these two options 6 | # 7 | # Merb::Plugins.config[:"merb-auth"][:login_param] = :email 8 | # Merb::Plugins.config[:"merb-auth"][:password_param] = :my_password_field_name 9 | 10 | begin 11 | # Sets the default class ofr authentication. This is primarily used for 12 | # Plugins and the default strategies 13 | Merb::Authentication.user_class = User 14 | 15 | 16 | # Mixin the salted user mixin 17 | require 'merb-auth-more/mixins/salted_user' 18 | Merb::Authentication.user_class.class_eval{ include Merb::Authentication::Mixins::SaltedUser } 19 | 20 | # Setup the session serialization 21 | class Merb::Authentication 22 | 23 | def fetch_user(session_user_id) 24 | Merb::Authentication.user_class.get(session_user_id) 25 | end 26 | 27 | def store_user(user) 28 | user.nil? ? user : user.id 29 | end 30 | end 31 | 32 | rescue 33 | Merb.logger.error <<-TEXT 34 | 35 | You need to setup some kind of user class with merb-auth. 36 | Merb::Authentication.user_class = User 37 | 38 | If you want to fully customize your authentication you should use merb-core directly. 39 | 40 | See merb/merb-auth/setup.rb and strategies.rb to customize your setup 41 | 42 | TEXT 43 | end 44 | 45 | -------------------------------------------------------------------------------- /chef/lib/chef/resource/http_request.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' 20 | 21 | class Chef 22 | class Resource 23 | class HttpRequest < Chef::Resource 24 | 25 | def initialize(name, collection=nil, node=nil) 26 | super(name, collection, node) 27 | @resource_name = :http_request 28 | @message = name 29 | @url = nil 30 | @action = :get 31 | @allowed_actions.push(:get, :put, :post, :delete, :head, :options) 32 | end 33 | 34 | def url(args=nil) 35 | set_or_return( 36 | :url, 37 | args, 38 | :kind_of => String 39 | ) 40 | end 41 | 42 | def message(args=nil) 43 | set_or_return( 44 | :message, 45 | args, 46 | :kind_of => Object 47 | ) 48 | end 49 | 50 | end 51 | end 52 | end -------------------------------------------------------------------------------- /chef-server/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'rake/rdoctask' 3 | 4 | require 'merb-core' 5 | require 'merb-core/tasks/merb' 6 | require 'spec' 7 | require 'spec/rake/spectask' 8 | require 'chef' 9 | 10 | include FileUtils 11 | 12 | GEM = "chef-server" 13 | CHEF_SERVER_VERSION = "0.5.7" 14 | AUTHOR = "Opscode" 15 | EMAIL = "chef@opscode.com" 16 | HOMEPAGE = "http://wiki.opscode.com/display/chef" 17 | SUMMARY = "A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure." 18 | 19 | # Load the basic runtime dependencies; this will include 20 | # any plugins and therefore plugin rake tasks. 21 | init_env = ENV['MERB_ENV'] || 'rake' 22 | Merb.load_dependencies(:environment => init_env) 23 | 24 | # Get Merb plugins and dependencies 25 | Merb::Plugins.rakefiles.each { |r| require r } 26 | 27 | # Load any app level custom rakefile extensions from lib/tasks 28 | tasks_path = File.join(File.dirname(__FILE__), "lib", "tasks") 29 | rake_files = Dir["#{tasks_path}/*.rake"] 30 | rake_files.each{|rake_file| load rake_file } 31 | 32 | desc "Start runner environment" 33 | task :merb_env do 34 | Merb.start_environment(:environment => init_env, :adapter => 'runner') 35 | end 36 | 37 | require 'spec/rake/spectask' 38 | require 'merb-core/test/tasks/spectasks' 39 | desc 'Default: run spec examples' 40 | task :default => 'spec' 41 | 42 | ############################################################################## 43 | # ADD YOUR CUSTOM TASKS IN /lib/tasks 44 | # NAME YOUR RAKE FILES file_name.rake 45 | ############################################################################## 46 | -------------------------------------------------------------------------------- /chef-server/bin/chef-server: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # 3 | # ./chef-server - Serving up piping hot infrastructure! 4 | # 5 | # Author:: Adam Jacob () 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 | # Based on the 'merb' command, by Ezra 22 | 23 | require "rubygems" 24 | require "merb-core" 25 | require "chef" 26 | 27 | Dir.chdir File.join(File.dirname(__FILE__),"..") 28 | __DIR__ = Dir.getwd 29 | 30 | if ARGV[0] && ARGV[0] =~ /^[^-]/ 31 | ARGV.push "-H" 32 | end 33 | unless %w[-a --adapter -i --irb-console -r --script-runner].any? { |o| ARGV.index(o) } 34 | ARGV.push *%w[-a mongrel] 35 | end 36 | ARGV.push *[ "-I", File.join(__DIR__, "config", "init.rb") ] 37 | ARGV.push *[ "-m", __DIR__] 38 | 39 | if index = ARGV.index("-C") 40 | config = ARGV[index+1] 41 | ARGV.delete("-C") 42 | ARGV.delete(config) 43 | Chef::Config.from_file(File.expand_path(config)) 44 | else 45 | Chef::Config.from_file( 46 | File.join("/etc", "chef", "server.rb") 47 | ) 48 | end 49 | 50 | Merb.start 51 | -------------------------------------------------------------------------------- /chef/lib/chef/mixin/generate_url.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/platform' 20 | 21 | class Chef 22 | module Mixin 23 | module GenerateURL 24 | 25 | def generate_cookbook_url(url, cookbook, type, node, args=nil) 26 | new_url = nil 27 | if url =~ /^(http|https):\/\// 28 | new_url = url 29 | else 30 | new_url = "cookbooks/#{cookbook}/#{type}?" 31 | new_url += "id=#{url}" 32 | platform, version = Chef::Platform.find_platform_and_version(node) 33 | if type == "files" || type == "templates" 34 | new_url += "&platform=#{platform}&version=#{version}&fqdn=#{node[:fqdn]}" 35 | end 36 | if args 37 | args.each do |key, value| 38 | new_url += "&#{key}=#{value}" 39 | end 40 | end 41 | end 42 | 43 | return new_url 44 | end 45 | 46 | end 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /chef/spec/unit/resource/http_request_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::Resource::HttpRequest do 22 | 23 | before(:each) do 24 | @resource = Chef::Resource::HttpRequest.new("fakey_fakerton") 25 | end 26 | 27 | it "should create a new Chef::Resource::HttpRequest" do 28 | @resource.should be_a_kind_of(Chef::Resource) 29 | @resource.should be_a_kind_of(Chef::Resource::HttpRequest) 30 | end 31 | 32 | it "should set url to a string" do 33 | @resource.url "http://slashdot.org" 34 | @resource.url.should eql("http://slashdot.org") 35 | end 36 | 37 | it "should set the message to the name by default" do 38 | @resource.message.should eql("fakey_fakerton") 39 | end 40 | 41 | it "should set message to a string" do 42 | @resource.message "monkeybars" 43 | @resource.message.should eql("monkeybars") 44 | end 45 | 46 | end -------------------------------------------------------------------------------- /example-repository/config/rake.rb: -------------------------------------------------------------------------------- 1 | ### 2 | # Company and SSL Details 3 | ### 4 | 5 | # The company name - used for SSL certificates, and in various other places 6 | COMPANY_NAME = "Opscode" 7 | 8 | # The Country Name to use for SSL Certificates 9 | SSL_COUNTRY_NAME = "US" 10 | 11 | # The State Name to use for SSL Certificates 12 | SSL_STATE_NAME = "Washington" 13 | 14 | # The Locality Name for SSL - typically, the city 15 | SSL_LOCALITY_NAME = "Seattle" 16 | 17 | # What department? 18 | SSL_ORGANIZATIONAL_UNIT_NAME = "Operations" 19 | 20 | # The SSL contact email address 21 | SSL_EMAIL_ADDRESS = "ops@example.com" 22 | 23 | # License for new Cookbooks 24 | # Can be :apachev2 or :none 25 | NEW_COOKBOOK_LICENSE = :apachev2 26 | 27 | ########################## 28 | # Chef Repository Layout # 29 | ########################## 30 | 31 | # Where to find upstream cookbooks 32 | COOKBOOK_PATH = "/var/chef/cookbooks" 33 | 34 | # Where to find site-local modifications to upstream cookbooks 35 | SITE_COOKBOOK_PATH = "/var/chef/site-cookbooks" 36 | 37 | # Chef Config Path 38 | CHEF_CONFIG_PATH = "/etc/chef" 39 | 40 | # The location of the Chef Server Config file (on the server) 41 | CHEF_SERVER_CONFIG = File.join(CHEF_CONFIG_PATH, "server.rb") 42 | 43 | # The location of the Chef Client Config file (on the client) 44 | CHEF_CLIENT_CONFIG = File.join(CHEF_CONFIG_PATH, "client.rb") 45 | 46 | ### 47 | # Useful Extras (which you probably don't need to change) 48 | ### 49 | 50 | # The top of the repository checkout 51 | TOPDIR = File.expand_path(File.join(File.dirname(__FILE__), "..")) 52 | 53 | # Where to store certificates generated with ssl_cert 54 | CADIR = File.expand_path(File.join(TOPDIR, "certificates")) 55 | -------------------------------------------------------------------------------- /features/support/env.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 | %w{chef chef-server}.each do |inc_dir| 20 | $: << File.join(File.dirname(__FILE__), '..', '..', inc_dir, 'lib') 21 | end 22 | 23 | require 'spec/expectations' 24 | require 'chef' 25 | require 'chef/config' 26 | require 'chef/client' 27 | require 'tmpdir' 28 | 29 | Chef::Config.from_file(File.join(File.dirname(__FILE__), '..', 'data', 'config', 'client.rb')) 30 | Ohai::Config[:log_level] = :error 31 | 32 | class ChefWorld 33 | attr_accessor :client, :tmpdir 34 | 35 | def initialize 36 | @client = Chef::Client.new 37 | @tmpdir = File.join(Dir.tmpdir, "chef_integration") 38 | @cleanup_files = Array.new 39 | @cleanup_dirs = Array.new 40 | @recipe = nil 41 | end 42 | end 43 | 44 | World do 45 | ChefWorld.new 46 | end 47 | 48 | After do 49 | @cleanup_files.each do |file| 50 | system("rm #{file}") 51 | end 52 | @cleanup_dirs.each do |dir| 53 | system("rm -rf #{dir}") 54 | end 55 | end 56 | 57 | -------------------------------------------------------------------------------- /chef/lib/chef.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 | $:.unshift(File.dirname(__FILE__)) unless 20 | $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) 21 | 22 | require 'rubygems' 23 | require 'extlib' 24 | require 'chef/exceptions' 25 | require 'chef/log' 26 | require 'chef/config' 27 | Dir[File.join(File.dirname(__FILE__), 'chef/mixin/**/*.rb')].sort.each { |lib| require lib } 28 | 29 | class Chef 30 | VERSION = '0.5.7' 31 | 32 | class << self 33 | def fatal!(msg, err = -1) 34 | Chef::Log.fatal(msg) 35 | exit err 36 | end 37 | end 38 | end 39 | 40 | # Adds a Dir.glob to Ruby 1.8.5, for compat 41 | if RUBY_VERSION < "1.8.6" 42 | class Dir 43 | class << self 44 | alias_method :glob_, :glob 45 | def glob(*args) 46 | raise ArgumentError if args.empty? 47 | args.inject([]) { |r, p| r + glob_(p) } 48 | end 49 | alias_method :[], :glob 50 | end 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /chef/spec/unit/provider_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::Provider do 22 | before(:each) do 23 | @resource = Chef::Resource.new("funk") 24 | @node = Chef::Node.new 25 | @node.name "latte" 26 | @provider = Chef::Provider.new(@node, @resource) 27 | end 28 | 29 | it "should return a Chef::Provider" do 30 | @provider.should be_a_kind_of(Chef::Provider) 31 | end 32 | 33 | it "should store the resource passed to new as new_resource" do 34 | @provider.new_resource.should eql(@resource) 35 | end 36 | 37 | it "should store the node passed to new as node" do 38 | @provider.node.should eql(@node) 39 | end 40 | 41 | it "should have nil for current_resource by default" do 42 | @provider.current_resource.should eql(nil) 43 | end 44 | 45 | it "should return true for action_nothing" do 46 | @provider.action_nothing.should eql(true) 47 | end 48 | 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 | def recipe_list(node) 24 | data = Chef::Node.load(node) 25 | response = "" 26 | data.recipes.each do |recipe| 27 | response << " #{recipe}" 28 | end 29 | response 30 | end 31 | 32 | def get_info(node) 33 | data = Chef::Node.load(node) 34 | response = "" 35 | response << "FQDN: #{data[:fqdn]}
    " 36 | response << "IP Address: #{data[:ipaddress]}
    " 37 | ohai_time = Time.at(data[:ohai_time]) 38 | response << "Last Check-in: #{ohai_time}
    " 39 | response << "Uptime: #{data[:uptime]}
    " 40 | response << "Platform: #{data[:platform]} #{data[:platform_version]}" 41 | response 42 | end 43 | end 44 | 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /features/steps/run_client.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 | ### 20 | # When 21 | ### 22 | When /^I run the chef\-client$/ do 23 | log_level = ENV["LOG_LEVEL"] ? ENV["LOG_LEVEL"] : "error" 24 | status = Chef::Mixin::Command.popen4( 25 | "chef-client -l #{log_level} -c #{File.expand_path(File.join(File.dirname(__FILE__), '..', 'data', 'config', 'client.rb'))}", :waitlast => true) do |p, i, o, e| 26 | i.close 27 | @stdout = o.gets(nil) 28 | @stderr = e.gets(nil) 29 | end 30 | @status = status 31 | end 32 | 33 | ### 34 | # Then 35 | ### 36 | Then /^the run should exit '(.+)'$/ do |exit_code| 37 | begin 38 | @status.exitstatus.should eql(exit_code.to_i) 39 | rescue 40 | print_output 41 | raise 42 | end 43 | print_output if ENV["LOG_LEVEL"] == "debug" 44 | end 45 | 46 | def print_output 47 | puts "--- run stdout:" 48 | puts @stdout 49 | puts "--- run stderr" 50 | puts @stderr 51 | end 52 | 53 | Then /^stdout should have '(.+)'$/ do |to_match| 54 | @stdout.should match(/#{to_match}/m) 55 | end 56 | -------------------------------------------------------------------------------- /chef/lib/chef/resource/template.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/file' 20 | 21 | class Chef 22 | class Resource 23 | class Template < Chef::Resource::File 24 | 25 | def initialize(name, collection=nil, node=nil) 26 | super(name, collection, node) 27 | @resource_name = :template 28 | @action = "create" 29 | @source = nil 30 | @cookbook = nil 31 | @variables = Hash.new 32 | end 33 | 34 | def source(file=nil) 35 | set_or_return( 36 | :source, 37 | file, 38 | :kind_of => [ String ] 39 | ) 40 | end 41 | 42 | def variables(args=nil) 43 | set_or_return( 44 | :variables, 45 | args, 46 | :kind_of => [ Hash ] 47 | ) 48 | end 49 | 50 | def cookbook(args=nil) 51 | set_or_return( 52 | :cookbook, 53 | args, 54 | :kind_of => [ String ] 55 | ) 56 | end 57 | 58 | end 59 | end 60 | end -------------------------------------------------------------------------------- /chef-server-slice/app/controllers/cookbooks.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 | require 'chef' / 'cookbook_loader' 21 | 22 | class ChefServerSlice::Cookbooks < ChefServerSlice::Application 23 | 24 | provides :html, :json 25 | 26 | def index 27 | @cl = Chef::CookbookLoader.new 28 | display @cl 29 | end 30 | 31 | def show 32 | @cl = Chef::CookbookLoader.new 33 | @cookbook = @cl[params[:id]] 34 | raise NotFound unless @cookbook 35 | display @cookbook 36 | end 37 | 38 | def recipe_files 39 | @recipe_files = load_all_files(:recipes) 40 | display @recipe_files 41 | end 42 | 43 | def attribute_files 44 | @attribute_files = load_all_files(:attributes) 45 | display @attribute_files 46 | end 47 | 48 | def definition_files 49 | @definition_files = load_all_files(:definitions) 50 | display @definition_files 51 | end 52 | 53 | def library_files 54 | @lib_files = load_all_files(:libraries) 55 | display @lib_files 56 | end 57 | 58 | end 59 | -------------------------------------------------------------------------------- /features/manage_files.feature: -------------------------------------------------------------------------------- 1 | Feature: Manage Files 2 | In order to save time 3 | As a Developer 4 | I want to manage files declaratively 5 | 6 | Scenario: Create a file 7 | Given a validated node 8 | And it includes the recipe 'manage_files::create_a_file' 9 | When I run the chef-client 10 | Then the run should exit '0' 11 | And a file named 'create_a_file.txt' should exist 12 | 13 | Scenario: Set the owner of a created file 14 | Given a validated node 15 | And it includes the recipe 'manage_files::set_the_owner_of_a_created_file' 16 | When I run the chef-client 17 | Then the run should exit '0' 18 | And the file named 'create_a_file.txt' should be owned by 'nobody' 19 | 20 | Scenario: Delete a file 21 | Given a validated node 22 | And it includes the recipe 'manage_files::delete_a_file' 23 | When I run the chef-client 24 | Then the run should exit '0' 25 | And a file named 'create_a_file.txt' should not exist 26 | 27 | Scenario: Delete a file that already does not exist 28 | Given a validated node 29 | And it includes the recipe 'manage_files::delete_a_file_that_does_not_already_exist' 30 | When I run the chef-client 31 | Then the run should exit '1' 32 | And stdout should have 'Cannot delete file' 33 | 34 | Scenario: Touch a file 35 | Given a validated node 36 | And it includes the recipe 'manage_files::touch_a_file' 37 | And we have an empty file named 'touch_test.txt' 38 | And we have the atime/mtime of 'touch_test.txt' 39 | When I run the chef-client 40 | Then the run should exit '0' 41 | And the atime of 'touch_test.txt' should be different 42 | And the mtime of 'touch_test.txt' should be different 43 | -------------------------------------------------------------------------------- /chef/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'rake/gempackagetask' 3 | require 'rake/rdoctask' 4 | require './tasks/rspec.rb' 5 | 6 | GEM = "chef" 7 | CHEF_VERSION = "0.5.7" 8 | AUTHOR = "Adam Jacob" 9 | EMAIL = "adam@opscode.com" 10 | HOMEPAGE = "http://wiki.opscode.com/display/chef" 11 | SUMMARY = "A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure." 12 | 13 | spec = Gem::Specification.new do |s| 14 | s.name = GEM 15 | s.version = CHEF_VERSION 16 | s.platform = Gem::Platform::RUBY 17 | s.has_rdoc = true 18 | s.extra_rdoc_files = ["README.txt", "LICENSE" ] 19 | s.summary = SUMMARY 20 | s.description = s.summary 21 | s.author = AUTHOR 22 | s.email = EMAIL 23 | s.homepage = HOMEPAGE 24 | 25 | # Uncomment this to add a dependency 26 | s.add_dependency "ruby-openid" 27 | s.add_dependency "json" 28 | s.add_dependency "erubis" 29 | s.add_dependency "extlib" 30 | s.add_dependency "stomp" 31 | s.add_dependency "ohai" 32 | 33 | s.bindir = "bin" 34 | s.executables = %w( chef-client chef-solo ) 35 | 36 | s.require_path = 'lib' 37 | s.files = %w(LICENSE README.txt Rakefile) + Dir.glob("{lib,specs,config,examples}/**/*") 38 | end 39 | 40 | Rake::GemPackageTask.new(spec) do |pkg| 41 | pkg.gem_spec = spec 42 | end 43 | 44 | Rake::RDocTask.new do |rd| 45 | rd.rdoc_files.include("lib/**/*.rb") 46 | end 47 | 48 | task :install => :package do 49 | sh %{sudo gem install pkg/#{GEM}-#{CHEF_VERSION} --no-rdoc --no-ri} 50 | end 51 | 52 | task :uninstall do 53 | sh %{sudo gem uninstall #{GEM} -x -v #{CHEF_VERSION} } 54 | end 55 | 56 | desc "create a gemspec file" 57 | task :make_spec do 58 | File.open("#{GEM}.gemspec", "w") do |file| 59 | file.puts spec.to_ruby 60 | end 61 | end 62 | 63 | -------------------------------------------------------------------------------- /chef/spec/unit/resource/script_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::Resource::Script do 22 | 23 | before(:each) do 24 | @resource = Chef::Resource::Script.new("fakey_fakerton") 25 | end 26 | 27 | it "should create a new Chef::Resource::Script" do 28 | @resource.should be_a_kind_of(Chef::Resource) 29 | @resource.should be_a_kind_of(Chef::Resource::Script) 30 | end 31 | 32 | it "should have a resource name of :script" do 33 | @resource.resource_name.should eql(:script) 34 | end 35 | 36 | it "should set command to the argument provided to new" do 37 | @resource.command.should eql("fakey_fakerton") 38 | end 39 | 40 | it "should accept a string for the code" do 41 | @resource.code "hey jude" 42 | @resource.code.should eql("hey jude") 43 | end 44 | 45 | it "should accept a string for the interpreter" do 46 | @resource.interpreter "naaaaNaNaNaaNaaNaaNaa" 47 | @resource.interpreter.should eql("naaaaNaNaNaaNaaNaaNaa") 48 | end 49 | 50 | end -------------------------------------------------------------------------------- /chef/lib/chef/resource/group.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 Group < Chef::Resource 22 | 23 | def initialize(name, collection=nil, node=nil) 24 | super(name, collection, node) 25 | @resource_name = :group 26 | @group_name = name 27 | @gid = nil 28 | @members = [] 29 | @action = :create 30 | @allowed_actions.push(:create, :remove, :modify, :manage) 31 | end 32 | 33 | def group_name(arg=nil) 34 | set_or_return( 35 | :group_name, 36 | arg, 37 | :kind_of => [ String ] 38 | ) 39 | end 40 | 41 | def gid(arg=nil) 42 | set_or_return( 43 | :gid, 44 | arg, 45 | :kind_of => [ Integer ] 46 | ) 47 | end 48 | 49 | def members(arg=nil) 50 | converted_members = arg.is_a?(String) ? [].push(arg) : arg 51 | set_or_return( 52 | :members, 53 | converted_members, 54 | :kind_of => [ Array ] 55 | ) 56 | end 57 | 58 | end 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /chef-server-slice/app/controllers/search.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 | require 'chef' / 'search' 21 | require 'chef' / 'queue' 22 | 23 | class ChefServerSlice::Search < ChefServerSlice::Application 24 | 25 | provides :html, :json 26 | 27 | def index 28 | @s = Chef::Search.new 29 | @search_indexes = @s.list_indexes 30 | display @search_indexes 31 | end 32 | 33 | def show 34 | @s = Chef::Search.new 35 | 36 | query = params[:q].nil? ? "*" : (params[:q].empty? ? "*" : params[:q]) 37 | attributes = params[:a].nil? ? [] : params[:a].split(",").collect { |a| a.to_sym } 38 | @results = @s.search(params[:id], query, attributes) 39 | 40 | display @results 41 | end 42 | 43 | def destroy 44 | @s = Chef::Search.new 45 | @entries = @s.search(params[:id], "*") 46 | @entries.each do |entry| 47 | Chef::Queue.send_msg(:queue, :remove, entry) 48 | end 49 | @status = 202 50 | if content_type == :html 51 | redirect url(:search) 52 | else 53 | display @entries 54 | end 55 | end 56 | 57 | end 58 | -------------------------------------------------------------------------------- /chef/examples/sample_recipe.rb: -------------------------------------------------------------------------------- 1 | include_recipe "openldap" 2 | include_recipe "openldap::client" 3 | include_recipe "openldap::server" 4 | include_recipe "resolver" 5 | include_recipe "base" 6 | 7 | exec "restart-apache" do 8 | path "/usr/bin:/usr/local/bin" 9 | command "/etc/init.d/apache2 restart" 10 | action :nothing 11 | end 12 | 13 | service "apache2" do 14 | insure "running" 15 | has_restart true 16 | end 17 | 18 | file "/etc/nsswitch.conf" do 19 | owner "root" 20 | group "root" 21 | mode 0644 22 | notifies :restart, resources("service[openldap]"), :immediately 23 | end 24 | 25 | service "apache2" do 26 | action "enabled" 27 | subscribes :restart, resources("/etc/nsswitch.conf"), :immediately 28 | end 29 | 30 | file "/etc/ldap.conf" do 31 | owner "root" 32 | group "root" 33 | mode 0644 34 | end 35 | 36 | file "/srv/monkey" do 37 | insure "present" 38 | owner "root" 39 | group "root" 40 | mode 0644 41 | end 42 | 43 | file "/srv/owl" do 44 | insure "present" 45 | owner "root" 46 | group "root" 47 | mode 0644 48 | end 49 | 50 | file "/srv/zen" do 51 | insure "absent" 52 | end 53 | 54 | # 55 | # file "/srv/monkey" do |f| 56 | # f.insure = "present" 57 | # f.owner = "adam" 58 | # f.group = "adam" 59 | # f.mode = 0644 60 | # f.before = resources(:file => "/etc/nsswitch.conf") 61 | # end 62 | # 63 | # file "/etc/ldap-nss.conf" do |f| 64 | # f.insure = "present" 65 | # f.owner = "root" 66 | # f.group = "root" 67 | # f.mode = 0644 68 | # f.notifies = :refresh, resources(:file => "/etc/ldap.conf") 69 | # end 70 | # 71 | # file "/etc/coffee.conf" do |f| 72 | # f.insure = "present" 73 | # f.owner = "root" 74 | # f.group = "root" 75 | # f.mode = 0644 76 | # f.subscribes = :polio, resources(:file => "/etc/nsswitch.conf") 77 | # end -------------------------------------------------------------------------------- /chef/lib/chef/resource/link.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' 20 | 21 | class Chef 22 | class Resource 23 | class Link < Chef::Resource 24 | 25 | def initialize(name, collection=nil, node=nil) 26 | super(name, collection, node) 27 | @resource_name = :link 28 | @to = nil 29 | @action = :create 30 | @link_type = :symbolic 31 | @target_file = name 32 | @allowed_actions.push(:create, :delete) 33 | end 34 | 35 | def to(arg=nil) 36 | set_or_return( 37 | :source_file, 38 | arg, 39 | :kind_of => String 40 | ) 41 | end 42 | 43 | def target_file(arg=nil) 44 | set_or_return( 45 | :target_file, 46 | arg, 47 | :kind_of => String 48 | ) 49 | end 50 | 51 | def link_type(arg=nil) 52 | real_arg = arg.kind_of?(String) ? arg.to_sym : arg 53 | set_or_return( 54 | :link_type, 55 | real_arg, 56 | :equal_to => [ :symbolic, :hard ] 57 | ) 58 | end 59 | 60 | end 61 | end 62 | end -------------------------------------------------------------------------------- /chef/spec/unit/resource/remote_file_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::Resource::RemoteFile do 22 | 23 | before(:each) do 24 | @resource = Chef::Resource::RemoteFile.new("fakey_fakerton") 25 | end 26 | 27 | describe "initialize" do 28 | it "should create a new Chef::Resource::RemoteFile" do 29 | @resource.should be_a_kind_of(Chef::Resource) 30 | @resource.should be_a_kind_of(Chef::Resource::File) 31 | @resource.should be_a_kind_of(Chef::Resource::RemoteFile) 32 | end 33 | end 34 | 35 | describe "source" do 36 | it "should accept a string for the remote file source" do 37 | @resource.source "something" 38 | @resource.source.should eql("something") 39 | end 40 | end 41 | 42 | describe "cookbook" do 43 | it "should accept a string for the cookbook name" do 44 | @resource.cookbook "something" 45 | @resource.cookbook.should eql("something") 46 | end 47 | 48 | it "should default to nil" do 49 | @resource.cookbook.should == nil 50 | end 51 | end 52 | 53 | end -------------------------------------------------------------------------------- /chef-server/config/router.rb: -------------------------------------------------------------------------------- 1 | # Merb::Router is the request routing mapper for the merb framework. 2 | # 3 | # You can route a specific URL to a controller / action pair: 4 | # 5 | # match("/contact"). 6 | # to(:controller => "info", :action => "contact") 7 | # 8 | # You can define placeholder parts of the url with the :symbol notation. These 9 | # placeholders will be available in the params hash of your controllers. For example: 10 | # 11 | # match("/books/:book_id/:action"). 12 | # to(:controller => "books") 13 | # 14 | # Or, use placeholders in the "to" results for more complicated routing, e.g.: 15 | # 16 | # match("/admin/:module/:controller/:action/:id"). 17 | # to(:controller => ":module/:controller") 18 | # 19 | # You can specify conditions on the placeholder by passing a hash as the second 20 | # argument of "match" 21 | # 22 | # match("/registration/:course_name", :course_name => /^[a-z]{3,5}-\d{5}$/). 23 | # to(:controller => "registration") 24 | # 25 | # You can also use regular expressions, deferred routes, and many other options. 26 | # See merb/specs/merb/router.rb for a fairly complete usage sample. 27 | 28 | Merb.logger.info("Compiling routes...") 29 | Merb::Router.prepare do 30 | # RESTful routes 31 | # resources :posts 32 | 33 | # Adds the required routes for merb-auth using the password slice 34 | # slice(:merb_auth_slice_password, :name_prefix => nil, :path_prefix => "") 35 | slice(:chef_server_slice) 36 | # This is the default route for /:controller/:action/:id 37 | # This is fine for most cases. If you're heavily using resource-based 38 | # routes, you may want to comment/remove this line to prevent 39 | # clients from calling your create or destroy actions with a GET 40 | default_routes 41 | 42 | # Change this for your home page to be available at / 43 | # match('/').to(:controller => 'whatever', :action =>'index') 44 | end 45 | --------------------------------------------------------------------------------