Skip to content

Commit

Permalink
Update testapp recipe to be configurable so it can be deployed on AWS
Browse files Browse the repository at this point in the history
  • Loading branch information
christine_draper committed Feb 1, 2015
1 parent f0834bc commit 281aa07
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/chef/knife/topo/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Knife
module Topo
VERSION = "0.0.10"
VERSION = "0.0.11"
end
end
3 changes: 3 additions & 0 deletions test-repo/cookbooks/testapp/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
default['testapp']['user'] = 'vagrant'
default['testapp']['path'] = "/home/vagrant"
default['testapp']['appname'] = 'testapp'
2 changes: 1 addition & 1 deletion test-repo/cookbooks/testapp/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
license 'Apache v2.0'
description 'Installs/Configures test application'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.11'
version '0.1.12'
depends 'mongodb', '~> 0.16'
depends 'nodejs', '~> 1.3'
35 changes: 20 additions & 15 deletions test-repo/cookbooks/testapp/recipes/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,49 @@
#
#

directory "/home/vagrant/ypo" do
owner "vagrant"
group "vagrant"
user = node['testapp']['user']
appname = node['testapp']['appname']
basepath = node['testapp']['path']
fullpath = ::File.join(basepath, appname)

directory fullpath do
owner user
group user
mode 00750
action :create
end

cookbook_file "/home/vagrant/ypo/server.js" do
cookbook_file ::File.join(fullpath, "server.js") do
source 'server.js'
end

cookbook_file "/home/vagrant/ypo/package.json" do
cookbook_file ::File.join(fullpath, "package.json") do
source 'package.json'
end

cookbook_file "/home/vagrant/ypo/index.html" do
cookbook_file ::File.join(fullpath, "index.html") do
source 'index.html'
end

execute 'install_ypo' do
cwd "/home/vagrant/ypo"
user "vagrant"
execute 'install_testapp' do
cwd fullpath
user user
command "npm install"
end

template "ypo.upstart.conf" do
path "/etc/init/ypo.conf"
template "testapp.upstart.conf" do
path ::File.join("/etc/init", appname + ".conf")
source 'nodejs.upstart.conf.erb'
mode '0644'
variables(
:user => 'vagrant',
:user => user,
:node_dir => '/usr/local',
:app_dir => '/home/vagrant',
:entry => 'ypo'
:app_dir => basepath,
:entry => appname
)
end

service 'ypo' do
service appname do
provider Chef::Provider::Service::Upstart
supports :restart => true, :start => true, :stop => true
action [:restart]
Expand Down

0 comments on commit 281aa07

Please sign in to comment.