This repository has been archived by the owner on Jun 13, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #973 from till/r/scholar-deploy-manager
Refactor: move scholar to easybib_deploy_manager
- Loading branch information
Showing
10 changed files
with
178 additions
and
55 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,3 +1,21 @@ | ||
force_default['haproxy']['ssl'] = 'on' | ||
force_default['haproxy']['type'] = '1.5' | ||
force_default['ssl-deploy']['ssl-role'] = 'lb' | ||
|
||
default['stack-scholar']['applications'] = { | ||
:scholar => { | ||
:layer => nil, | ||
:nginx => 'scholar.conf.erb', | ||
:nginx_config => { | ||
:listen_opts => 'default_server' | ||
} | ||
}, | ||
:scholar_admin => { | ||
:layer => 'nginxphpapp', | ||
:nginx => 'silex.conf.erb' | ||
}, | ||
:scholar_realtime => { | ||
:layer => nil, | ||
:nginx => nil | ||
} | ||
} |
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,49 +1,18 @@ | ||
include_recipe 'php-fpm::service' | ||
include_recipe 'nginx-app::service' | ||
|
||
node['deploy'].each do |application, deploy| | ||
listen_opts = nil | ||
node.set['stack-scholar']['applications']['scholar']['layer'] = [ | ||
'nginxphpapp', | ||
node['easybib_deploy']['supervisor_role'] | ||
] | ||
|
||
case application | ||
when 'scholar_admin' | ||
next unless allow_deploy(application, 'scholar_admin', 'nginxphpapp') | ||
when 'scholar_realtime' | ||
if node['haproxy']['websocket_layers'].nil? | ||
next | ||
end | ||
|
||
next unless allow_deploy(application, 'scholar_realtime', node['haproxy']['websocket_layers'].keys) | ||
when 'scholar' | ||
listen_opts = 'default_server' | ||
supervisor_role = node['easybib_deploy']['supervisor_role'] | ||
next unless allow_deploy(application, 'scholar', ['nginxphpapp', supervisor_role]) | ||
else | ||
Chef::Log.info("deploy::scholar - #{application} skipped") | ||
next | ||
end | ||
|
||
Chef::Log.info("deploy::#{application} - Deployment started.") | ||
Chef::Log.info("deploy::#{application} - Deploying as user: #{deploy['user']} and #{deploy['group']}") | ||
|
||
easybib_deploy application do | ||
deploy_data deploy | ||
app application | ||
end | ||
|
||
config_template = if application == 'scholar' | ||
'scholar.conf.erb' | ||
else | ||
'silex.conf.erb' | ||
end | ||
unless node['haproxy']['websocket_layers'].nil? | ||
node.set['stack-scholar']['applications']['scholar_realtime']['layer'] = node['haproxy']['websocket_layers'].keys | ||
end | ||
|
||
easybib_nginx application do | ||
config_template config_template | ||
domain_name deploy['domains'].join(' ') | ||
doc_root deploy['document_root'] | ||
htpasswd "#{deploy['deploy_to']}/current/htpasswd" | ||
listen_opts listen_opts | ||
notifies :reload, 'service[nginx]', :delayed | ||
notifies node['easybib-deploy']['php-fpm']['restart-action'], 'service[php-fpm]', :delayed | ||
end | ||
Chef::Log.info(node['stack-scholar']['applications']) | ||
|
||
easybib_deploy_manager get_cluster_name do | ||
apps node['stack-scholar']['applications'] | ||
deployments node['deploy'] | ||
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,39 @@ | ||
require 'chefspec' | ||
require 'json' | ||
|
||
describe 'fixtures::brokenapps' do | ||
|
||
let(:cookbook_paths) do | ||
[ | ||
File.expand_path("#{File.dirname(__FILE__)}/../../"), | ||
File.expand_path("#{File.dirname(__FILE__)}/") | ||
] | ||
end | ||
|
||
let(:runner) do | ||
ChefSpec::Runner.new( | ||
:cookbook_path => cookbook_paths, | ||
:step_into => %w(easybib_deploy_manager) | ||
) | ||
end | ||
let(:chef_run) { runner.converge(described_recipe) } | ||
let(:node) { runner.node } | ||
|
||
let(:fixtures) { "#{File.dirname(__FILE__)}/fixtures" } | ||
|
||
before do | ||
node.set['opsworks']['stack']['name'] = 'stack-chefspec' | ||
node.set['opsworks']['instance']['layers'] = ['node-chefspec'] | ||
end | ||
|
||
describe 'broken apps' do | ||
before do | ||
node.set['deploy'] = JSON.parse(File.read("#{fixtures}/deploy.json")) | ||
node.set['stack-chefspec']['applications'] = JSON.parse(File.read("#{fixtures}/brokenapps.json")) | ||
end | ||
|
||
it 'chef throws an exception' do | ||
expect { chef_run }.to raise_error(RuntimeError) | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"scholar_realtime": ["consumer"] | ||
} |
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,56 @@ | ||
{ | ||
"scholar_admin": { | ||
"deploy_to": "/srv/www/scholar_admin", | ||
"chef_provider": "Timestamped", | ||
"keep_releases": 5, | ||
"current_path": "/srv/www/scholar_admin/current", | ||
"document_root": "web", | ||
"ignore_bundler_groups": ["test", "development"], | ||
"absolute_document_root": "/srv/www/scholar_admin/current/web/", | ||
"rake": "/usr/local/bin/rake", | ||
"migrate": false, | ||
"migrate_command": "", | ||
"rails_env": "production", | ||
"action": "deploy", | ||
"user": "deploy", | ||
"group": "deploy", | ||
"shell": "/no/login", | ||
"home": "/var/www", | ||
"sleep_before_restart": 0, | ||
"stack": { | ||
"needs_reload": true | ||
}, | ||
"enable_submodules": true, | ||
"shallow_clone": false, | ||
"delete_cached_copy": true, | ||
"purge_before_symlink": ["log", "tmp/pids", "public/system"], | ||
"create_dirs_before_symlink": ["tmp", "public", "config"], | ||
"symlink_before_migrate": {}, | ||
"symlinks": { | ||
"system": "public/system", | ||
"pids": "tmp/pids", | ||
"log": "log" | ||
}, | ||
"environment": { | ||
"HOME": "/var/www" | ||
}, | ||
"environment_variables": {}, | ||
"ssl_support": false, | ||
"application": "scholar_admin", | ||
"application_type": "other", | ||
"auto_bundle_on_deploy": true, | ||
"deploying_user": "arn:aws:iam::12345:user/till", | ||
"domains": ["example.org", "scholar_admin"], | ||
"mounted_at": null, | ||
"restart_command": "echo 'restarting app'", | ||
"ssl_certificate": null, | ||
"ssl_certificate_key": null, | ||
"ssl_certificate_ca": null, | ||
"scm": { | ||
"scm_type": "s3", | ||
"repository": "https://deploy/zip", | ||
"user": "", | ||
"password": "" | ||
} | ||
} | ||
} |
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,4 @@ | ||
name 'fixtures' | ||
version '0.99.0' | ||
|
||
depends 'easybib' |
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,4 @@ | ||
easybib_deploy_manager get_cluster_name do | ||
apps node['stack-chefspec']['applications'] | ||
deployments node['deploy'] | ||
end |