-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy_mgr.rb
41 lines (35 loc) · 1008 Bytes
/
deploy_mgr.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require 'rubygems'
require 'bundler/setup'
require 'sinatra'
require 'chef'
require 'yaml'
set :haml, :format => :html5
configure do |c|
chef_cfg = YAML::load_file("chef.yaml")
c.set(:data_bag, chef_cfg['data_bag'])
c.set(:chef, Chef::REST.new(chef_cfg['url'],
chef_cfg['client_name'],
chef_cfg['key_file']))
end
get '/' do
redirect to('/environments/')
end
get '/environments/' do
@items = settings.chef.get_rest("/data/#{settings.data_bag}")
haml :item_list
end
get '/environments/:env_name/' do |env_name|
@env_name = env_name
item = settings.chef.get_rest("/data/#{settings.data_bag}/#{env_name}")
item.delete('id')
@targets = item
#haml :environment
item2 = settings.chef.get_rest("/data/#{settings.data_bag}/qa")
item2.delete('id')
@staging = item2
haml :environment
end
post '/environments/:id/update' do
settings.chef.put_rest("/data/#{settings.data_bag}/#{params[:id]}", params)
redirect back
end