123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- #
- # Cookbook Name:: application
- # Recipe:: java
- #
- # Copyright 2010, Opscode, Inc.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- #
- app = node.run_state[:current_app]
- ###
- # You really most likely don't want to run this recipe from here - let the
- # default application recipe work it's mojo for you.
- ###
- node.default[:apps][app['id']][node.app_environment][:run_migrations] = false
- ## First, install any application specific packages
- if app['packages']
- app['packages'].each do |pkg,ver|
- package pkg do
- action :install
- version ver if ver && ver.length > 0
- end
- end
- end
- directory app['deploy_to'] do
- owner app['owner']
- group app['group']
- mode '0755'
- recursive true
- end
- directory "#{app['deploy_to']}/releases" do
- owner app['owner']
- group app['group']
- mode '0755'
- recursive true
- end
- directory "#{app['deploy_to']}/shared" do
- owner app['owner']
- group app['group']
- mode '0755'
- recursive true
- end
- %w{ log pids system }.each do |dir|
- directory "#{app['deploy_to']}/shared/#{dir}" do
- owner app['owner']
- group app['group']
- mode '0755'
- recursive true
- end
- end
- if app["database_master_role"]
- dbm = nil
- # If we are the database master
- if node.run_list.roles.include?(app["database_master_role"][0])
- dbm = node
- else
- # Find the database master
- results = search(:node, "run_list:role\\[#{app["database_master_role"][0]}\\] AND app_environment:#{node[:app_environment]}", nil, 0, 1)
- rows = results[0]
- if rows.length == 1
- dbm = rows[0]
- end
- end
-
- # Assuming we have one...
- if dbm
- template "#{app['deploy_to']}/shared/#{app['id']}.xml" do
- source "context.xml.erb"
- owner app["owner"]
- group app["group"]
- mode "644"
- variables(
- :host => dbm['fqdn'],
- :app => app['id'],
- :database => app['databases'][node.app_environment],
- :war => "#{app['deploy_to']}/releases/#{app['war'][node.app_environment]['checksum']}.war"
- )
- end
- end
- end
- ## Then, deploy
- remote_file app['id'] do
- path "#{app['deploy_to']}/releases/#{app['war'][node.app_environment]['checksum']}.war"
- source app['war'][node.app_environment]['source']
- mode "0644"
- checksum app['war'][node.app_environment]['checksum']
- end
|