Merge pull request #247 from dsander/chef-solo

Updated chef-solo deployment to work with current versions

Andrew Cantino 10 years ago
parent
commit
3c6339d78c

+ 3 - 0
deployment/.chef/knife.rb

@@ -0,0 +1,3 @@
1
+cookbook_path ["cookbooks", "site-cookbooks"]
2
+role_path     "roles"
3
+data_bag_path "data_bags"

+ 71 - 0
deployment/Cheffile.lock

@@ -0,0 +1,71 @@
1
+SITE
2
+  remote: http://community.opscode.com/api/v1
3
+  specs:
4
+    apt (2.3.8)
5
+    bluepill (2.3.1)
6
+      rsyslog (>= 0.0.0)
7
+    build-essential (2.0.0)
8
+    chef_handler (1.1.6)
9
+    dmg (2.2.0)
10
+    ohai (1.1.12)
11
+    rsyslog (1.12.2)
12
+    runit (1.5.10)
13
+      build-essential (>= 0.0.0)
14
+      yum (~> 3.0)
15
+      yum-epel (>= 0.0.0)
16
+    windows (1.30.2)
17
+      chef_handler (>= 0.0.0)
18
+    yum (3.2.0)
19
+    yum-epel (0.3.6)
20
+      yum (~> 3.0)
21
+
22
+GIT
23
+  remote: git://github.com/mdxp/nodejs-cookbook.git
24
+  ref: master
25
+  sha: e2415cd8c4e03dccf21d7ef6ca31e1c5c81467ca
26
+  specs:
27
+    nodejs (1.3.0)
28
+      apt (>= 0.0.0)
29
+      build-essential (>= 0.0.0)
30
+      yum-epel (>= 0.0.0)
31
+
32
+GIT
33
+  remote: git://github.com/opscode-cookbooks/git.git
34
+  ref: master
35
+  sha: 76b0f9bb08fdd9e2e201fd70b72298097accdf96
36
+  specs:
37
+    git (4.0.1)
38
+      build-essential (>= 0.0.0)
39
+      dmg (>= 0.0.0)
40
+      runit (>= 1.0)
41
+      windows (>= 0.0.0)
42
+      yum (~> 3.0)
43
+      yum-epel (>= 0.0.0)
44
+
45
+GIT
46
+  remote: git://github.com/opscode-cookbooks/mysql.git
47
+  ref: master
48
+  sha: a2ff53f0ca6deca75aebf6da55ac381194ec7728
49
+  specs:
50
+    mysql (5.1.9)
51
+
52
+GIT
53
+  remote: git://github.com/opscode-cookbooks/nginx.git
54
+  ref: master
55
+  sha: 05b3a613f53a0b05c96f9206c5d67aa420f337fb
56
+  specs:
57
+    nginx (2.6.3)
58
+      apt (~> 2.2)
59
+      bluepill (~> 2.3)
60
+      build-essential (~> 2.0)
61
+      ohai (~> 1.1)
62
+      runit (~> 1.2)
63
+      yum-epel (~> 0.3)
64
+
65
+DEPENDENCIES
66
+  git (>= 0)
67
+  mysql (>= 0)
68
+  nginx (>= 0)
69
+  nodejs (>= 0)
70
+  runit (>= 0)
71
+

+ 2 - 14
deployment/Vagrantfile

@@ -12,6 +12,8 @@ Vagrant.configure("2") do |config|
12 12
   end
13 13
 
14 14
   config.vm.provider :virtualbox do |vb, override|
15
+    #vb.memory = 1024
16
+    #vb.cpus = 4
15 17
     override.vm.box = "hashicorp/precise64"
16 18
     override.vm.network :forwarded_port, host: 3000, guest: 3000
17 19
   end
@@ -19,18 +21,4 @@ Vagrant.configure("2") do |config|
19 21
   config.vm.provider :parallels do |prl, override|
20 22
     override.vm.box = "parallels/ubuntu-12.04"
21 23
   end
22
-
23
-  config.vm.provider :aws do |aws, override| 
24
-    override.vm.box = "dummy"
25
-    override.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
26
-
27
-    aws.access_key_id = ""
28
-    aws.secret_access_key = ""
29
-    aws.keypair_name = ""
30
-    aws.region = "us-east-1"
31
-    aws.ami = "ami-d0f89fb9"
32
-
33
-    override.ssh.username = "ubuntu"
34
-    override.ssh.private_key_path = ""
35
-  end
36 24
 end

+ 1 - 1
deployment/roles/huginn_production.json

@@ -10,7 +10,7 @@
10 10
 
11 11
 "default_attributes" : {
12 12
   "mysql": {
13
-    "server_root_password": "",
13
+    "server_root_password": "password",
14 14
     "server_repl_password": "",
15 15
     "server_debian_password": ""
16 16
   },

+ 0 - 58
deployment/site-cookbooks/huginn_production/files/default/Gemfile

@@ -1,58 +0,0 @@
1
-source 'https://rubygems.org'
2
-
3
-gem 'rails'
4
-gem 'rake'
5
-gem 'mysql2'
6
-gem 'devise'
7
-gem 'kaminari'
8
-gem 'bootstrap-kaminari-views'
9
-gem "rufus-scheduler", :require => false
10
-gem 'json', '>= 1.7.7'
11
-gem 'jsonpath'
12
-gem 'twilio-ruby'
13
-
14
-gem 'delayed_job', :git => 'https://github.com/wok/delayed_job' # Until the YAML issues are fixed in master.
15
-gem 'delayed_job_active_record', "~> 0.3.3" # newer was giving a strange MySQL error
16
-gem "daemons"
17
-# gem "delayed_job_web"
18
-group :production do
19
-  gem 'unicorn'
20
-end
21
-gem 'foreman'
22
-gem 'dotenv-rails', :groups => [:development, :test]
23
-
24
-group :assets do
25
-  gem 'sass-rails',   '~> 3.2.3'
26
-  gem 'coffee-rails', '~> 3.2.1'
27
-  gem 'uglifier', '>= 1.0.3'
28
-  gem 'select2-rails'
29
-  gem 'jquery-rails'
30
-end
31
-
32
-gem 'geokit-rails3'
33
-gem 'kramdown'
34
-gem "typhoeus"
35
-gem 'nokogiri'
36
-gem 'wunderground'
37
-
38
-gem "twitter"
39
-gem 'twitter-stream', '>=0.1.16'
40
-gem 'em-http-request'
41
-
42
-platforms :ruby_18 do
43
-  gem 'system_timer'
44
-  gem 'fastercsv'
45
-end
46
-
47
-group :development do
48
-  gem 'pry'
49
-end
50
-
51
-group :development, :test do
52
-  gem 'rspec-rails'
53
-  gem 'rspec'
54
-  gem 'shoulda-matchers'
55
-  gem 'rr'
56
-  gem 'webmock', :require => false
57
-  gem 'rake'
58
-end

+ 4 - 4
deployment/site-cookbooks/huginn_production/files/default/Procfile

@@ -1,4 +1,4 @@
1
-web: sudo bundle exec unicorn_rails -c config/unicorn.rb
2
-schedule: sudo bundle exec rails runner bin/schedule.rb
3
-twitter: sudo bundle exec rails runner bin/twitter_stream.rb
4
-dj: sudo bundle exec script/delayed_job run
1
+web: sudo bundle exec unicorn_rails -c config/unicorn.rb -E production
2
+schedule: sudo RAILS_ENV=production bundle exec rails runner bin/schedule.rb
3
+twitter: sudo RAILS_ENV=production bundle exec rails runner bin/twitter_stream.rb
4
+dj: sudo RAILS_ENV=production bundle exec script/delayed_job run

+ 2 - 1
deployment/site-cookbooks/huginn_production/files/default/env.example

@@ -14,7 +14,7 @@ DATABASE_RECONNECT=true
14 14
 DATABASE_NAME=huginn_production
15 15
 DATABASE_POOL=5
16 16
 DATABASE_USERNAME=root
17
-DATABASE_PASSWORD=
17
+DATABASE_PASSWORD=password
18 18
 #DATABASE_HOST=your-domain-here.com
19 19
 #DATABASE_PORT=3306
20 20
 #DATABASE_SOCKET=/tmp/mysql.sock
@@ -23,6 +23,7 @@ DATABASE_PASSWORD=
23 23
 
24 24
 # Configure Rails environment.  This should only be needed in production and may cause errors in development.
25 25
 RAILS_ENV=production
26
+FORCE_SSL=false
26 27
 
27 28
 # Outgoing email settings.  To use Gmail or Google Apps, put your Google Apps domain or gmail.com
28 29
 # as the SMTP_DOMAIN and your Gmail username and password as the SMTP_USER_NAME and SMTP_PASSWORD.

+ 5 - 6
deployment/site-cookbooks/huginn_production/files/default/nginx.conf

@@ -1,15 +1,18 @@
1 1
 #worker_process 2;
2 2
 user huginn huginn;
3 3
 
4
-events { 
4
+events {
5 5
   worker_connections 1024;
6 6
   accept_mutex on;
7 7
 }
8 8
 
9 9
 http {
10
+  types_hash_max_size 2048;
11
+  include    mime.types;
12
+
10 13
   upstream huginn_server {
11 14
     server unix:/home/huginn/shared/tmp/sockets/unicorn.sock;
12
-}
15
+  }
13 16
 
14 17
   server {
15 18
     listen 80;
@@ -23,13 +26,9 @@ http {
23 26
     }
24 27
     location @app {
25 28
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
26
-
27 29
       proxy_set_header X-Forwarded-Proto $scheme;
28
-
29 30
       proxy_set_header Host $http_host;
30
-
31 31
       proxy_redirect off;
32
-
33 32
       proxy_pass http://huginn_server;
34 33
     }
35 34
 }

+ 4 - 2
deployment/site-cookbooks/huginn_production/files/default/unicorn.rb

@@ -17,7 +17,8 @@ stdout_path "log/unicorn_err.log"
17 17
 pid '/home/huginn/shared/tmp/pids/unicorn.pid'
18 18
 
19 19
 before_fork do |server, worker|
20
-  ActiveRecord::Base.connection.disconnect!
20
+  defined?(ActiveRecord::Base) and
21
+    ActiveRecord::Base.connection.disconnect!
21 22
   old_pid = "#{server.config[:pid]}.oldbin"
22 23
   if File.exists?(old_pid) && server.pid != old_pid
23 24
     begin
@@ -29,5 +30,6 @@ before_fork do |server, worker|
29 30
 end
30 31
 
31 32
 after_fork do |server, worker|
32
-  ActiveRecord::Base.establish_connection
33
+  defined?(ActiveRecord::Base) and
34
+    ActiveRecord::Base.establish_connection
33 35
 end

+ 11 - 9
deployment/site-cookbooks/huginn_production/recipes/default.rb

@@ -14,7 +14,7 @@ group "huginn" do
14 14
   members ["huginn"]
15 15
 end
16 16
 
17
-%w("ruby1.9.1" "ruby1.9.1-dev" "libxslt-dev" "libxml2-dev" "curl" "libshadow-ruby1.8" "libmysqlclient-dev").each do |pkg|
17
+%w("ruby1.9.1" "ruby1.9.1-dev" "libxslt-dev" "libxml2-dev" "curl" "libshadow-ruby1.8" "libmysqlclient-dev" "libffi-dev" "libssl-dev").each do |pkg|
18 18
   package("#{pkg}")
19 19
 end
20 20
 
@@ -36,6 +36,7 @@ end
36 36
 
37 37
 deploy "/home/huginn" do
38 38
   repo "https://github.com/cantino/huginn.git"
39
+  branch "master"
39 40
   user "huginn"
40 41
   group "huginn"
41 42
   environment "RAILS_ENV" => "production"
@@ -56,7 +57,7 @@ deploy "/home/huginn" do
56 57
     end
57 58
     directory("/home/huginn/shared/tmp/pids")
58 59
     directory("/home/huginn/shared/tmp/sockets")
59
-    %w(Procfile unicorn.rb Gemfile nginx.conf).each do |file|
60
+    %w(Procfile unicorn.rb nginx.conf).each do |file|
60 61
       cookbook_file "/home/huginn/shared/config/#{file}" do
61 62
       owner "huginn"
62 63
       action :create_if_missing
@@ -77,16 +78,17 @@ deploy "/home/huginn" do
77 78
       code <<-EOH
78 79
       export LANG="en_US.UTF-8"
79 80
       export LC_ALL="en_US.UTF-8"
80
-      ln -nfs /home/huginn/shared/config/Gemfile ./Gemfile
81 81
       ln -nfs /home/huginn/shared/config/Procfile ./Procfile
82 82
       ln -nfs /home/huginn/shared/config/.env ./.env
83 83
       ln -nfs /home/huginn/shared/config/unicorn.rb ./config/unicorn.rb
84
-      sudo cp /home/huginn/shared/config/nginx.conf /etc/nginx/ 
85
-      sudo bundle install
86
-      sed -i s/REPLACE_ME_NOW\!/$(sudo rake secret)/ .env
87
-      sudo bundle exec rake db:create
88
-      sudo bundle exec rake db:migrate
89
-      sudo bundle exec rake db:seed
84
+      sudo cp /home/huginn/shared/config/nginx.conf /etc/nginx/
85
+      echo 'gem "unicorn", :group => :production' >> Gemfile
86
+      sudo bundle install --without=development --without=test
87
+      sed -i s/REPLACE_ME_NOW\!/$(sudo bundle exec rake secret)/ .env
88
+      sudo RAILS_ENV=production bundle exec rake db:create
89
+      sudo RAILS_ENV=production bundle exec rake db:migrate
90
+      sudo RAILS_ENV=production bundle exec rake db:seed
91
+      sudo RAILS_ENV=production bundle exec rake assets:precompile
90 92
       sudo foreman export upstart /etc/init -a huginn -u huginn -l log
91 93
       sudo start huginn
92 94
       EOH

+ 0 - 6
deployment/solo.rb

@@ -1,6 +0,0 @@
1
-file_cache_path           "/tmp/chef-solo"
2
-data_bag_path             "/tmp/chef-solo/data_bags"
3
-encrypted_data_bag_secret "/tmp/chef-solo/data_bag_key"
4
-cookbook_path             [ "/tmp/chef-solo/site-cookbooks",
5
-                            "/tmp/chef-solo/cookbooks" ]
6
-role_path                 "/tmp/chef-solo/roles"