diff --git a/.gitignore b/.gitignore index cc48a87..30bf0e8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /.chef .rvmrc Gemfile.lock +.kitchen diff --git a/README.md b/README.md index 1c3ab49..c2779c8 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,16 @@ Installs and configures Couchbase. REQUIREMENTS ============ -Platform --------- +Chef 0.10.10 and Ohai 0.6.12 are required due to the use of platform_family. -Tested on Ubuntu 12.04. +Platforms +--------- + +* Debian family (Debian, Ubuntu etc) +* Red Hat family (Redhat, CentOS, Oracle etc) +* Microsoft Windows + +Note that Couchbase Server does not support Windows 8 or Server 2012: see http://www.couchbase.com/issues/browse/MB-7016. ATTRIBUTES ========== @@ -17,29 +23,32 @@ ATTRIBUTES couchbase-server ---------------- -* `node['couchbase']['server']['edition']` - The edition of couchbase-server to install, "community" or "enterprise" -* `node['couchbase']['server']['version']` - The version of couchbase-server to install -* `node['couchbase']['server']['package_file]` - The couchbase-server package file to download and install -* `node['couchbase']['server']['package_base_url]` - The url path to download the couchbase-server package file from -* `node['couchbase']['server']['package_full_url]` - The full url to the couchbase-server package file to download and install -* `node['couchbase']['server']['database_path']` - The directory Couchbase should persist data to -* `node['couchbase']['server']['log_dir']` - The directory Couchbase should log to -* `node['couchbase']['server']['memory_quota_mb']` - The per server RAM quota for the entire cluster in megabytes - defaults to Couchbase's maximum allowed value -* `node['couchbase']['server']['username']` - The cluster's username for the REST API and Admin UI -* `node['couchbase']['server']['password']` - The cluster's password for the REST API and Admin UI +* `node['couchbase']['server']['edition']` - The edition of couchbase-server to install, "community" or "enterprise" +* `node['couchbase']['server']['version']` - The version of couchbase-server to install +* `node['couchbase']['server']['package_file']` - The couchbase-server package file to download and install +* `node['couchbase']['server']['package_base_url']` - The url path to download the couchbase-server package file from +* `node['couchbase']['server']['package_full_url']` - The full url to the couchbase-server package file to download and install +* `node['couchbase']['server']['database_path']` - The directory Couchbase should persist data to +* `node['couchbase']['server']['log_dir']` - The directory Couchbase should log to +* `node['couchbase']['server']['memory_quota_mb']` - The per server RAM quota for the entire cluster in megabytes + defaults to Couchbase's maximum allowed value +* `node['couchbase']['server']['username']` - The cluster's username for the REST API and Admin UI +* `node['couchbase']['server']['password']` - The cluster's password for the REST API and Admin UI -libcouchbase ------------- +client +------ -* `node['couchbase']['libcouchbase']['version']` - The version of libcouchbase to install -* `node['couchbase']['libcouchbase']['package_base_url]` - The url path to download the libcouchbase packages files from +* `node['couchbase']['client']['version']` - The version of libcouchbase to install -libvbucket ----------- +moxi +---- -* `node['couchbase']['libvbucket']['version']` - The version of libvbucket to install -* `node['couchbase']['libvbucket']['package_base_url]` - The url path to download the libvbucket packages files from +* `node['couchbase']['moxi']['version']` - The version of moxi to install +* `node['couchbase']['moxi']['package_file']` - The package file to download +* `node['couchbase']['moxi']['package_base_url']` - The base URL where the packages are located +* `node['couchbase']['moxi']['package_full_url']` - The full URL to the moxi package +* `node['couchbase']['moxi']['cluster_server']` - The bootstrap server for moxi to contact for the node list +* `node['couchbase']['moxi']['cluster_rest_url']` - The bootstrap server's full REST URL for retrieving the initial node list RECIPES ======= @@ -47,13 +56,18 @@ RECIPES client ------ -Installs the libvbucket and libcouchbase packages. +Installs the libcouchbase2 and devel packages. server ------ Installs the couchbase-server package and starts the couchbase-server service. +moxi +---- + +Installs the moxi-server package and starts the moxi-server service. + RESOURCES/PROVIDERS =================== @@ -177,6 +191,7 @@ LICENSE AND AUTHOR Author:: Chris Griego () Author:: Morgan Nelson () +Author:: Julian Dunn () Copyright 2012, getaroom diff --git a/attributes/client.rb b/attributes/client.rb index b5c5d3d..50a6f02 100644 --- a/attributes/client.rb +++ b/attributes/client.rb @@ -1,7 +1 @@ -codename = %w(oneiric lucid).include?(node['lsb']['codename']) ? node['lsb']['codename'] : "oneiric" - -default['couchbase']['libcouchbase']['version'] = "1.0.4-1" -default['couchbase']['libvbucket']['version'] = "1.8.0.4-1" - -default['couchbase']['libcouchbase']['package_base_url'] = "http://packages.couchbase.com/ubuntu/pool/#{codename}/main/libc/libcouchbase" -default['couchbase']['libvbucket']['package_base_url'] = "http://packages.couchbase.com/ubuntu/pool/#{codename}/main/libv/libvbucket" +default['couchbase']['client']['version'] = '2.0.3-1' diff --git a/attributes/moxi.rb b/attributes/moxi.rb new file mode 100644 index 0000000..f994c4a --- /dev/null +++ b/attributes/moxi.rb @@ -0,0 +1,18 @@ +package_machine = node['kernel']['machine'] == "x86_64" ? "x86_64" : "x86" + +default['couchbase']['moxi']['version'] = "1.8.1" + +case platform +when "ubuntu", "debian" + default['couchbase']['moxi']['package_file'] = "moxi-server_#{package_machine}_#{node['couchbase']['moxi']['version']}.deb" +when "redhat", "centos", "scientific", "amazon", "fedora" + default['couchbase']['moxi']['package_file'] = "moxi-server_#{package_machine}_#{node['couchbase']['moxi']['version']}.rpm" +else + Chef::Log.error("Moxi Server is not supported on #{platform}") +end + +default['couchbase']['moxi']['package_base_url'] = "http://packages.couchbase.com/releases/#{node['couchbase']['moxi']['version']}" +default['couchbase']['moxi']['package_full_url'] = "#{node['couchbase']['moxi']['package_base_url']}/#{node['couchbase']['moxi']['package_file']}" + +default['couchbase']['moxi']['cluster_server'] = 'couchbase01' +default['couchbase']['moxi']['cluster_rest_url'] = "http://#{node['couchbase']['moxi']['cluster_server']}:8091/pools/default/bucketsStreaming/default" diff --git a/attributes/server.rb b/attributes/server.rb index f277ec6..ff3f284 100644 --- a/attributes/server.rb +++ b/attributes/server.rb @@ -1,14 +1,36 @@ package_machine = node['kernel']['machine'] == "x86_64" ? "x86_64" : "x86" default['couchbase']['server']['edition'] = "community" -default['couchbase']['server']['version'] = "1.8.0" +default['couchbase']['server']['version'] = "2.0.0" + +case node['platform_family'] +when "debian" + default['couchbase']['server']['package_file'] = "couchbase-server-#{node['couchbase']['server']['edition']}_#{package_machine}_#{node['couchbase']['server']['version']}.deb" +when "rhel" + default['couchbase']['server']['package_file'] = "couchbase-server-#{node['couchbase']['server']['edition']}_#{package_machine}_#{node['couchbase']['server']['version']}.rpm" +when "windows" + if node['kernel']['machine'] != 'x86_64' + Chef::Log.error("Couchbase Server on Windows must be installed on a 64-bit machine") + else + default['couchbase']['server']['package_file'] = "couchbase-server-#{node['couchbase']['server']['edition']}_#{package_machine}_#{node['couchbase']['server']['version']}.setup.exe" + end +else + Chef::Log.error("Couchbase Server is not supported on #{platform_family}") +end -default['couchbase']['server']['package_file'] = "couchbase-server-#{node['couchbase']['server']['edition']}_#{package_machine}_#{node['couchbase']['server']['version']}.deb" default['couchbase']['server']['package_base_url'] = "http://packages.couchbase.com/releases/#{node['couchbase']['server']['version']}" default['couchbase']['server']['package_full_url'] = "#{node['couchbase']['server']['package_base_url']}/#{node['couchbase']['server']['package_file']}" -default['couchbase']['server']['database_path'] = "/opt/couchbase/var/lib/couchbase/data" -default['couchbase']['server']['log_dir'] = "/opt/couchbase/var/lib/couchbase/logs" +case node['platform_family'] +when "windows" + default['couchbase']['server']['install_dir'] = "C:\Program Files\Couchbase\Server\" + default['couchbase']['server']['database_path'] = "#{node['couchbase']['server']['install_dir']}\var\lib\couchbase\data" + default['couchbase']['server']['log_dir'] = "#{node['couchbase']['server']['install_dir']}\var\lib\couchbase\logs" +else + default['couchbase']['server']['install_dir'] = "/opt/couchbase" + default['couchbase']['server']['database_path'] = "#{node['couchbase']['server']['install_dir']}/var/lib/couchbase/data" + default['couchbase']['server']['log_dir'] = "#{node['couchbase']['server']['install_dir']}/var/lib/couchbase/logs" +end default['couchbase']['server']['username'] = "Administrator" default['couchbase']['server']['password'] = "" diff --git a/chef-repo/.chef/knife.rb b/chef-repo/.chef/knife.rb deleted file mode 100644 index 7304127..0000000 --- a/chef-repo/.chef/knife.rb +++ /dev/null @@ -1,19 +0,0 @@ -current_dir = File.dirname(__FILE__) - -ENV['OPSCODE_USER'] ||= ENV['USER'] - -log_level :info -log_location STDOUT -node_name ENV['OPSCODE_USER'] -client_key "#{ENV['HOME']}/.chef/#{ENV['OPSCODE_USER']}.pem" -validation_client_name "#{ENV['ORGNAME']}-validator" -validation_key "#{ENV['HOME']}/.chef/#{ENV['ORGNAME']}-validator.pem" -chef_server_url "https://api.opscode.com/organizations/#{ENV['ORGNAME']}" -cache_type 'BasicFile' -cache_options :path => "#{ENV['HOME']}/.chef/checksums" -cookbook_path ["#{current_dir}/../cookbooks"] - -knife[:aws_access_key_id] = ENV['AWS_ACCESS_KEY_ID'] -knife[:aws_secret_access_key] = ENV['AWS_SECRET_ACCESS_KEY'] -knife[:aws_ssh_key_id] = ENV['AWS_SSH_KEY_ID'] -knife[:identity_file] = "#{ENV['HOME']}/.ssh/#{ENV['AWS_SSH_KEY_ID']}.pem" diff --git a/chef-repo/cookbooks/chef_handler/CHANGELOG.md b/chef-repo/cookbooks/chef_handler/CHANGELOG.md deleted file mode 100644 index 20737f5..0000000 --- a/chef-repo/cookbooks/chef_handler/CHANGELOG.md +++ /dev/null @@ -1,12 +0,0 @@ -## v1.0.6: - -* [COOK-1069] - typo in chef_handler readme - -## v1.0.4: - -* [COOK-654] dont try and access a class before it has been loaded -* fix bad boolean check (if vs unless) - -## v1.0.2: - -* [COOK-620] ensure handler code is reloaded during daemonized chef runs diff --git a/chef-repo/cookbooks/chef_handler/CONTRIBUTING b/chef-repo/cookbooks/chef_handler/CONTRIBUTING deleted file mode 100644 index 7963d9c..0000000 --- a/chef-repo/cookbooks/chef_handler/CONTRIBUTING +++ /dev/null @@ -1,29 +0,0 @@ -If you would like to contribute, please open a ticket in JIRA: - -* http://tickets.opscode.com - -Create the ticket in the COOK project and use the cookbook name as the -component. - -For all code contributions, we ask that contributors sign a -contributor license agreement (CLA). Instructions may be found here: - -* http://wiki.opscode.com/display/chef/How+to+Contribute - -When contributing changes to individual cookbooks, please do not -modify the version number in the metadata.rb. Also please do not -update the CHANGELOG.md for a new version. Not all changes to a -cookbook may be merged and released in the same versions. Opscode will -handle the version updates during the release process. You are welcome -to correct typos or otherwise make updates documentation in the -README. - -If a contribution adds new platforms or platform versions, indicate -such in the body of the commit message(s), and update the relevant -COOK ticket. When writing commit messages, it is helpful for others if -you indicate the COOK ticket. For example: - - git commit -m '[COOK-1041] Updated pool resource to correctly delete.' - -In the ticket itself, it is also helpful if you include log output of -a successful Chef run, but this is not absolutely required. diff --git a/chef-repo/cookbooks/chef_handler/LICENSE b/chef-repo/cookbooks/chef_handler/LICENSE deleted file mode 100644 index 11069ed..0000000 --- a/chef-repo/cookbooks/chef_handler/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/chef-repo/cookbooks/chef_handler/README.md b/chef-repo/cookbooks/chef_handler/README.md deleted file mode 100644 index ab99822..0000000 --- a/chef-repo/cookbooks/chef_handler/README.md +++ /dev/null @@ -1,103 +0,0 @@ -Description -=========== - -Creates a configured handler path for distributing [Chef report and exception handlers](http://wiki.opscode.com/display/chef/Exception+and+Report+Handlers). Also exposes an LWRP for enabling Chef handlers from within recipe code (as opposed to hard coding in the client.rb file). This is useful for cookbook authors who may want to ship a product specific handler (see the `cloudkick` cookbook for an example) with their cookbook. - -Attributes -========== - -`node["chef_handler"]["handler_path"]` - location to drop off handlers directory, default is `/var/chef/handlers`. - -Resource/Provider -================= - -`chef_handler` --------------- - -Requires, configures and enables handlers on the node for the current Chef run. Also has the ability to pass arguments to the handlers initializer. This allows initialization data to be pulled from a node's attribute data. - -It is best to declare `chef_handler` resources early on in the compile phase so they are available to fire for any exceptions during the Chef run. If you have a base role you would want any recipes that register Chef handlers to come first in the run_list. - -### Actions - -- :enable: Enables the Chef handler for the current Chef run on the current node -- :disable: Disables the Chef handler for the current Chef run on the current node - -### Attribute Parameters - -- class_name: name attribute. The name of the handler class (can be module name-spaced). -- source: full path to the handler file. can also be a gem path if the handler ships as part of a Ruby gem. -- arguments: an array of arguments to pass the handler's class initializer -- supports: type of Chef Handler to register as, ie :report, :exception or both. default is `:report => true, :exception => true` - -### Example - - # register the Chef::Handler::JsonFile handler - # that ships with the Chef gem - chef_handler "Chef::Handler::JsonFile" do - source "chef/handler/json_file" - arguments :path => '/var/chef/reports' - action :enable - end - - # do the same but during the compile phase - chef_handler "Chef::Handler::JsonFile" do - source "chef/handler/json_file" - arguments :path => '/var/chef/reports' - action :nothing - end.run_action(:enable) - - # handle exceptions only - chef_handler "Chef::Handler::JsonFile" do - source "chef/handler/json_file" - arguments :path => '/var/chef/reports' - supports :exception => true - action :enable - end - - - # enable the CloudkickHandler which was - # dropped off in the default handler path. - # passes the oauth key/secret to the handler's - # intializer. - chef_handler "CloudkickHandler" do - source "#{node['chef_handler']['handler_path']}/cloudkick_handler.rb" - arguments [node['cloudkick']['oauth_key'], node['cloudkick']['oauth_secret']] - action :enable - end - - -Usage -===== - -default -------- - -Put the recipe `chef_handler` at the start of the node's run list to make sure that custom handlers are dropped off early on in the Chef run and available for later recipes. - -For information on how to write report and exception handlers for Chef, please see the Chef wiki pages: -http://wiki.opscode.com/display/chef/Exception+and+Report+Handlers - -json_file ---------- - -Leverages the `chef_handler` LWRP to automatically register the `Chef::Handler::JsonFile` handler that ships as part of Chef. This handler serializes the run status data to a JSON file located at `/var/chef/reports`. - -License and Author -================== - -Author:: Seth Chisamore () - -Copyright:: 2011, Opscode, Inc - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/chef-repo/cookbooks/chef_handler/attributes/default.rb b/chef-repo/cookbooks/chef_handler/attributes/default.rb deleted file mode 100644 index 245b6e9..0000000 --- a/chef-repo/cookbooks/chef_handler/attributes/default.rb +++ /dev/null @@ -1,21 +0,0 @@ -# -# Author:: Seth Chisamore () -# Cookbook Name:: chef_handlers -# Attribute:: default -# -# Copyright 2011, Opscode, Inc -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -default["chef_handler"]["handler_path"] = "#{File.expand_path(File.join(Chef::Config[:file_cache_path],'..'))}/handlers" \ No newline at end of file diff --git a/chef-repo/cookbooks/chef_handler/files/default/handlers/README b/chef-repo/cookbooks/chef_handler/files/default/handlers/README deleted file mode 100644 index b575066..0000000 --- a/chef-repo/cookbooks/chef_handler/files/default/handlers/README +++ /dev/null @@ -1 +0,0 @@ -This directory contains Chef handlers to distribute to your nodes. diff --git a/chef-repo/cookbooks/chef_handler/metadata.json b/chef-repo/cookbooks/chef_handler/metadata.json deleted file mode 100644 index c5d85f1..0000000 --- a/chef-repo/cookbooks/chef_handler/metadata.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "chef_handler", - "description": "Distribute and enable Chef Exception and Report handlers", - "long_description": "Description\n===========\n\nCreates a configured handler path for distributing [Chef report and exception handlers](http://wiki.opscode.com/display/chef/Exception+and+Report+Handlers). Also exposes an LWRP for enabling Chef handlers from within recipe code (as opposed to hard coding in the client.rb file). This is useful for cookbook authors who may want to ship a product specific handler (see the `cloudkick` cookbook for an example) with their cookbook.\n\nAttributes\n==========\n\n`node[\"chef_handler\"][\"handler_path\"]` - location to drop off handlers directory, default is `/var/chef/handlers`.\n\nResource/Provider\n=================\n\n`chef_handler`\n--------------\n\nRequires, configures and enables handlers on the node for the current Chef run. Also has the ability to pass arguments to the handlers initializer. This allows initialization data to be pulled from a node's attribute data.\n\nIt is best to declare `chef_handler` resources early on in the compile phase so they are available to fire for any exceptions during the Chef run. If you have a base role you would want any recipes that register Chef handlers to come first in the run_list.\n\n### Actions\n\n- :enable: Enables the Chef handler for the current Chef run on the current node\n- :disable: Disables the Chef handler for the current Chef run on the current node\n\n### Attribute Parameters\n\n- class_name: name attribute. The name of the handler class (can be module name-spaced).\n- source: full path to the handler file. can also be a gem path if the handler ships as part of a Ruby gem.\n- arguments: an array of arguments to pass the handler's class initializer\n- supports: type of Chef Handler to register as, ie :report, :exception or both. default is `:report => true, :exception => true`\n\n### Example\n\n # register the Chef::Handler::JsonFile handler\n # that ships with the Chef gem\n chef_handler \"Chef::Handler::JsonFile\" do\n source \"chef/handler/json_file\"\n arguments :path => '/var/chef/reports'\n action :enable\n end\n\n # do the same but during the compile phase\n chef_handler \"Chef::Handler::JsonFile\" do\n source \"chef/handler/json_file\"\n arguments :path => '/var/chef/reports'\n action :nothing\n end.run_action(:enable)\n\n # handle exceptions only\n chef_handler \"Chef::Handler::JsonFile\" do\n source \"chef/handler/json_file\"\n arguments :path => '/var/chef/reports'\n supports :exception => true\n action :enable\n end\n\n\n # enable the CloudkickHandler which was\n # dropped off in the default handler path.\n # passes the oauth key/secret to the handler's\n # intializer.\n chef_handler \"CloudkickHandler\" do\n source \"#{node['chef_handler']['handler_path']}/cloudkick_handler.rb\"\n arguments [node['cloudkick']['oauth_key'], node['cloudkick']['oauth_secret']]\n action :enable\n end\n\n\nUsage\n=====\n\ndefault\n-------\n\nPut the recipe `chef_handler` at the start of the node's run list to make sure that custom handlers are dropped off early on in the Chef run and available for later recipes.\n\nFor information on how to write report and exception handlers for Chef, please see the Chef wiki pages:\nhttp://wiki.opscode.com/display/chef/Exception+and+Report+Handlers\n\njson_file\n---------\n\nLeverages the `chef_handler` LWRP to automatically register the `Chef::Handler::JsonFile` handler that ships as part of Chef. This handler serializes the run status data to a JSON file located at `/var/chef/reports`.\n\nLicense and Author\n==================\n\nAuthor:: Seth Chisamore ()\n\nCopyright:: 2011, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n", - "maintainer": "Opscode, Inc.", - "maintainer_email": "cookbooks@opscode.com", - "license": "Apache 2.0", - "platforms": { - }, - "dependencies": { - }, - "recommendations": { - }, - "suggestions": { - }, - "conflicting": { - }, - "providing": { - }, - "replacing": { - }, - "attributes": { - }, - "groupings": { - }, - "recipes": { - }, - "version": "1.0.6" -} \ No newline at end of file diff --git a/chef-repo/cookbooks/chef_handler/metadata.rb b/chef-repo/cookbooks/chef_handler/metadata.rb deleted file mode 100644 index fc61c94..0000000 --- a/chef-repo/cookbooks/chef_handler/metadata.rb +++ /dev/null @@ -1,6 +0,0 @@ -maintainer "Opscode, Inc." -maintainer_email "cookbooks@opscode.com" -license "Apache 2.0" -description "Distribute and enable Chef Exception and Report handlers" -long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "1.0.6" diff --git a/chef-repo/cookbooks/chef_handler/providers/default.rb b/chef-repo/cookbooks/chef_handler/providers/default.rb deleted file mode 100644 index bed721b..0000000 --- a/chef-repo/cookbooks/chef_handler/providers/default.rb +++ /dev/null @@ -1,83 +0,0 @@ -# -# Author:: Seth Chisamore -# Cookbook Name:: chef_handler -# Provider:: default -# -# Copyright:: 2011, Opscode, Inc -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -action :enable do - # use load instead of require to ensure the handler file - # is reloaded into memory each chef run. fixes COOK-620 - begin - Object.send(:remove_const, klass) - GC.start - rescue - Chef::Log.debug("#{@new_resource.class_name} has not been loaded.") - end - file_name = @new_resource.source - file_name << ".rb" unless file_name =~ /.*\.rb$/ - load file_name - handler = klass.send(:new, *collect_args(@new_resource.arguments)) - @new_resource.supports.each do |type, enable| - if enable - # we have to re-enable the handler every chef run - # to ensure daemonized Chef always has the latest - # handler code. TODO: add a :reload action - Chef::Log.info("Enabling #{@new_resource} as a #{type} handler") - Chef::Config.send("#{type.to_s}_handlers").delete_if {|v| v.class.to_s.include? @new_resource.class_name} - Chef::Config.send("#{type.to_s}_handlers") << handler - new_resource.updated_by_last_action(true) - end - end -end - -action :disable do - @new_resource.supports.each_key do |type| - if enabled?(type) - Chef::Log.info("Disabling #{@new_resource} as a #{type} handler") - Chef::Config.send("#{type.to_s}_handlers").delete_if {|v| v.class.to_s.include? @new_resource.class_name} - new_resource.updated_by_last_action(true) - end - end -end - -def load_current_resource - @current_resource = Chef::Resource::ChefHandler.new(@new_resource.name) - @current_resource.class_name(@new_resource.class_name) - @current_resource.source(@new_resource.source) - @current_resource -end - -private -def enabled?(type) - Chef::Config.send("#{type.to_s}_handlers").select do |handler| - handler.class.to_s.include? @new_resource.class_name - end.size >= 1 -end - -def collect_args(resource_args = []) - if resource_args.is_a? Array - resource_args - else - [resource_args] - end -end - -def klass - @klass ||= begin - @new_resource.class_name.split('::').inject(Kernel) {|scope, const_name| scope.const_get(const_name)} - end -end \ No newline at end of file diff --git a/chef-repo/cookbooks/chef_handler/recipes/default.rb b/chef-repo/cookbooks/chef_handler/recipes/default.rb deleted file mode 100644 index 95132ee..0000000 --- a/chef-repo/cookbooks/chef_handler/recipes/default.rb +++ /dev/null @@ -1,31 +0,0 @@ -# -# Author:: Seth Chisamore () -# Cookbook Name:: chef_handlers -# Recipe:: default -# -# Copyright 2011, Opscode, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -Chef::Log.info("Chef Handlers will be at: #{node['chef_handler']['handler_path']}") - -remote_directory node['chef_handler']['handler_path'] do - source 'handlers' - owner 'root' - group 'root' - mode "0755" - recursive true - action :nothing -end.run_action(:create) - diff --git a/chef-repo/cookbooks/chef_handler/recipes/json_file.rb b/chef-repo/cookbooks/chef_handler/recipes/json_file.rb deleted file mode 100644 index d2fab10..0000000 --- a/chef-repo/cookbooks/chef_handler/recipes/json_file.rb +++ /dev/null @@ -1,28 +0,0 @@ -# -# Author:: Seth Chisamore () -# Cookbook Name:: chef_handlers -# Recipe:: json_file -# -# Copyright 2011, Opscode, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# force resource actions in compile phase so exception handler -# fires for compile phase exceptions - -chef_handler "Chef::Handler::JsonFile" do - source "chef/handler/json_file" - arguments :path => '/var/chef/reports' - action :nothing -end.run_action(:enable) diff --git a/chef-repo/cookbooks/chef_handler/resources/default.rb b/chef-repo/cookbooks/chef_handler/resources/default.rb deleted file mode 100644 index 355e8f1..0000000 --- a/chef-repo/cookbooks/chef_handler/resources/default.rb +++ /dev/null @@ -1,34 +0,0 @@ -# -# Author:: Seth Chisamore -# Cookbook Name:: chef_handler -# Resource:: default -# -# Copyright:: 2011, Opscode, Inc -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -actions :enable, :disable - -attribute :class_name, :kind_of => String, :name_attribute => true -attribute :source, :default => nil, :kind_of => String -attribute :arguments, :default => [] -attribute :supports, :kind_of => Hash, :default => {:report => true, :exception => true} - -# we have to set default for the supports attribute -# in initializer since it is a 'reserved' attribute name -def initialize(*args) - super - @action = :enable - @supports = {:report => true, :exception => true} -end diff --git a/chef-repo/cookbooks/couchbase b/chef-repo/cookbooks/couchbase deleted file mode 120000 index c25bddb..0000000 --- a/chef-repo/cookbooks/couchbase +++ /dev/null @@ -1 +0,0 @@ -../.. \ No newline at end of file diff --git a/chef-repo/cookbooks/minitest-handler/.travis.yml b/chef-repo/cookbooks/minitest-handler/.travis.yml deleted file mode 100644 index 8e1e518..0000000 --- a/chef-repo/cookbooks/minitest-handler/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: ruby -gemfile: - - test/support/Gemfile -rvm: - - 1.9.3 -script: BUNDLE_GEMFILE=test/support/Gemfile bundle exec rake foodcritic \ No newline at end of file diff --git a/chef-repo/cookbooks/minitest-handler/CHANGELOG.md b/chef-repo/cookbooks/minitest-handler/CHANGELOG.md deleted file mode 100644 index 0bbe62a..0000000 --- a/chef-repo/cookbooks/minitest-handler/CHANGELOG.md +++ /dev/null @@ -1,30 +0,0 @@ -Changelog -===== - -### v0.0.9 - -* add windows support tks to David Petzel -* add travis-ci integration -* change maintainer to Bryan W. Berry - - -### v0.0.7 - -* Add better examples to the readme -* pass foodcritic - -### v0.0.6 - -* MINITEST-HANDLER-COOKBOOK-12 ensure minitest gem used and not the standard library in 1.9 -* MINITEST-HANDLER-COOKBOOK-11 Add support for Chef-Solo -* Create the /var/chef/minitest directory if it doesn't already exist - - -### v0.0.5 - -* Install the minitest-chef-handler gem instead of downloading from github directly -* Remove tests from cookbooks no longer in the run list - -### v0.0.4 - -Add examples/ top level directory (may not work) diff --git a/chef-repo/cookbooks/minitest-handler/LICENSE b/chef-repo/cookbooks/minitest-handler/LICENSE deleted file mode 100644 index 11069ed..0000000 --- a/chef-repo/cookbooks/minitest-handler/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/chef-repo/cookbooks/minitest-handler/README.md b/chef-repo/cookbooks/minitest-handler/README.md deleted file mode 100644 index 0252e1e..0000000 --- a/chef-repo/cookbooks/minitest-handler/README.md +++ /dev/null @@ -1,78 +0,0 @@ -Cookbook: minitest-handler -Author: Bryan McLellan -Author: Bryan W. Berry -Author: David Petzel -Copyright: 2012 Opscode, Inc. -License: Apache 2.0 - -Description -=========== - -# minitest-handler [![Build Status](https://secure.travis-ci.org/btm/minitest-handler-cookbook.png?branch=master)](http://travis-ci.org/btm/minitest-handler-cookbook) - -This cookbook utilizes the minitest-chef-handler project to facilitate cookbook testing. - -minitest-chef-handler project: https://github.com/calavera/minitest-chef-handler -stable minitest-handler cookbook: http://community.opscode.com/cookbooks/minitest-handler -minitest-handler cookbook development: https://github.com/btm/minitest-handler-cookbook - -Attributes -========== - -node[:minitest][:path] - Location to store and find tests, defaults to /var/chef/minitest - -Usage -===== - -* The node run list should begin with 'recipe[minitest-handler]' -* Each cookbook should contain tests in the 'files/default/tests/minitest' directory with a file suffix of '_test.rb' - -Minitest: https://github.com/seattlerb/minitest - -Examples -======== - -### Tradition minitest - - class TestApache2 < MiniTest::Chef::TestCase - def test_that_the_package_installed - case node[:platform] - when "ubuntu","debian" - assert system('apt-cache policy apache2 | grep Installed | grep -v none') - end - end - - def test_that_the_service_is_running - assert system('/etc/init.d/apache2 status') - end - - def test_that_the_service_is_enabled - assert File.exists?(Dir.glob("/etc/rc5.d/S*apache2").first) - end - end - - -### Using minitest/spec - - require 'minitest/spec' - - describe_recipe 'ark::test' do - - # It's often convenient to load these includes in a separate - # helper along with - # your own helper methods, but here we just include them directly: - include MiniTest::Chef::Assertions - include MiniTest::Chef::Context - include MiniTest::Chef::Resources - - it "installed the unzip package" do - package("unzip").must_be_installed - end - - it "dumps the correct files into place with correct owner and group" do - file("/usr/local/foo_dump/foo1.txt").must_have(:owner, "foobarbaz").and(:group, "foobarbaz") - end - - end - -For more detailed examples, see [here](https://github.com/calavera/minitest-chef-handler/blob/v0.4.0/examples/spec_examples/files/default/tests/minitest/example_test.rb) diff --git a/chef-repo/cookbooks/minitest-handler/Rakefile b/chef-repo/cookbooks/minitest-handler/Rakefile deleted file mode 100644 index 8b93e33..0000000 --- a/chef-repo/cookbooks/minitest-handler/Rakefile +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env rake - -@cookbook = "minitest-handler-cookbook" - -desc "Runs foodcritc linter" -task :foodcritic do - if Gem::Version.new("1.9.2") <= Gem::Version.new(RUBY_VERSION.dup) - sandbox = File.join(File.dirname(__FILE__), %w{tmp foodcritic}, @cookbook) - prepare_foodcritic_sandbox(sandbox) - - sh "foodcritic --epic-fail any #{File.dirname(sandbox)}" - else - puts "WARN: foodcritic run is skipped as Ruby #{RUBY_VERSION} is < 1.9.2." - end -end - -task :default => 'foodcritic' - -private - -def prepare_foodcritic_sandbox(sandbox) - files = %w{*.md *.rb attributes definitions files providers - recipes resources templates} - - rm_rf sandbox - mkdir_p sandbox - cp_r Dir.glob("{#{files.join(',')}}"), sandbox - puts "\n\n" -end diff --git a/chef-repo/cookbooks/minitest-handler/attributes/default.rb b/chef-repo/cookbooks/minitest-handler/attributes/default.rb deleted file mode 100644 index e3d0ce3..0000000 --- a/chef-repo/cookbooks/minitest-handler/attributes/default.rb +++ /dev/null @@ -1,17 +0,0 @@ -default['minitest']['gem_version'] = "3.0.1" - - -case node['os'] -when "windows" - default['minitest']['path'] = "/var/chef/minitest" - #Usin nil to prevent this from being applied on Windows - default['minitest']['owner'] = nil - default['minitest']['group'] = nil - default['minitest']['mode'] = nil -else - #Default values for Linux - default['minitest']['path'] = "/var/chef/minitest" - default['minitest']['owner'] = "root" - default['minitest']['group'] = "root" - default['minitest']['mode'] = "0775" -end \ No newline at end of file diff --git a/chef-repo/cookbooks/minitest-handler/metadata.json b/chef-repo/cookbooks/minitest-handler/metadata.json deleted file mode 100644 index bcd66fe..0000000 --- a/chef-repo/cookbooks/minitest-handler/metadata.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "minitest-handler", - "description": "Installs and configures minitest-chef-handler", - "long_description": "Cookbook: minitest-handler \nAuthor: Bryan McLellan \nAuthor: Bryan W. Berry \nAuthor: David Petzel \nCopyright: 2012 Opscode, Inc. \nLicense: Apache 2.0 \n\nDescription\n===========\n\n# minitest-handler [![Build Status](https://secure.travis-ci.org/btm/minitest-handler-cookbook.png?branch=master)](http://travis-ci.org/btm/minitest-handler-cookbook)\n\nThis cookbook utilizes the minitest-chef-handler project to facilitate cookbook testing.\n\nminitest-chef-handler project: https://github.com/calavera/minitest-chef-handler \nstable minitest-handler cookbook: http://community.opscode.com/cookbooks/minitest-handler \nminitest-handler cookbook development: https://github.com/btm/minitest-handler-cookbook \n\nAttributes\n==========\n\nnode[:minitest][:path] - Location to store and find tests, defaults to /var/chef/minitest\n\nUsage\n=====\n\n* The node run list should begin with 'recipe[minitest-handler]'\n* Each cookbook should contain tests in the 'files/default/tests/minitest' directory with a file suffix of '_test.rb'\n\nMinitest: https://github.com/seattlerb/minitest\n\nExamples\n========\n\n### Tradition minitest\n\n class TestApache2 < MiniTest::Chef::TestCase\n def test_that_the_package_installed\n case node[:platform]\n when \"ubuntu\",\"debian\"\n assert system('apt-cache policy apache2 | grep Installed | grep -v none')\n end\n end\n \n def test_that_the_service_is_running\n assert system('/etc/init.d/apache2 status')\n end\n \n def test_that_the_service_is_enabled\n assert File.exists?(Dir.glob(\"/etc/rc5.d/S*apache2\").first)\n end\n end\n\n\n### Using minitest/spec\n\n require 'minitest/spec'\n\n describe_recipe 'ark::test' do\n\n # It's often convenient to load these includes in a separate\n # helper along with\n # your own helper methods, but here we just include them directly:\n include MiniTest::Chef::Assertions\n include MiniTest::Chef::Context\n include MiniTest::Chef::Resources\n\n it \"installed the unzip package\" do\n package(\"unzip\").must_be_installed\n end\n\n it \"dumps the correct files into place with correct owner and group\" do\n file(\"/usr/local/foo_dump/foo1.txt\").must_have(:owner, \"foobarbaz\").and(:group, \"foobarbaz\")\n end\n\n end\n\nFor more detailed examples, see [here](https://github.com/calavera/minitest-chef-handler/blob/v0.4.0/examples/spec_examples/files/default/tests/minitest/example_test.rb)\n", - "maintainer": "Bryan Berry", - "maintainer_email": "bryan.berry@gmail.com", - "license": "Apache 2.0", - "platforms": { - }, - "dependencies": { - "chef_handler": ">= 0.0.0" - }, - "recommendations": { - }, - "suggestions": { - }, - "conflicting": { - }, - "providing": { - }, - "replacing": { - }, - "attributes": { - }, - "groupings": { - }, - "recipes": { - }, - "version": "0.0.10" -} \ No newline at end of file diff --git a/chef-repo/cookbooks/minitest-handler/metadata.rb b/chef-repo/cookbooks/minitest-handler/metadata.rb deleted file mode 100644 index c7c7bc3..0000000 --- a/chef-repo/cookbooks/minitest-handler/metadata.rb +++ /dev/null @@ -1,8 +0,0 @@ -maintainer "Bryan Berry" -maintainer_email "bryan.berry@gmail.com" -license "Apache 2.0" -description "Installs and configures minitest-chef-handler" -long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "0.0.10" - -depends "chef_handler" diff --git a/chef-repo/cookbooks/minitest-handler/recipes/default.rb b/chef-repo/cookbooks/minitest-handler/recipes/default.rb deleted file mode 100644 index ac18e92..0000000 --- a/chef-repo/cookbooks/minitest-handler/recipes/default.rb +++ /dev/null @@ -1,63 +0,0 @@ -# Hack to install Gem immediately pre Chef 0.10.10 (CHEF-2879) -gem_package "minitest" do - version node['minitest']['gem_version'] - action :nothing -end.run_action(:install) - -gem_package "minitest-chef-handler" do - action :nothing -end.run_action(:install) - -Gem.clear_paths -# Ensure minitest gem is utilized -gem "minitest" -require "minitest-chef-handler" - -recipes = node['recipes'] -if recipes.empty? and Chef::Config[:solo] - #If you have roles listed in your run list they are NOT expanded - recipes = node.run_list.map {|item| item.name if item.type == :recipe } -end - -# Directory to store cookbook tests -directory "minitest test location" do - path node['minitest']['path'] - owner node['minitest']['owner'] - group node['minitest']['group'] - mode node['minitest']['mode'] - recursive true -end - -ruby_block "delete tests from old cookbooks" do - block do - raise "minitest-handler cookbook could not find directory '#{node['minitest']['path']}'" unless File.directory?(node['minitest']['path']) - expired_cookbooks = Dir.entries(node['minitest']['path']).delete_if { |dir| dir == '.' || dir == '..' || recipes.include?(dir) } - expired_cookbooks.each do |cookbook| - Chef::Log.info("Cookbook #{cookbook} no longer in run list, remove minitest tests") - FileUtils.rm_rf "#{node['minitest']['path']}/#{cookbook}" - end - end -end - -# Search through all cookbooks in the run list for tests -recipes.each do |recipe| - # recipes is actually a list of cookbooks and recipes with :: as a - # delimiter - cookbook_name = recipe.split('::').first - remote_directory "tests-#{cookbook_name}" do - source "tests/minitest" - cookbook cookbook_name - path "#{node['minitest']['path']}/#{cookbook_name}" - purge true - ignore_failure true - end -end - -handler = MiniTest::Chef::Handler.new({ - :path => "#{node['minitest']['path']}/**/*_test.rb", - :verbose => true}) - -Chef::Log.info("Enabling minitest-chef-handler as a report handler") -Chef::Config.send("report_handlers").delete_if {|v| v.class.to_s.include? MiniTest::Chef::Handler} -Chef::Config.send("report_handlers") << handler - diff --git a/chef-repo/infrastructure.yml b/chef-repo/infrastructure.yml deleted file mode 100644 index 28d615d..0000000 --- a/chef-repo/infrastructure.yml +++ /dev/null @@ -1,17 +0,0 @@ -cookbooks: -- couchbase: -- chef_handler: -- minitest-handler: - -roles: -- client: -- server: -- server_with_custom_memory_quota: - -nodes: -- ec2 1: - - recipe[minitest-handler] role[client] role[server] - - --no-host-key-verify -x ubuntu -G default -I ami-3c994355 -f c1.medium -d ubuntu12.04-gems --region us-east-1 -- ec2 1: - - recipe[minitest-handler] role[client] role[server] role[server_with_custom_memory_quota] - - --no-host-key-verify -x ubuntu -G default -I ami-3c994355 -f c1.medium -d ubuntu12.04-gems --region us-east-1 diff --git a/chef-repo/roles/client.rb b/chef-repo/roles/client.rb deleted file mode 100644 index 31d4a62..0000000 --- a/chef-repo/roles/client.rb +++ /dev/null @@ -1,6 +0,0 @@ -name "client" -description "Tests for Couchbase Client" - -run_list( - "recipe[couchbase::client]", -) diff --git a/chef-repo/roles/server.rb b/chef-repo/roles/server.rb deleted file mode 100644 index 65ddd92..0000000 --- a/chef-repo/roles/server.rb +++ /dev/null @@ -1,15 +0,0 @@ -name "server" -description "Tests for Couchbase Server" - -run_list( - "recipe[couchbase::server]", - "recipe[couchbase::test_buckets]", -) - -default_attributes({ - "couchbase" => { - "server" => { - "password" => "password", - }, - }, -}) diff --git a/chef-repo/roles/server_with_custom_memory_quota.rb b/chef-repo/roles/server_with_custom_memory_quota.rb deleted file mode 100644 index 940971b..0000000 --- a/chef-repo/roles/server_with_custom_memory_quota.rb +++ /dev/null @@ -1,14 +0,0 @@ -name "server_with_custom_memory_quota" -description "Tests for Couchbase Server with a custom memory quota" - -run_list( - "role[server]", -) - -default_attributes({ - "couchbase" => { - "server" => { - "memory_quota_mb" => 1000, - }, - }, -}) diff --git a/files/default/tests/minitest/client_test.rb b/files/default/tests/minitest/client_test.rb index c3ebaeb..014e29b 100644 --- a/files/default/tests/minitest/client_test.rb +++ b/files/default/tests/minitest/client_test.rb @@ -5,21 +5,31 @@ describe "libcouchbase-dev" do it "is installed" do - package("libcouchbase-dev").must_be_installed + case node['platform_family'] + when "debian" + package("libcouchbase-dev").must_be_installed + when "rhel" + package("libcouchbase-devel").must_be_installed + end end it "installed the correct version" do - package("libcouchbase-dev").must_have :version, node['couchbase']['libcouchbase']['version'] + case node['platform_family'] + when "debian" + package("libcouchbase-dev").must_have :version, node['couchbase']['client']['version'] + when "rhel" + package("libcouchbase-devel").must_be_installed + end end end - describe "libvbucket-dev" do + describe "libcouchbase2" do it "is installed" do - package("libvbucket-dev").must_be_installed + package("libcouchbase2").must_be_installed end it "installed the correct version" do - package("libvbucket-dev").must_have :version, node['couchbase']['libvbucket']['version'] + package("libcouchbase2").must_have :version, node['couchbase']['client']['version'] end end end diff --git a/files/default/tests/minitest/moxi_test.rb b/files/default/tests/minitest/moxi_test.rb new file mode 100644 index 0000000..b7d9afa --- /dev/null +++ b/files/default/tests/minitest/moxi_test.rb @@ -0,0 +1,18 @@ +describe_recipe "couchbase::moxi" do + include MiniTest::Chef::Assertions + include MiniTest::Chef::Context + include MiniTest::Chef::Resources + + describe "moxi-server service" do + let(:moxi_server) { service "moxi-server" } + + it "starts on boot" do + moxi_server.must_be_enabled + end + + it "is running as a daemon" do + moxi_server.must_be_running + end + end + +end diff --git a/libraries/max_memory_quota_calculator.rb b/libraries/max_memory_quota_calculator.rb index a55a3af..87959d7 100644 --- a/libraries/max_memory_quota_calculator.rb +++ b/libraries/max_memory_quota_calculator.rb @@ -7,7 +7,13 @@ class MaxMemoryQuotaCalculator class << self def from_node(node) - new kilobytes_to_bytes node["memory"]['total'].to_i + if node["memory"].nil? + # Usually nodes have this set, except if running in RSpec without Fauxhai, + # so set some dummy value + new kilobytes_to_bytes 0.to_i + else + new kilobytes_to_bytes node["memory"]['total'].to_i + end end protected diff --git a/metadata.rb b/metadata.rb index d35d5f6..37a1a77 100644 --- a/metadata.rb +++ b/metadata.rb @@ -6,8 +6,14 @@ long_description IO.read(File.join(File.dirname(__FILE__), "README.md")) version "1.0.0" -supports "debian" -supports "ubuntu" +%w{debian ubuntu centos redhat oracle amazon scientific windows}.each do |os| + supports os +end + +%w{apt windows yum}.each do |d| + depends d +end recipe "couchbase::server", "Installs couchbase-server" recipe "couchbase::client", "Installs libcouchbase" +recipe "couchbase::moxi", "Installs moxi-server" diff --git a/recipes/client.rb b/recipes/client.rb index 8432693..decd7c2 100644 --- a/recipes/client.rb +++ b/recipes/client.rb @@ -24,17 +24,49 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -package_machine = node['kernel']['machine'] == "i386" ? "i386" : "amd64" - -%w(libvbucket libcouchbase).each do |lib| - %w(1 -dev).each do |package_suffix| - package_file = "#{lib}#{package_suffix}_#{node['couchbase'][lib]['version']}_#{package_machine}.deb" +case node['platform_family'] +when "debian" + apt_repository "couchbase" do + uri "http://packages.couchbase.com/ubuntu" + distribution node['lsb']['codename'] + components ["main"] + key "http://packages.couchbase.com/ubuntu/couchbase.key" + end - remote_file File.join(Chef::Config[:file_cache_path], package_file) do - source "#{node['couchbase'][lib]['package_base_url']}/#{package_file}" - action :create_if_missing + %w{libcouchbase2 libcouchbase-dev}.each do |p| + package p do + action :install end + end - dpkg_package File.join(Chef::Config[:file_cache_path], package_file) +when "rhel" + yum_key "couchbase-rpm.key" do + url "http://packages.couchbase.com/rpm/couchbase-rpm.key" + action :add end + + case + when node['platform_version'].to_f >= 5.0 && node['platform_version'].to_f < 6.0 + osver = '5.5' + when node['platform_version'].to_f >= 6.0 + osver = '6.2' + else + Chef::Log.error("Platform version #{node['platform_version']} is unsupported by Couchbase C library") + end + + yum_repository "couchbase" do + name "couchbase" + description "Couchbase package repository" + url "http://packages.couchbase.com/rpm/#{osver}/$basearch/" + action :add + end + + %w{libcouchbase2 libcouchbase-devel}.each do |p| + package p do + action :install + end + end + +else + Chef::Log.error("Platform family #{node['platform_family']} is unsupported by Couchbase C library") end diff --git a/recipes/moxi.rb b/recipes/moxi.rb new file mode 100644 index 0000000..6c38dc5 --- /dev/null +++ b/recipes/moxi.rb @@ -0,0 +1,60 @@ +# +# Cookbook Name:: couchbase +# Recipe:: moxi +# Author:: Julian C. Dunn () +# +# Copyright 2013, SecondMarket Labs, LLC. +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Mutually exclusive with the server recipe. If you have the server on this node you don't need moxi client. +unless (node['recipes'].include?("couchbase::server")) + + remote_file File.join(Chef::Config[:file_cache_path], node['couchbase']['moxi']['package_file']) do + source node['couchbase']['moxi']['package_full_url'] + action :create_if_missing + end + + case node['platform_family'] + when "debian" + dpkg_package File.join(Chef::Config[:file_cache_path], node['couchbase']['moxi']['package_file']) + when "rhel" + rpm_package File.join(Chef::Config[:file_cache_path], node['couchbase']['moxi']['package_file']) + end + + service "moxi-server" do + supports :restart => true, :status => true + action :enable + end + + template "/opt/moxi/etc/moxi-cluster.cfg" do + source "moxi-cluster.cfg.erb" + owner 'moxi' + group 'moxi' + mode '00644' + action :create + notifies :restart, "service[moxi-server]" + end + + service "moxi-server" do + action :start + end + +end diff --git a/recipes/server.rb b/recipes/server.rb index a43ba0c..9a6b7a0 100644 --- a/recipes/server.rb +++ b/recipes/server.rb @@ -29,7 +29,25 @@ action :create_if_missing end -dpkg_package File.join(Chef::Config[:file_cache_path], node['couchbase']['server']['package_file']) +case node['platform'] +when "debian", "ubuntu" + dpkg_package File.join(Chef::Config[:file_cache_path], node['couchbase']['server']['package_file']) +when "redhat", "centos", "scientific", "amazon", "fedora" + rpm_package File.join(Chef::Config[:file_cache_path], node['couchbase']['server']['package_file']) +when "windows" + + template "#{Chef::Config[:file_cache_path]}/setup.iss" do + source "setup.iss.erb" + action :create + end + + windows_package "Couchbase Server" do + source File.join(Chef::Config[:file_cache_path], node['couchbase']['server']['package_file']) + options "/s" + installer_type :custom + action :install + end +end service "couchbase-server" do supports :restart => true, :status => true diff --git a/templates/default/moxi-cluster.cfg.erb b/templates/default/moxi-cluster.cfg.erb new file mode 100644 index 0000000..401fd72 --- /dev/null +++ b/templates/default/moxi-cluster.cfg.erb @@ -0,0 +1,7 @@ +# Please point moxi at your membase cluster by specifying +# a membase REST URL. +# +# The moxi server won't start correctly until after you +# edit and uncomment the url line below... +# +url=<%= node['couchbase']['moxi']['cluster_rest_url'] %> diff --git a/templates/default/setup.iss.erb b/templates/default/setup.iss.erb new file mode 100644 index 0000000..60213f8 --- /dev/null +++ b/templates/default/setup.iss.erb @@ -0,0 +1,17 @@ +[{9E3DC4AA-46D9-4B30-9643-2A97169F02A7}-DlgOrder] +Dlg0={9E3DC4AA-46D9-4B30-9643-2A97169F02A7}-SdWelcome-0 +Count=4 +Dlg1={9E3DC4AA-46D9-4B30-9643-2A97169F02A7}-SdAskDestPath-0 +Dlg2={9E3DC4AA-46D9-4B30-9643-2A97169F02A7}-SdStartCopy2-0 +Dlg3={9E3DC4AA-46D9-4B30-9643-2A97169F02A7}-SdFinish-0 +[{9E3DC4AA-46D9-4B30-9643-2A97169F02A7}-SdWelcome-0] +Result=1 +[{9E3DC4AA-46D9-4B30-9643-2A97169F02A7}-SdAskDestPath-0] +szDir=<%= node['couchbase']['server']['install_dir'] %> +Result=1 +[{9E3DC4AA-46D9-4B30-9643-2A97169F02A7}-SdStartCopy2-0] +Result=1 +[{9E3DC4AA-46D9-4B30-9643-2A97169F02A7}-SdFinish-0] +Result=1 +bOpt1=0 +bOpt2=0 diff --git a/test/kitchen/Kitchenfile b/test/kitchen/Kitchenfile new file mode 100644 index 0000000..2741417 --- /dev/null +++ b/test/kitchen/Kitchenfile @@ -0,0 +1,7 @@ +cookbook "couchbase" do +# Server doesn't work because MaxMemoryCalculator on the test VM gets less +# than the minimum amount and bombs out +# configuration "server" + configuration "client" + configuration "moxi" +end