Permalink
Browse files

Recipes cleanup: added missing actions and shutdown recipe

  • Loading branch information...
ajgon committed Apr 16, 2016
1 parent aba311b commit 9eb9bb8f3121805a39375e31115b1b04e8ebdd25
Showing with 109 additions and 24 deletions.
  1. +4 −0 recipes/configure.rb
  2. +22 −9 recipes/deploy.rb
  3. +10 −6 recipes/setup.rb
  4. +21 −0 recipes/shutdown.rb
  5. +22 −9 recipes/undeploy.rb
  6. +4 −0 spec/spec_helper.rb
  7. +26 −0 spec/unit/recipes/shutdown_spec.rb
View
@@ -17,6 +17,10 @@
database.configure(self)
end
scm = Drivers::Scm::Factory.build(application, node)
scm.configure(self)
framework = Drivers::Framework::Factory.build(application, node)
framework.configure(self)
appserver = Drivers::Appserver::Factory.build(application, node)
appserver.configure(self)
webserver = Drivers::Webserver::Factory.build(application, node)
View
@@ -1,17 +1,24 @@
# frozen_string_literal: true
include_recipe 'opsworks_ruby::configure'
every_enabled_application do |app, deploy|
scm = Drivers::Scm::Factory.build(app, node)
appserver = Drivers::Appserver::Factory.build(app, node)
framework = Drivers::Framework::Factory.build(app, node)
every_enabled_application do |application, deploy|
every_enabled_rds do |rds|
database = Drivers::Db::Factory.build(application, node, rds: rds)
database.before_deploy(self)
end
scm = Drivers::Scm::Factory.build(application, node)
framework = Drivers::Framework::Factory.build(application, node)
appserver = Drivers::Appserver::Factory.build(application, node)
webserver = Drivers::Webserver::Factory.build(application, node)
scm.before_deploy(self)
appserver.before_deploy(self)
framework.before_deploy(self)
appserver.before_deploy(self)
webserver.before_deploy(self)
deploy app['shortname'] do
deploy_to deploy_dir(app)
deploy application['shortname'] do
deploy_to deploy_dir(application)
user node['deployer']['user'] || 'root'
group www_group
rollback_on_error true
@@ -29,7 +36,7 @@
appserver.notifies[:deploy].each do |config|
notifies config[:action],
config[:resource].respond_to?(:call) ? config[:resource].call(app) : config[:resource],
config[:resource].respond_to?(:call) ? config[:resource].call(application) : config[:resource],
config[:timer]
end
@@ -57,7 +64,13 @@
end
end
framework.after_deploy(self)
webserver.after_deploy(self)
appserver.after_deploy(self)
framework.after_deploy(self)
scm.after_deploy(self)
every_enabled_rds do |rds|
database = Drivers::Db::Factory.build(application, node, rds: rds)
database.after_deploy(self)
end
end
View
@@ -13,14 +13,18 @@
to '/usr/bin/bundle'
end
every_enabled_application do |application|
scm = Drivers::Scm::Factory.build(application, node)
scm.setup(self)
webserver = Drivers::Webserver::Factory.build(application, node)
webserver.setup(self)
every_enabled_application do |application, _deploy|
every_enabled_rds do |rds|
database = Drivers::Db::Factory.build(application, node, rds: rds)
database.setup(self)
end
scm = Drivers::Scm::Factory.build(application, node)
scm.setup(self)
framework = Drivers::Framework::Factory.build(application, node)
framework.setup(self)
appserver = Drivers::Appserver::Factory.build(application, node)
appserver.setup(self)
webserver = Drivers::Webserver::Factory.build(application, node)
webserver.setup(self)
end
View
@@ -0,0 +1,21 @@
# frozen_string_literal: true
#
# Cookbook Name:: opsworks_ruby
# Recipe:: shutdown
#
every_enabled_application do |application, _deploy|
every_enabled_rds do |rds|
database = Drivers::Db::Factory.build(application, node, rds: rds)
database.shutdown(self)
end
scm = Drivers::Scm::Factory.build(application, node)
scm.shutdown(self)
framework = Drivers::Framework::Factory.build(application, node)
framework.shutdown(self)
appserver = Drivers::Appserver::Factory.build(application, node)
appserver.shutdown(self)
webserver = Drivers::Webserver::Factory.build(application, node)
webserver.shutdown(self)
end
View
@@ -1,29 +1,42 @@
# frozen_string_literal: true
every_enabled_application do |app, _deploy|
scm = Drivers::Scm::Factory.build(app, node)
appserver = Drivers::Appserver::Factory.build(app, node)
framework = Drivers::Framework::Factory.build(app, node)
every_enabled_application do |application, _deploy|
every_enabled_rds do |rds|
database = Drivers::Db::Factory.build(application, node, rds: rds)
database.before_undeploy(self)
end
scm = Drivers::Scm::Factory.build(application, node)
framework = Drivers::Framework::Factory.build(application, node)
appserver = Drivers::Appserver::Factory.build(application, node)
webserver = Drivers::Webserver::Factory.build(application, node)
scm.before_undeploy(self)
appserver.before_undeploy(self)
framework.before_undeploy(self)
appserver.before_undeploy(self)
webserver.before_undeploy(self)
deploy app['shortname'] do
deploy_to deploy_dir(app)
deploy application['shortname'] do
deploy_to deploy_dir(application)
user node['deployer']['user'] || 'root'
group www_group
appserver.notifies[:undeploy].each do |config|
notifies config[:action],
config[:resource].respond_to?(:call) ? config[:resource].call(app) : config[:resource],
config[:resource].respond_to?(:call) ? config[:resource].call(application) : config[:resource],
config[:timer]
end
action :rollback
end
framework.after_undeploy(self)
webserver.after_undeploy(self)
appserver.after_undeploy(self)
framework.after_undeploy(self)
scm.after_undeploy(self)
every_enabled_rds do |rds|
database = Drivers::Db::Factory.build(application, node, rds: rds)
database.after_undeploy(self)
end
end
View
@@ -8,4 +8,8 @@
# Require all fixtures
Dir[File.expand_path('../fixtures/*.rb', __FILE__)].each { |f| require f }
RSpec.configure do |config|
config.log_level = :error
end
at_exit { ChefSpec::Coverage.report! }
@@ -0,0 +1,26 @@
# frozen_string_literal: true
#
# Cookbook Name:: opsworks_ruby
# Spec:: shutdown
#
# Copyright (c) 2016 The Authors, All Rights Reserved.
require 'spec_helper'
describe 'opsworks_ruby::shutdown' do
let(:chef_run) do
ChefSpec::SoloRunner.new do |solo_node|
solo_node.set['deploy'] = node['deploy']
end.converge(described_recipe)
end
before do
stub_search(:aws_opsworks_app, '*:*').and_return([aws_opsworks_app])
stub_search(:aws_opsworks_rds_db_instance, '*:*').and_return([aws_opsworks_rds_db_instance])
end
it 'works' do
expect do
chef_run
end.not_to raise_error
end
end

0 comments on commit 9eb9bb8

Please sign in to comment.