mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
Using Deploy resource(Chef)
This commit is contained in:
parent
3d76e3990e
commit
6618b2cb09
9 changed files with 82 additions and 130 deletions
|
@ -1,45 +0,0 @@
|
|||
Make sure you have Vagrant and Virtualbox(Not necessary, if deploying to AWS) installed.
|
||||
Install librarian-chef gem
|
||||
|
||||
gem install librarian-chef
|
||||
|
||||
And Vagrant plugins
|
||||
|
||||
vagrant plugin install vagrant-aws
|
||||
vagrant plugin install vagrant-omnibus
|
||||
|
||||
Move to `/deployment` and run
|
||||
|
||||
librarian-chef install
|
||||
|
||||
This will install all the cookbooks mentioned in Cheffile.
|
||||
|
||||
To install Huginn on AWS, fill the Vagrantfile with your account details and run
|
||||
|
||||
vagrant up ec2 --provider=aws
|
||||
|
||||
To install it on a virtualbox VM:
|
||||
|
||||
vagrant up vb
|
||||
|
||||
It'll install huginn and get the server started. You can now go to `yourserver.com/3000` to use huginn if you are in virtualbox. On ec2, pointing to public DNS will let you access huginn. Huginn will be at `/home/huginn/huginn`. A new dedicated user will be created for managing huginn with username `huginn` and password `huginn`. To ssh into ec2:
|
||||
|
||||
vagrant ssh ec2
|
||||
|
||||
Similarly, to ssh into VirtualBox
|
||||
|
||||
vagrant ssh vb
|
||||
|
||||
After ssh-ing into ec2, you can start(its already running), stop or restart huginn by
|
||||
|
||||
sudo start huginn
|
||||
sudo stop huginn
|
||||
sudo restart huginn
|
||||
|
||||
To terminate ec2 instance:
|
||||
|
||||
vagrant destroy ec2
|
||||
|
||||
Similarly, to destroy VirtualBox VM
|
||||
|
||||
vagrant destroy vb
|
11
deployment/Vagrantfile
vendored
11
deployment/Vagrantfile
vendored
|
@ -43,16 +43,7 @@ Vagrant.configure("2") do |config|
|
|||
chef.roles_path = "roles"
|
||||
chef.cookbooks_path = ["cookbooks", "site-cookbooks"]
|
||||
chef.add_role("huginn_production")
|
||||
chef.json = {
|
||||
"mysql"=> {
|
||||
"server_root_password" => "",
|
||||
"server_repl_password" => "",
|
||||
"server_debian_password"=> ""
|
||||
},
|
||||
"nginx" => {
|
||||
'init_style' => "upstart"
|
||||
}
|
||||
}
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
0
deployment/nodes/.gitignore
vendored
Normal file
0
deployment/nodes/.gitignore
vendored
Normal file
|
@ -8,6 +8,17 @@
|
|||
|
||||
"description" : "Huginn Production Environment",
|
||||
|
||||
"default_attributes" : {
|
||||
"mysql": {
|
||||
"server_root_password": "",
|
||||
"server_repl_password": "",
|
||||
"server_debian_password": ""
|
||||
},
|
||||
"nginx" : {
|
||||
"init_style" : "upstart"
|
||||
}
|
||||
},
|
||||
|
||||
"run_list":[
|
||||
"recipe[git]",
|
||||
"recipe[apt]",
|
||||
|
|
|
@ -8,18 +8,18 @@ events {
|
|||
|
||||
http {
|
||||
upstream huginn_server {
|
||||
server unix:/home/huginn/huginn/tmp/sockets/unicorn.sock;
|
||||
server unix:/home/huginn/shared/tmp/sockets/unicorn.sock;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
keepalive_timeout 5;
|
||||
root /home/huginn/huginn/public;
|
||||
root /home/huginn/current/public;
|
||||
try_files $uri/index.html $uri.html $uri @app;
|
||||
error_page 500 502 503 504 /500.html;
|
||||
location = /500.html {
|
||||
root /home/huginn/huginn/public;
|
||||
root /home/huginn/current/public;
|
||||
}
|
||||
location @app {
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
app_path = "/home/huginn/huginn"
|
||||
app_path = "/home/huginn/current"
|
||||
|
||||
worker_processes 2
|
||||
preload_app true
|
||||
timeout 180
|
||||
listen '/home/huginn/huginn/tmp/sockets/unicorn.sock'
|
||||
listen '/home/huginn/shared/tmp/sockets/unicorn.sock'
|
||||
|
||||
working_directory app_path
|
||||
|
||||
|
@ -14,7 +14,7 @@ stderr_path "log/unicorn_out.log"
|
|||
stdout_path "log/unicorn_err.log"
|
||||
|
||||
# Set master PID location
|
||||
pid '/home/huginn/huginn/tmp/pids/unicorn.pid'
|
||||
pid '/home/huginn/shared/tmp/pids/unicorn.pid'
|
||||
|
||||
before_fork do |server, worker|
|
||||
ActiveRecord::Base.connection.disconnect!
|
||||
|
|
|
@ -2,7 +2,6 @@ include_recipe 'apt'
|
|||
include_recipe 'build-essential'
|
||||
|
||||
user "huginn" do
|
||||
action :create
|
||||
system true
|
||||
home "/home/huginn"
|
||||
password "$6$ZwO6b.6tij$SMa8UIwtESGDxB37NwHsct.gJfXWmmflNbH.oypwJ9y0KkzMkCdw7D14iK7GX9C4CWSEcpGOFUow7p01rQFu5."
|
||||
|
@ -13,66 +12,15 @@ end
|
|||
|
||||
group "huginn" do
|
||||
members ["huginn"]
|
||||
action :create
|
||||
end
|
||||
|
||||
%w("ruby1.9.1" "ruby1.9.1-dev" "libxslt-dev" "libxml2-dev" "curl" "libshadow-ruby1.8").each do |pkg|
|
||||
package pkg do
|
||||
action :install
|
||||
end
|
||||
end
|
||||
|
||||
git "/home/huginn/huginn" do
|
||||
repository 'git://github.com/cantino/huginn.git'
|
||||
reference 'master'
|
||||
action :sync
|
||||
user "huginn"
|
||||
package("#{pkg}")
|
||||
end
|
||||
|
||||
gem_package("rake")
|
||||
gem_package("bundle")
|
||||
|
||||
cookbook_file "/etc/nginx/nginx.conf" do
|
||||
source "nginx.conf"
|
||||
owner "huginn"
|
||||
end
|
||||
|
||||
directory "/home/huginn/huginn/tmp" do
|
||||
action :create
|
||||
owner "huginn"
|
||||
recursive true
|
||||
end
|
||||
|
||||
directory "/home/huginn/huginn/log" do
|
||||
action :create
|
||||
owner "huginn"
|
||||
recursive true
|
||||
end
|
||||
|
||||
cookbook_file "/home/huginn/huginn/config/unicorn.rb" do
|
||||
source "unicorn.rb"
|
||||
mode "644"
|
||||
owner "huginn"
|
||||
end
|
||||
|
||||
cookbook_file "home/huginn/huginn/Gemfile" do
|
||||
source "Gemfile"
|
||||
mode "644"
|
||||
owner "huginn"
|
||||
end
|
||||
|
||||
cookbook_file "home/huginn/huginn/.env" do
|
||||
source ".env.example"
|
||||
mode "666"
|
||||
owner "huginn"
|
||||
end
|
||||
|
||||
cookbook_file "home/huginn/huginn/Procfile" do
|
||||
source "Procfile"
|
||||
mode "444"
|
||||
owner "huginn"
|
||||
end
|
||||
|
||||
service "nginx" do
|
||||
action :start
|
||||
end
|
||||
|
@ -80,24 +28,65 @@ end
|
|||
bash "Setting huginn user with NOPASSWD option" do
|
||||
cwd "/etc/sudoers.d"
|
||||
code <<-EOH
|
||||
touch huginn
|
||||
chmod 0440 huginn
|
||||
touch huginn && chmod 0440 huginn
|
||||
echo "huginn ALL=(ALL) NOPASSWD:ALL" >> huginn
|
||||
EOH
|
||||
end
|
||||
|
||||
bash "huginn dependencies" do
|
||||
cwd "/home/huginn/huginn"
|
||||
deploy "/home/huginn" do
|
||||
repo "https://github.com/cantino/huginn.git"
|
||||
user "huginn"
|
||||
code <<-EOH
|
||||
export LANG="en_US.UTF-8"
|
||||
export LC_ALL="en_US.UTF-8"
|
||||
sudo bundle install
|
||||
sed -i s/REPLACE_ME_NOW\!/$(sudo rake secret)/ .env
|
||||
sudo rake db:create
|
||||
sudo rake db:migrate
|
||||
sudo rake db:seed
|
||||
sudo foreman export upstart /etc/init -a huginn -u huginn
|
||||
sudo start huginn
|
||||
EOH
|
||||
end
|
||||
environment "RAILS_ENV" => "production"
|
||||
keep_releases 5
|
||||
create_dirs_before_symlink []
|
||||
symlinks "log" => "log"
|
||||
symlink_before_migrate({})
|
||||
rollback_on_error true
|
||||
before_symlink do
|
||||
%w(config log tmp).each do |dir|
|
||||
directory "/home/huginn/shared/#{dir}" do
|
||||
owner "huginn"
|
||||
recursive true
|
||||
end
|
||||
end
|
||||
directory("/home/huginn/shared/tmp/pids")
|
||||
directory("/home/huginn/shared/tmp/sockets")
|
||||
cookbook_file "/etc/nginx/nginx.conf" do
|
||||
source "nginx.conf"
|
||||
owner "huginn"
|
||||
end
|
||||
%w(Procfile unicorn.rb Gemfile).each do |file|
|
||||
cookbook_file "/home/huginn/shared/config/#{file}" do
|
||||
owner "huginn"
|
||||
action :create_if_missing
|
||||
end
|
||||
end
|
||||
cookbook_file "home/huginn/shared/config/.env" do
|
||||
source "env.example"
|
||||
mode "666"
|
||||
owner "huginn"
|
||||
action :create_if_missing
|
||||
end
|
||||
end
|
||||
before_restart do
|
||||
bash "huginn dependencies" do
|
||||
cwd "/home/huginn/current"
|
||||
user "huginn"
|
||||
code <<-EOH
|
||||
export LANG="en_US.UTF-8"
|
||||
export LC_ALL="en_US.UTF-8"
|
||||
ln -nfs /home/huginn/shared/config/Gemfile ./Gemfile
|
||||
ln -nfs /home/huginn/shared/config/Procfile ./Procfile
|
||||
ln -nfs /home/huginn/shared/config/.env ./.env
|
||||
ln -nfs /home/huginn/shared/config/unicorn.rb ./config/unicorn.rb
|
||||
sudo bundle install
|
||||
sed -i s/REPLACE_ME_NOW\!/$(sudo rake secret)/ .env
|
||||
sudo rake db:create
|
||||
sudo rake db:migrate
|
||||
sudo rake db:seed
|
||||
sudo foreman export upstart /etc/init -a huginn -u huginn -l log
|
||||
sudo start huginn
|
||||
EOH
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
6
deployment/solo.rb
Normal file
6
deployment/solo.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
file_cache_path "/tmp/chef-solo"
|
||||
data_bag_path "/tmp/chef-solo/data_bags"
|
||||
encrypted_data_bag_secret "/tmp/chef-solo/data_bag_key"
|
||||
cookbook_path [ "/tmp/chef-solo/site-cookbooks",
|
||||
"/tmp/chef-solo/cookbooks" ]
|
||||
role_path "/tmp/chef-solo/roles"
|
Loading…
Add table
Reference in a new issue