This repository has been archived by the owner on Jul 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
72ca278
commit dcee8bd
Showing
14 changed files
with
218 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name 'rubygems-app' | ||
|
||
version '0.0.34' | ||
version '0.0.36' | ||
|
||
depends 'apt' | ||
depends 'chef-vault' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default['rubygems-hubot']['deploy_dir'] = '/var/lib/hubot-capistrano' |
46 changes: 46 additions & 0 deletions
46
cookbooks/rubygems-hubot/files/default/scripts/deploy.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Description: | ||
# Allows hubot to interact with capistrano. | ||
# | ||
# Dependencies: | ||
# None | ||
# | ||
# Configuration: | ||
# None | ||
# | ||
# Commands: | ||
# hubot deploy <env> | ||
# | ||
# Author: | ||
# Shopify, David Radcliffe | ||
|
||
spawn = require("child_process").spawn | ||
|
||
exec = (command, args, callback) -> | ||
data = "" | ||
|
||
options = { env: { HOME: process.env["HOME"], PATH: process.env["PATH"], PWD: '/var/lib/hubot-capistrano/staging' } } | ||
proc = spawn(command, args, options) | ||
|
||
proc.stdout.on "data", (chunk) -> | ||
data += chunk | ||
|
||
proc.stderr.on "data", (chunk) -> | ||
data += chunk | ||
|
||
proc.on "error", (err) -> | ||
callback "Error: #{err}" | ||
|
||
proc.on "close", (exit_code)-> | ||
if exit_code == 0 | ||
callback data | ||
else | ||
callback "Exited with #{exit_code}\n#{data}" | ||
|
||
module.exports = (robot) -> | ||
robot.respond /deploy\s+(production|staging)/i, (msg) -> | ||
env = msg.match[1] | ||
msg.send "Deploying to #{env}..." | ||
cap_command = "cap #{env} deploy" | ||
server = if env == 'production' then 'bastion02.production.rubygems.org' else 'bastion01.staging.rubygems.org' | ||
exec "bundle", ["exec", cap_command], (result) -> | ||
msg.send "```\n#{result}\n```\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
name 'rubygems-hubot' | ||
|
||
version '0.0.2' | ||
version '0.0.23' | ||
|
||
depends 'chef-vault' | ||
depends 'hubot', '~> 1.0.2' | ||
depends 'rsyslog' | ||
depends 'rubygems-ruby' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# | ||
# Cookbook Name:: rubygems-hubot | ||
# Recipe:: deploy | ||
# | ||
|
||
package 'libpq-dev' | ||
|
||
directory node['rubygems-hubot']['deploy_dir'] do | ||
user 'hubot' | ||
group 'hubot' | ||
end | ||
|
||
git "#{node['rubygems-hubot']['deploy_dir']}/staging" do | ||
repository 'https://github.com/rubygems/rubygems.org.git' | ||
reference 'master' | ||
user node['hubot']['user'] | ||
group node['hubot']['group'] | ||
action :sync | ||
notifies :run, "execute[bundle_install_deploy]", :immediately | ||
end | ||
|
||
execute "bundle_install_deploy" do | ||
command "bundle install --local --deployment" | ||
cwd "#{node['rubygems-hubot']['deploy_dir']}/staging" | ||
user node['hubot']['user'] | ||
group node['hubot']['group'] | ||
action :nothing | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# | ||
# Cookbook Name:: rubygems-hubot | ||
# Recipe:: ssh | ||
# | ||
|
||
include_recipe 'chef-vault' | ||
hubot_secrets = chef_vault_item('hubot', 'keys') | ||
|
||
directory "#{node['hubot']['install_dir']}/.ssh" do | ||
owner node['hubot']['user'] | ||
mode 0700 | ||
end | ||
|
||
file "#{node['hubot']['install_dir']}/.ssh/id_rsa" do | ||
owner node['hubot']['user'] | ||
mode 0600 | ||
content hubot_secrets['private'] | ||
end | ||
|
||
file "#{node['hubot']['install_dir']}/.ssh/id_rsa.pub" do | ||
owner node['hubot']['user'] | ||
content hubot_secrets['public'] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"id":"hubot", | ||
"username": "hubot", | ||
"comment": "Hubot", | ||
"admin" : true, | ||
"deployer": true, | ||
"environments": [ | ||
"staging", | ||
"production" | ||
], | ||
"ssh_keys": [ | ||
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCru1+Cxtmeyv4MQ2n+j+67JhIV2C/azQmF/gqogh4degA73NwUs++aCPcrXQ3nN3YKJ6Bs/1s7n8kDK7Sl+bwaefTwBxsP+5rlOvnJ0TvGW2YgzneJybEcd83CBUg9wrgaSslMvAcOPQqcQnrlnjrh6m/Tn0lWMH3bKBAFGq/0iQRDFDXJu3xLaW6mQER51MyFPUbtBQYF5XTaI5rny+Z3DxY/k0EPN/Ojkte64I+KGgUkWAiweT0ZA8LJfM6Y84MtRbXcDliCLiadlwWsbJ6TQplRy8a2jUSWcLdOLZv5CsI0qhvjRTPxetpHaaQBxDmR2rbdXCL4G4MCTk96p+Oj hubot" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name 'bot' | ||
description 'Hubot' | ||
run_list( | ||
'recipe[rubygems]', | ||
'recipe[rubygems-hubot]' | ||
) |