Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
fe26436
Set mongodb as recommendation only
Jul 3, 2013
90a0c3c
create new defaults for the unicorn.rb template
Jul 5, 2013
7d86b9d
Remove unicorn & system ruby dependency, replace with rbenv
Jul 5, 2013
decb34d
Replace init script for su-ing into rbenv user
Jul 5, 2013
8ee3449
Rename unicorn.conf -> unicorn.rb
Jul 5, 2013
98965f1
Set environment in rbenv user's .bash_profile instead of global profile
Jul 5, 2013
d191071
Don't restart errbit_unicorn unless config changed
Jul 5, 2013
5bd1ded
Remove system ruby from Vagrantfile
Jul 5, 2013
c1d6f9e
Merge remote-tracking branch 'millisami/pull/4'
chewi May 8, 2015
c328c69
Fix licenses
chewi May 4, 2015
ef3d547
Kitchen
chewi May 4, 2015
d1a950b
Current errbit needs Ruby 2.2
chewi May 5, 2015
e5b699b
Use rbenv_script instead of execute
chewi May 5, 2015
33b70b7
Install a JavaScript interpreter
chewi May 5, 2015
c60d004
Install gems to ~/.rbenv instead of vendor/bundle
chewi May 5, 2015
16d5f38
Configure errbit with a dotenv file
chewi May 5, 2015
b20ab22
Fix deploy_to and rbenv attributes
chewi May 5, 2015
c76c2d1
Keep build-essentials stuff in converge phase
chewi May 5, 2015
4627306
Tidy up unicorn service
chewi May 6, 2015
8f0d203
Don't explicitly install packages
chewi May 6, 2015
9ba3620
Clean up nginx template
chewi May 7, 2015
6fdd618
Support for Puma via systemd
chewi May 7, 2015
6f98fa1
Start the Unicorn service on boot
chewi May 8, 2015
36bf066
CentOS 7.1 works!
chewi May 8, 2015
cac6006
Run rake db:migrate on each deployment
chewi May 8, 2015
b3ebbfc
Implement not_if in bootstrap recipe
chewi May 8, 2015
b5d7f0e
Don't store nginx logs under shared directory
chewi May 13, 2015
21676fb
Remove metadata.json
chewi May 14, 2015
862869c
Precompile assets before migrating
chewi May 14, 2015
7d2d4ab
Make things work with SELinux enabled
chewi May 14, 2015
70c307f
Separate the nginx port from the Errbit port
chewi May 15, 2015
e0b866f
The rbenv cookbook is now fixed upstream
chewi Jul 27, 2015
27d0c57
rbenv cookbook has renamed to ruby_rbenv
chewi Nov 20, 2015
3bd8e2c
Bento bump
chewi Mar 29, 2016
9ea076c
Ruby bump to 2.2.4
chewi Mar 29, 2016
98bcbca
Upstream now includes therubyracer in the Gemfile
chewi Mar 29, 2016
aed5288
Pin nginx cookbook to ~> 2.7
chewi Mar 29, 2016
79bad0b
I must have forgotten to update this for rbenv
chewi Mar 29, 2016
00a674c
Bento bump
chewi Aug 25, 2017
f423d41
Use the new ruby_rbenv v2 cookbook
chewi Aug 25, 2017
81c7281
Migrate from the nginx to chef_nginx cookbook
chewi Aug 25, 2017
ca5c697
Fix bad version constraint in metadata
chewi Aug 31, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ Gemfile.lock
*.un~
/cookbooks
.chef
/.kitchen
22 changes: 22 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
driver:
name: vagrant
customize:
memory: 768
network:
- ['forwarded_port', {guest: 80, host: 8080, auto_correct: true}]

provisioner:
name: chef_zero

platforms:
- name: centos-7.3
- name: ubuntu-12.04

suites:
- name: default
run_list:
- recipe[mongodb]
- recipe[chef_nginx]
- recipe[errbit::default]
- recipe[errbit::bootstrap]
3 changes: 1 addition & 2 deletions Berksfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
site :opscode

source 'https://api.berkshelf.com'
metadata
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# Description

This cookbook is designed to be able to run [Errbit](http://github.com/errbit/errbit).
Its github is at [chef-errbit](https://github.com/millisami/chef-errbit)
Its github is at [chef-errbit](https://github.com/klamontagne/chef-errbit)

# Requirements

Developed using chef 10.14.0 and it should work with higher versions. But not tested against chef 11 family.

The following Opscode cookbooks are dependencies:

* mongodb
* git
* unicorn
* apt
* nginx

You also need a MongoDB installation, such as with the [mongodb cookbook](https://github.com/edelight/chef-mongodb).

If you have other installations of rbenv on the node, you need to edit the node's user_installs as described in [chef-rbenv's documentation](https://github.com/fnichol/chef-rbenv#-rbenv-installed-for-a-specific-user-with-rubies).

# Usage

Just to install the Errbit app, include the following in your wrapper cookbook's recipe
Expand Down
3 changes: 1 addition & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ Vagrant.configure("2") do |config|
}

chef.run_list = [
'recipe[errbit::install_ruby]',
'recipe[nginx]',
'recipe[chef_nginx]',
'recipe[errbit::default]',
'recipe[errbit::bootstrap]'
]
Expand Down
100 changes: 68 additions & 32 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,81 @@
#
# Copyright (C) 2013 Millisami
#
# All rights reserved - Do Not Redistribute
# 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['errbit']['name'] = "errbit"
default['errbit']['user'] = "deployer"
default['errbit']['password'] = "$1$qqO27xay$dtmwY9NMmJiSa47xhUZm0." #errbit
default['errbit']['user'] = "errbit"
default['errbit']['group'] = node['errbit']['user']
default['errbit']['deploy_to'] = "/home/#{default['errbit']['user']}/#{node['errbit']['name']}"
default['errbit']['deploy_to'] = "/home/#{node['errbit']['user']}/#{node['errbit']['name']}"
default['errbit']['repo_url'] = "git://github.com/errbit/errbit.git"
default['errbit']['revision'] = "master"
default['errbit']['environment'] = "production"

# errbit config.yml
default['errbit']['config']['host'] = "errbit.example.com"
default['errbit']['config']['enforce_ssl'] = false
default['errbit']['config']['email_from'] = "[email protected]"
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']['user_has_username'] = false
default['errbit']['config']['allow_comments_with_issue_tracker'] = true
default['errbit']['config']['use_gravatar'] = true
default['errbit']['config']['gravatar_default'] = "identicon"

# errbit github integration
default['errbit']['config']['github_authentication'] = false
default['errbit']['config']['github_client_id'] = "github_client_id"
default['errbit']['config']['github_secret'] = "github_secret"
default['errbit']['config']['github_access_scope'] = ['repo']
# Local ruby to install via rbenv
default['errbit']['install_ruby'] = '2.2.4'

# 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'] = ""

# app server (Optional: More info in README)
default['errbit']['server'] = "unicorn" # or use others like puma
# dotenv file variables
#
## Errbit
default['errbit']['config']['errbit_host'] = 'errbit.example.com' # Don't default to FQDN, it might fail e-mail validation.
default['errbit']['config']['errbit_protocol'] = 'http'
default['errbit']['config']['errbit_port'] = 80
default['errbit']['config']['errbit_enforce_ssl'] = false
default['errbit']['config']['errbit_confirm_err_actions'] = true
default['errbit']['config']['errbit_user_has_username'] = true
default['errbit']['config']['errbit_use_gravatar'] = true
default['errbit']['config']['errbit_gravatar_default'] = 'identicon'
default['errbit']['config']['errbit_email_from'] = '[email protected]'
default['errbit']['config']['errbit_email_at_notices'] = [1, 10, 100]
default['errbit']['config']['errbit_per_app_email_at_notices'] = false
default['errbit']['config']['errbit_notify_at_notices'] = [0]
default['errbit']['config']['errbit_per_app_notify_at_notices'] = false
#
## GitHub
default['errbit']['config']['github_url'] = 'https://github.com'
default['errbit']['config']['github_authentication'] = false
default['errbit']['config']['github_client_id'] = nil
default['errbit']['config']['github_secret'] = nil
default['errbit']['config']['github_org_id'] = nil
default['errbit']['config']['github_access_scope'] = ['repo']
#
## SMTP
default['errbit']['config']['smtp_server'] = nil
default['errbit']['config']['smtp_port'] = nil
default['errbit']['config']['smtp_authentication'] = nil
default['errbit']['config']['smtp_username'] = nil
default['errbit']['config']['smtp_password'] = nil
default['errbit']['config']['smtp_domain'] = nil
#
## Sendmail
default['errbit']['config']['sendmail_location'] = nil
default['errbit']['config']['sendmail_arguments'] = nil
#
## Misc
default['errbit']['config']['devise_modules'] = %w( database_authenticatable recoverable rememberable trackable validatable omniauthable )
default['errbit']['config']['email_delivery_method'] = 'smtp'
default['errbit']['config']['mongo_url'] = 'mongodb://localhost/errbit'
default['errbit']['config']['rails_env'] = 'production'
default['errbit']['config']['secret_key_base'] = nil
default['errbit']['config']['serve_static_assets'] = true

default['errbit']['secret_token'] = 'b9e131c733a2672c79af5699f26e0bc5fba23a40ec51d76c9271c00097f35aa4c0993e1150f08048f0b66bd141cbcb58ab28814e35eb281c3cb2374aac160203'
# The cookbook currently only supports Puma on systemd and Unicorn on SysVinit.
default['errbit']['server']['name'] = node['init_package'] == 'systemd' ? 'puma' : 'unicorn'

default['errbit']['server']['backlog'] = 100
default['errbit']['server']['port'] = node['errbit']['config']['errbit_port']
default['errbit']['server']['preload_app'] = false
default['errbit']['server']['tcp_nodelay'] = true
default['errbit']['server']['tcp_nopush'] = true
default['errbit']['server']['timeout'] = 60
default['errbit']['server']['workers'] = 2
5 changes: 5 additions & 0 deletions chefignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,8 @@ Vagrantfile
# Travis #
##########
.travis.yml

# Kitchen #
###########
.kitchen/*
.kitchen.yml
36 changes: 0 additions & 36 deletions metadata.json

This file was deleted.

11 changes: 7 additions & 4 deletions metadata.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
name "errbit"
maintainer "Sachin Sagar Rai"
maintainer_email "[email protected]"
license "All rights reserved"
license "Apache 2.0"
description "Installs/Configures errbit"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.4.0"

depends "mongodb"
depends "git"
depends "unicorn"
depends "ruby_rbenv", ">= 2.0"
depends "apt"
depends "nginx"
depends "chef_nginx"
depends "build-essential"
depends "selinux_policy"

recommends "mongodb"

supports "centos"
supports "ubuntu"
44 changes: 35 additions & 9 deletions recipes/bootstrap.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
#
# Author:: Sachin Sagar Rai <[email protected]>
# Cookbook Name:: errbit
# Recipe:: setup
#
# Copyright (C) 2013 Millisami
#
# 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.
#

home_dir = "/home/#{node['errbit']['user']}"
current_dir = "#{node['errbit']['deploy_to']}/current"

Chef::Log.info "-" * 70
Chef::Log.info "Checking to bootstrap the admin user"
execute "check whether to bootstrap admin user" do
command "bundle exec rake db:seed -t"
cwd "#{node['errbit']['deploy_to']}/current"
environment ({'RAILS_ENV' => 'production'})
# not_if "bundle exec rails runner 'p User.where(admin: true).first'"
notifies :create, "ruby_block[remove_bootstrap]", :immediately
# notifies :restart, "service[unicorn_#{app['id']}]"
rbenv_script 'rake db:seed' do
code 'bundle exec rake db:seed RAILS_ENV=' + node['errbit']['config']['rails_env']
cwd current_dir
user node['errbit']['user']
rbenv_version node['errbit']['install_ruby']

not_if "#{home_dir}/.rbenv/bin/rbenv exec bundle exec rails runner 'exit User.where(:admin => true).exists?'", {
:cwd => current_dir,
:user => node['errbit']['user'],
:group => node['errbit']['group'],
:environment => { 'HOME' => home_dir }
}

notifies :run, "ruby_block[remove_bootstrap]", :immediately
end

ruby_block "remove_bootstrap" do
Expand Down
8 changes: 6 additions & 2 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#

include_recipe 'errbit::setup'
server = node['errbit']['server']
include_recipe 'errbit::' + node['errbit']['server']['name']

include_recipe "errbit::#{server}"
# Hack to work around systemd creating the socket with the wrong
# context and selinux_policy cookbook only running restorecon once.
execute "restorecon -R #{node['errbit']['deploy_to']}" do
only_if 'which restorecon'
end
21 changes: 0 additions & 21 deletions recipes/install_ruby.rb

This file was deleted.

49 changes: 42 additions & 7 deletions recipes/puma.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,50 @@
#
# Author:: Sachin Sagar Rai <[email protected]>
# Cookbook Name:: errbit
# Recipe:: default
# Recipe:: puma
#
# Copyright (C) 2013 Millisami
#
# All rights reserved - Do Not Redistribute
# 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.
#

template "#{node['errbit']['deploy_to']}/shared/config/puma.rb" do
source 'puma.rb.erb'
owner node['errbit']['user']
group node['errbit']['group']
mode 0644
end

['socket', 'service'].each do |unit|
template "/lib/systemd/system/puma-#{node['errbit']['name']}.#{unit}" do
source "puma.#{unit}.erb"
owner 'root'
group 'root'
mode 0644
end
end

service "puma-#{node['errbit']['name']}" do
supports [:reload, :restart, :status]
action :nothing

subscribes :reload, "template[/lib/systemd/system/puma-#{node['errbit']['name']}.service]"
subscribes :reload, "template[#{node['errbit']['deploy_to']}/shared/config/puma.rb]"
subscribes :reload, "file[#{node['errbit']['deploy_to']}/shared/config/env]"
subscribes :reload, "deploy_revision[#{node['errbit']['deploy_to']}]"
end

execute "puma app server" do
cwd "#{node['errbit']['deploy_to']}/current"
command "bundle exec puma -D"
# creates "/tmp/something"
action :run
service "puma-#{node['errbit']['name']}.socket" do
supports [:restart, :status]
action [:enable, :start]
end
Loading