diff --git a/recipes/configure.rb b/recipes/configure.rb index 13191ee..7cdaf32 100644 --- a/recipes/configure.rb +++ b/recipes/configure.rb @@ -1,6 +1,2 @@ -if node[:opsworks][:instance][:layers].include?('rails-app') - - include_recipe "opsworks_custom_env::restart_command" - include_recipe "opsworks_custom_env::write_config" - -end +include_recipe "opsworks_custom_env::restart_command" +include_recipe "opsworks_custom_env::write_config" diff --git a/recipes/restart_command.rb b/recipes/restart_command.rb index d26277d..0064a52 100644 --- a/recipes/restart_command.rb +++ b/recipes/restart_command.rb @@ -1,5 +1,4 @@ node[:deploy].each do |application, deploy| - execute "restart Rails app #{application} for custom env" do cwd deploy[:current_path] if node[:opsworks][:rails_stack][:name].eql? "apache_passenger" @@ -10,6 +9,7 @@ user deploy[:user] action :nothing - end + only_if { node[:opsworks][:instance][:layers].include?('rails-app') } + end end diff --git a/recipes/write_config.rb b/recipes/write_config.rb index 501aa5f..32a1aec 100644 --- a/recipes/write_config.rb +++ b/recipes/write_config.rb @@ -2,11 +2,14 @@ # See https://forums.aws.amazon.com/thread.jspa?threadID=118107 node[:deploy].each do |application, deploy| - + # rails apps only + next unless deploy[:application_type].eql?('rails') + # and only if custom_env JSON is present + next unless node[:custom_env].present? && node[:custom_env][application].present? + custom_env_template do application application deploy deploy - env node[:custom_env][application] + env node[:custom_env][application] || {} end - end