diff --git a/.gitignore b/.gitignore index 7c417c2..0a775fa 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ Gemfile.lock *.un~ /cookbooks .chef +.rvmrc diff --git a/Gemfile b/Gemfile index f1c74c0..85e998d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,7 @@ -source :rubygems +source 'http://rubygems.org' gem 'berkshelf' gem 'thor-foodcritic' -gem 'vagrant', '~> 1.0.5' +gem 'vagrant-wrapper' +gem 'test-kitchen', :group => :integration +gem 'kitchen-vagrant', :group => :integration \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile index 9fc76ed..146448d 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -3,7 +3,9 @@ Vagrant.configure("2") do |config| config.vm.hostname = "errbit-berkshelf" config.vm.box = "Opscode-12-04" - config.vm.network :private_network, ip: "33.33.33.20" + config.vm.network :private_network, ip: "33.33.33.10" + + config.vm.box_url = "https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box" # Create a public network, which generally matched to bridged network. # Bridged networks make the machine appear as another physical device on @@ -16,7 +18,7 @@ Vagrant.configure("2") do |config| # Forward a port from the guest to the host, which allows for outside # computers to access the VM, whereas host only networking does not. - # config.vm.forward_port 80, 8080 + config.vm.network :forwarded_port, guest: 80, host: 8080 # Share an additional folder to the guest VM. The first argument is # an identifier, the second is the path on the guest to mount the @@ -26,8 +28,8 @@ Vagrant.configure("2") do |config| # Peepcode chef #config.vm.share_folder "v-cookbooks", "/cookbooks", "." - config.ssh.max_tries = 40 - config.ssh.timeout = 120 + config.omnibus.chef_version = :latest + config.vm.boot_timeout = 120 # The path to the Berksfile to use with Vagrant Berkshelf # config.berkshelf.berksfile_path = "./Berksfile" diff --git a/attributes/default.rb b/attributes/default.rb index ec1a4b0..475a993 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -18,13 +18,18 @@ # errbit config.yml default['errbit']['config']['host'] = "errbit.example.com" +default['errbit']['config']['port'] = 80 +default['errbit']['config']['https'] = false default['errbit']['config']['enforce_ssl'] = false default['errbit']['config']['email_from'] = "errbit@example.com" default['errbit']['config']['per_app_email_at_notices'] = false default['errbit']['config']['email_at_notices'] = [1, 10, 100] -default['errbit']['config']['confirm_resolve_err'] = true +default['errbit']['config']['per_app_notify_at_notices'] = false +default['errbit']['config']['notify_at_notices'] = [0] +default['errbit']['config']['confirm_err_actions'] = true default['errbit']['config']['user_has_username'] = false default['errbit']['config']['allow_comments_with_issue_tracker'] = true +default['errbit']['config']['display_internal_errors'] = true default['errbit']['config']['use_gravatar'] = true default['errbit']['config']['gravatar_default'] = "identicon" @@ -35,14 +40,16 @@ default['errbit']['config']['github_access_scope'] = ['repo'] # mongodb creds -default['errbit']['db']['host'] = "localhost" -default['errbit']['db']['port'] = "27017" -default['errbit']['db']['database'] = "errbit" -default['errbit']['db']['username'] = "" -default['errbit']['db']['password'] = "" +default['errbit']['db']['host'] = "localhost" +default['errbit']['db']['port'] = "27017" +default['errbit']['db']['database'] = "errbit" +default['errbit']['db']['username'] = "" +default['errbit']['db']['password'] = "" +default['errbit']['db']['identity_map_enabled'] = true +default['errbit']['db']['use_utc'] = true # app server (Optional: More info in README) default['errbit']['server'] = "unicorn" # or use others like puma -default['errbit']['secret_token'] = 'b9e131c733a2672c79af5699f26e0bc5fba23a40ec51d76c9271c00097f35aa4c0993e1150f08048f0b66bd141cbcb58ab28814e35eb281c3cb2374aac160203' +default['errbit']['secret_token'] = '1505bf435970a11dc892d434eb69bc07190ff42e6f3fe4db8b158f56d5f7c6c1861dfd018e499a4ca120c9881684ad985f98cb1f48f3b76cbea9c85d5465bbce' diff --git a/metadata.rb b/metadata.rb index e5b65b8..033e464 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license "All rights reserved" description "Installs/Configures errbit" long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "0.4.0" +version "0.4.1" depends "mongodb" depends "git" diff --git a/recipes/setup.rb b/recipes/setup.rb index 86d74fb..e16a7ab 100644 --- a/recipes/setup.rb +++ b/recipes/setup.rb @@ -19,6 +19,10 @@ # include_recipe "mongodb::10gen_repo" +mongodb_instance "mongodb" do + port node['errbit']['db']['port'] + host node['errbit']['db']['host'] +end node.set['build_essential']['compiletime'] = true include_recipe "build-essential" @@ -103,13 +107,18 @@ mode 00644 variables(params: { host: node['errbit']['config']['host'], + port: node['errbit']['config']['port'], + https: node['errbit']['config']['https'], enforce_ssl: node['errbit']['config']['enforce_ssl'], email_from: node['errbit']['config']['email_from'], per_app_email_at_notices: node['errbit']['config']['per_app_email_at_notices'], email_at_notices: node['errbit']['config']['email_at_notices'], - confirm_resolve_err: node['errbit']['config']['confirm_resolve_err'], + per_app_notify_at_notices: node['errbit']['config']['per_app_notify_at_notices'], + notify_at_notices: node['errbit']['config']['notify_at_notices'], + confirm_err_actions: node['errbit']['config']['confirm_err_actions'], user_has_username: node['errbit']['config']['user_has_username'], allow_comments_with_issue_tracker: node['errbit']['config']['allow_comments_with_issue_tracker'], + display_internal_errors: node['errbit']['config']['display_internal_errors'], use_gravatar: node['errbit']['config']['use_gravatar'], gravatar_default: node['errbit']['config']['gravatar_default'], github_authentication: node['errbit']['config']['github_authentication'], @@ -119,6 +128,17 @@ }) end +# errbit config.yml +template "#{node['errbit']['deploy_to']}/shared/config/initializers/__secret_token.rb" do + source "secret_token.rb.erb" + owner node['errbit']['user'] + group node['errbit']['group'] + mode 00644 + variables(params: { + secret_token: node['errbit']['secret_token'] + }) +end + template "#{node['errbit']['deploy_to']}/shared/config/mongoid.yml" do source "mongoid.yml.erb" owner node['errbit']['user'] @@ -128,9 +148,11 @@ environment: node['errbit']['environment'], host: node['errbit']['db']['host'], port: node['errbit']['db']['port'], - database: node['errbit']['db']['database'] - # username: node['errbit']['db']['username'], - # password: node['errbit']['db']['password'] + database: node['errbit']['db']['database'], + username: node['errbit']['db']['username'], + password: node['errbit']['db']['password'], + identity_map_enabled: node['errbit']['db']['identity_map_enabled'], + use_utc: node['errbit']['db']['use_utc'] }) end @@ -142,9 +164,9 @@ enable_submodules false migrate false before_migrate do - link "#{release_path}/vendor/bundle" do - to "#{node['errbit']['deploy_to']}/shared/vendor_bundle" - end + # link "#{release_path}/vendor/bundle" do + # to "#{node['errbit']['deploy_to']}/shared/vendor_bundle" + # end common_groups = %w{development test cucumber staging production} execute "bundle install --deployment --without #{(common_groups - ([node['errbit']['environment']])).join(' ')}" do ignore_failure true @@ -154,6 +176,7 @@ symlink_before_migrate nil symlinks( + "config/initializers/__secret_token.rb" => "config/initializers/__secret_token.rb", "config/config.yml" => "config/config.yml", "config/mongoid.yml" => "config/mongoid.yml" ) diff --git a/templates/default/config.yml.erb b/templates/default/config.yml.erb index dddb947..73ec974 100644 --- a/templates/default/config.yml.erb +++ b/templates/default/config.yml.erb @@ -2,10 +2,26 @@ # Errbit Config # ============= # +# Copy this file to config/config.yml and +# modify it accordingly. This file will automatically +# be copied to shared/config on the server when +# `cap deploy:setup` is ran the first time. Be sure +# to place production specific settings there +# You will need to restart the server after changing any settings. # The host of your errbit server host: <%= @params[:host] %> +# The port for your errbit server. +# Only set this if it isn't the default for the protocol (i.e.. 80 for HTTP, 443 for HTTPS) +port: <%= @params[:port] %> + +# The protocol for your errbit server. +# Only set if not running default HTTP +<% if @params[:https] %> + protocol: https +<% end %> + # Enforce SSL connections enforce_ssl: <%= @params[:enforce_ssl] %> @@ -22,8 +38,17 @@ per_app_email_at_notices: <%= @params[:per_app_email_at_notices] %> # an email notification. email_at_notices: <%= @params[:email_at_notices] %> -# Configure whether or not the user should be prompted before resolving an error. -confirm_resolve_err: <%= @params[:confirm_resolve_err] %> +# If you turn on this option, notify_at_notices can be +# configured on a per app basis, at the App edit page +per_app_notify_at_notices: <%= @params[:per_app_notify_at_notices] %> + +# Configure when emails are sent for an error. +# [1,3,7] = 1st, 3rd, and 7th occurence triggers +# [0] for all notices, provided notification service is configured +notify_at_notices: <%= @params[:notify_at_notices] %> + +# Configure whether or not the user should be prompted before resolving/deleting/merging/etc an error. +confirm_err_actions: <%= @params[:confirm_err_actions] %> # Add an optional 'username' field to Users. # Helpful when you need to plug in a custom authentication strategy, such as LDAP. @@ -34,22 +59,29 @@ user_has_username: <%= @params[:user_has_username] %> # but you want to leave a short comment. allow_comments_with_issue_tracker: <%= @params[:allow_comments_with_issue_tracker] %> +# Display internal errors in production +# Since this is an internal application, you might like to see what caused Errbit to crash. +# Pull requests are always welcome! +# However, you might be more comfortable setting this to false if your server can be accessed by anyone. +display_internal_errors: <%= @params[:allow_comments_with_issue_tracker] %> + # Enable Gravatar. use_gravatar: <%= @params[:use_gravatar] %> # Default Gravatar image, can be: mm, identicon, monsterid, wavatar, retro. gravatar_default: <%= @params[:gravatar_default] %> # Setup your deploy options for capistrano. -deployment: - hosts: - web: errbit.example.com - app: errbit.example.com - db: errbit.example.com - repository: http://github.com/errbit/errbit.git - user: deploy - deploy_to: /var/www/apps/errbit - # setup path to unicorn pids folder (or deploy_to/shared/pids will be used) - # pids: /var/www/apps/errbit/shared/pids +# deployment: +# hosts: +# web: errbit.example.com +# app: errbit.example.com +# db: errbit.example.com +# repository: https://github.com/errbit/errbit.git +# branch: master +# user: deploy +# deploy_to: /var/www/apps/errbit +# # setup path to unicorn pids folder (or deploy_to/shared/pids will be used) +# # pids: /var/www/apps/errbit/shared/pids # GitHub OAuth configuration # If you want to allow authentication via GitHub, you will need to register @@ -81,3 +113,8 @@ github_access_scope: <%= @params[:github_access_scope] %> # :user_name: USERNAME # :password: PASSWORD + +# If you want send your email by your sendmail +# sendmail_settings: +# :location: '/usr/sbin/sendmail' +# :arguments: '-i -t' diff --git a/templates/default/mongoid.yml.erb b/templates/default/mongoid.yml.erb index 28b661d..1bac047 100644 --- a/templates/default/mongoid.yml.erb +++ b/templates/default/mongoid.yml.erb @@ -1,3 +1,23 @@ +# Mongoid Configuration +# ===================== +# +# Copy this file to config/mongoid.yml and +# modify it accordingly. This file will automatically +# be copied to shared/config on the server when +# `cap deploy:setup` is ran the first time. Be sure +# to place production specific settings there + +# set these environment variables on your server <%= @params[:environment] %>: - host: localhost - database: <%= @params[:database] %> + sessions: + default: + database: <%= @params[:database] %> + hosts: + - '<%= @params[:host] %>:<%= @params[:port] %>' + <% unless @params[:username].empty? || @params[:password].empty? %> + username: <%= @params[:username] %> + password: <%= @params[:password] %> + <% end %> + options: + identity_map_enabled: <%= @params[:identity_map_enabled] %> + use_utc: <%= @params[:use_utc] %> \ No newline at end of file diff --git a/templates/default/nginx.conf.erb b/templates/default/nginx.conf.erb index 65c6196..3cf9d81 100644 --- a/templates/default/nginx.conf.erb +++ b/templates/default/nginx.conf.erb @@ -10,11 +10,11 @@ upstream <%= node['errbit']['name'] %> { # } server { - listen 80 deferred; + listen <%= node['errbit']['config']['port'] %> deferred; <% if @server_names %> server_name <%= @server_names.join(" ") %>; <% else %> - server_name <%= node['ipaddress'] %> + server_name <%= node['errbit']['config']['host'] %>; <% end %> client_max_body_size 4G; keepalive_timeout 5; diff --git a/templates/default/secret_token.rb.erb b/templates/default/secret_token.rb.erb new file mode 100644 index 0000000..f0ed758 --- /dev/null +++ b/templates/default/secret_token.rb.erb @@ -0,0 +1 @@ +Errbit::Application.config.secret_token = '<%= @params[:secret_token] %>' \ No newline at end of file diff --git a/templates/default/unicorn.conf.erb b/templates/default/unicorn.conf.erb index 8c13964..9604070 100644 --- a/templates/default/unicorn.conf.erb +++ b/templates/default/unicorn.conf.erb @@ -8,7 +8,6 @@ working_directory "<%= node['errbit']['deploy_to']%>/current" # use a shorter backlog for quicker failover when busy listen "<%= node['errbit']['deploy_to']%>/shared/sockets/unicorn.sock", :backlog => <%= node[:unicorn][:backlog] %> -listen 8080, :tcp_nopush => true timeout <%= node[:unicorn][:worker_timeout] %>