diff --git a/.gitignore b/.gitignore index 3474f052..6495d21b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ .rake_test_cache recipes.tgz /config/servers.rb -bin/ nodes/*.json !nodes/sample_host.json @@ -12,3 +11,10 @@ nodes/*.json .bundle/install.log .bundle + +.kitchen +.kitchen/ +.kitchen.local.yml +.librarian + +.rbenv-vars diff --git a/.kitchen.yml b/.kitchen.yml new file mode 100644 index 00000000..4559cebb --- /dev/null +++ b/.kitchen.yml @@ -0,0 +1,30 @@ +--- +driver: + name: digitalocean + +platforms: + - name: ubuntu-14-04-x64 + driver_config: + region: ams1 + size: 2gb + server_name: chef-repo-test + +suites: + - name: full-stack + run_list: + - role[mysql] + - role[rails_passenger] + attributes: + mysql: + server_debian_password: "test" + server_root_password: "test" + server_repl_password: "test" + active_applications: + intercity_sample_app: + domain_names: ['intercity.io'] + database_info: + adapter: mysql2 + username: intercity + password: r4nd0m + database: intercity_sample_app + ruby_version: 2.1.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cd93352..f889fa8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,12 +8,13 @@ This project makes use of the [Sementic Versioning](http://semver.org/) - Backup support (Support for filesystem, mysql and postgresql, backup to S3) - Backup compression using GZip - Added ruby 2.1.3 to the ruby binary list +- test-kitchen to automatically test the cookbooks and resulting server setup ### Deprecated - Nothing ### Removed -- Nothing +- Removed the sudos cookbook because it is not needed for the Unicorn stack anymore ### Fixed - Removed spaces from the .rbenv-vars template file diff --git a/Gemfile b/Gemfile index 26611369..b57134fd 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,11 @@ source "https://rubygems.org" -gem "chef", "~> 11.14.2" +gem "chef", "~> 11.16.2" gem "knife-solo", "~> 0.4.1" gem "librarian-chef", "~> 0.0.4" + +gem "test-kitchen" +gem "kitchen-vagrant" +gem "kitchen-digitalocean" +gem "serverspec" +gem "rspec" diff --git a/Gemfile.lock b/Gemfile.lock index 9de83f10..753fdf7f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,18 @@ GEM remote: https://rubygems.org/ specs: - chef (11.14.6) + activesupport (4.1.6) + i18n (~> 0.6, >= 0.6.9) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.1) + tzinfo (~> 1.1) + addressable (2.3.6) + axiom-types (0.1.1) + descendants_tracker (~> 0.0.4) + ice_nine (~> 0.11.0) + thread_safe (~> 0.3, >= 0.3.1) + chef (11.16.2) chef-zero (~> 2.1, >= 2.1.4) diff-lcs (~> 1.2, >= 1.2.4) erubis (~> 2.7) @@ -15,7 +26,7 @@ GEM mixlib-shellout (~> 1.4) net-ssh (~> 2.6) net-ssh-multi (~> 1.1) - ohai (~> 7.2) + ohai (~> 7.4) plist (~> 3.1.0) pry (~> 0.9) rest-client (>= 1.0.4, <= 1.6.7) @@ -25,16 +36,35 @@ GEM mixlib-log (~> 1.3) rack coderay (1.1.0) + coercible (1.0.0) + descendants_tracker (~> 0.0.1) + descendants_tracker (0.0.4) + thread_safe (~> 0.3, >= 0.3.1) diff-lcs (1.2.5) + droplet_kit (1.0.1) + kartograph (~> 0.0.5) + resource_kit (~> 0.0.5) + virtus (~> 1.0.3) + equalizer (0.0.9) erubis (2.7.0) + faraday (0.9.0) + multipart-post (>= 1.2, < 3) ffi (1.9.5) ffi-yajl (1.1.0) ffi (~> 1.5) libyajl2 (~> 1.0) hashie (2.1.2) highline (1.6.21) + i18n (0.6.11) + ice_nine (0.11.0) ipaddress (0.8.0) json (1.8.1) + kartograph (0.0.8) + kitchen-digitalocean (0.8.0) + droplet_kit (~> 1.0) + test-kitchen (~> 1.2) + kitchen-vagrant (0.15.0) + test-kitchen (~> 1.0) knife-solo (0.4.2) chef (>= 10.12) erubis (~> 2.7.0) @@ -50,12 +80,16 @@ GEM method_source (0.8.2) mime-types (1.25.1) minitar (0.5.4) + minitest (5.4.2) mixlib-authentication (1.3.0) mixlib-log mixlib-cli (1.5.0) mixlib-config (2.1.0) mixlib-log (1.6.0) mixlib-shellout (1.4.0) + multipart-post (2.0.0) + net-scp (1.2.1) + net-ssh (>= 2.6.5) net-ssh (2.9.1) net-ssh-gateway (1.2.0) net-ssh (>= 2.6.5) @@ -79,17 +113,63 @@ GEM method_source (~> 0.8.1) slop (~> 3.4) rack (1.5.2) + resource_kit (0.0.5) + activesupport (>= 3.0) + addressable (~> 2.3.6) + faraday rest-client (1.6.7) mime-types (>= 1.16) + rspec (3.0.0) + rspec-core (~> 3.0.0) + rspec-expectations (~> 3.0.0) + rspec-mocks (~> 3.0.0) + rspec-core (3.0.4) + rspec-support (~> 3.0.0) + rspec-expectations (3.0.4) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.0.0) + rspec-its (1.0.1) + rspec-core (>= 2.99.0.beta1) + rspec-expectations (>= 2.99.0.beta1) + rspec-mocks (3.0.4) + rspec-support (~> 3.0.0) + rspec-support (3.0.4) + safe_yaml (1.0.4) + serverspec (2.0.1) + rspec (~> 3.0.0) + rspec-its + specinfra (~> 2.0) slop (3.6.0) + specinfra (2.0.2) + net-scp + net-ssh systemu (2.6.4) + test-kitchen (1.2.1) + mixlib-shellout (~> 1.2) + net-scp (~> 1.1) + net-ssh (~> 2.7) + safe_yaml (~> 1.0) + thor (~> 0.18) thor (0.19.1) + thread_safe (0.3.4) + tzinfo (1.2.2) + thread_safe (~> 0.1) + virtus (1.0.3) + axiom-types (~> 0.1) + coercible (~> 1.0) + descendants_tracker (~> 0.0, >= 0.0.3) + equalizer (~> 0.0, >= 0.0.9) wmi-lite (1.0.0) PLATFORMS ruby DEPENDENCIES - chef (~> 11.14.2) + chef (~> 11.16.2) + kitchen-digitalocean + kitchen-vagrant knife-solo (~> 0.4.1) librarian-chef (~> 0.0.4) + rspec + serverspec + test-kitchen diff --git a/README.md b/README.md index e3cb3052..54674616 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ Intercity Chef Recipes ====================== +[ ![Codeship Status for intercity/chef-repo](https://codeship.io/projects/cca718f0-2e65-0132-1079-2a765a227ada/status)](https://codeship.io/projects/39371) + This Chef repository aims at being the easiest way set up and configure your own Rails server to host one or more Ruby on Rails applications using best practices from our community. @@ -235,6 +237,36 @@ in 5 - 10 minutes**. If something doesn't work or you need more instructions: **Please!** [Open an issue](https://github.com/intercity/chef-repo/issues) or email [hello@intercityup.com](mailto:hello@intercityup.com). +## Testing with test-kitchen + +### CI testing + +Test-kitchen is a tool where you can automatically provision a server with these cookbooks and run the tests for them. The configuration in `.kitchen.yml` works with DigitalOcean. + +First you need to obtain a DigitalOcean access token here: https://cloud.digitalocean.com/settings/applications. Then you need to find IDs of the SSH keys you added to your account: https://cloud.digitalocean.com/ssh_keys. You can obtain these IDs with the following command: + +``` +$ curl -X GET https://api.digitalocean.com/v2/account/keys -H "Authorization: Bearer $DIGITALOCEAN_ACCESS_TOKEN" +``` + +When you've obtained both your access token and your key IDs you can run the tests like this: + +``` +$ export DIGITALOCEAN_ACCESS_TOKEN="abcdefg" +$ export DIGITALOCEAN_SSH_KEY_IDS="194173" +$ bin/kitchen test +``` + +This command boots up a Droplet in your DigitalOcean account, provisions it with Chef, runs the tests and destroys the Droplet. + +### Testing while developing + +If you want to keep the Droplet running and do testing while making changes you can use the `kitchen verify` command instead of the `kitchen test` command to verify your changes: + +``` +$ bin/kitchen verify +``` + ## Resources and original authors * Most of the cookbooks that are used in this repository are installed from the [Opscode Community Cookbooks](http://community.opscode.com). diff --git a/bin/bundler b/bin/bundler new file mode 100755 index 00000000..72c62ec0 --- /dev/null +++ b/bin/bundler @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'bundler' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('bundler', 'bundler') diff --git a/bin/chef-apply b/bin/chef-apply new file mode 100755 index 00000000..90b7570a --- /dev/null +++ b/bin/chef-apply @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'chef-apply' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('chef', 'chef-apply') diff --git a/bin/chef-client b/bin/chef-client new file mode 100755 index 00000000..7412022a --- /dev/null +++ b/bin/chef-client @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'chef-client' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('chef', 'chef-client') diff --git a/bin/chef-service-manager b/bin/chef-service-manager new file mode 100755 index 00000000..a7407bae --- /dev/null +++ b/bin/chef-service-manager @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'chef-service-manager' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('chef', 'chef-service-manager') diff --git a/bin/chef-shell b/bin/chef-shell new file mode 100755 index 00000000..f8a097be --- /dev/null +++ b/bin/chef-shell @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'chef-shell' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('chef', 'chef-shell') diff --git a/bin/chef-solo b/bin/chef-solo new file mode 100755 index 00000000..811de8a0 --- /dev/null +++ b/bin/chef-solo @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'chef-solo' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('chef', 'chef-solo') diff --git a/bin/chef-zero b/bin/chef-zero new file mode 100755 index 00000000..5de35a22 --- /dev/null +++ b/bin/chef-zero @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'chef-zero' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('chef-zero', 'chef-zero') diff --git a/bin/coderay b/bin/coderay new file mode 100755 index 00000000..5be1c009 --- /dev/null +++ b/bin/coderay @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'coderay' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('coderay', 'coderay') diff --git a/bin/erubis b/bin/erubis new file mode 100755 index 00000000..2c7348b8 --- /dev/null +++ b/bin/erubis @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'erubis' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('erubis', 'erubis') diff --git a/bin/ffi-yajl-bench b/bin/ffi-yajl-bench new file mode 100755 index 00000000..af15547e --- /dev/null +++ b/bin/ffi-yajl-bench @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'ffi-yajl-bench' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('ffi-yajl', 'ffi-yajl-bench') diff --git a/bin/htmldiff b/bin/htmldiff new file mode 100755 index 00000000..c70e238d --- /dev/null +++ b/bin/htmldiff @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'htmldiff' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('diff-lcs', 'htmldiff') diff --git a/bin/kitchen b/bin/kitchen new file mode 100755 index 00000000..a130b9bd --- /dev/null +++ b/bin/kitchen @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'kitchen' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('test-kitchen', 'kitchen') diff --git a/bin/knife b/bin/knife new file mode 100755 index 00000000..083777a6 --- /dev/null +++ b/bin/knife @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'knife' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('chef', 'knife') diff --git a/bin/ldiff b/bin/ldiff new file mode 100755 index 00000000..8e3524a9 --- /dev/null +++ b/bin/ldiff @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'ldiff' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('diff-lcs', 'ldiff') diff --git a/bin/librarian-chef b/bin/librarian-chef new file mode 100755 index 00000000..a1960a0e --- /dev/null +++ b/bin/librarian-chef @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'librarian-chef' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('librarian-chef', 'librarian-chef') diff --git a/bin/minitar b/bin/minitar new file mode 100755 index 00000000..19167abd --- /dev/null +++ b/bin/minitar @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'minitar' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('minitar', 'minitar') diff --git a/bin/ohai b/bin/ohai new file mode 100755 index 00000000..3990a9df --- /dev/null +++ b/bin/ohai @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'ohai' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('ohai', 'ohai') diff --git a/bin/pry b/bin/pry new file mode 100755 index 00000000..54678a32 --- /dev/null +++ b/bin/pry @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'pry' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('pry', 'pry') diff --git a/bin/puma b/bin/puma new file mode 100755 index 00000000..d24478be --- /dev/null +++ b/bin/puma @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'puma' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('puma', 'puma') diff --git a/bin/pumactl b/bin/pumactl new file mode 100755 index 00000000..f3f7b2bd --- /dev/null +++ b/bin/pumactl @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'pumactl' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('puma', 'pumactl') diff --git a/bin/rackup b/bin/rackup new file mode 100755 index 00000000..8cc9953e --- /dev/null +++ b/bin/rackup @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'rackup' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('rack', 'rackup') diff --git a/bin/restclient b/bin/restclient new file mode 100755 index 00000000..4d7bdcf9 --- /dev/null +++ b/bin/restclient @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'restclient' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('rest-client', 'restclient') diff --git a/bin/shef b/bin/shef new file mode 100755 index 00000000..2d964336 --- /dev/null +++ b/bin/shef @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'shef' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('chef', 'shef') diff --git a/bin/thor b/bin/thor new file mode 100755 index 00000000..8421e001 --- /dev/null +++ b/bin/thor @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'thor' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('thor', 'thor') diff --git a/nodes/sample_host.json b/nodes/sample_host.json index 4d60358e..160b90fe 100644 --- a/nodes/sample_host.json +++ b/nodes/sample_host.json @@ -6,11 +6,6 @@ "server_repl_password": "" }, "packages": ["