Skip to content

Commit

Permalink
Support environments feature
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Jul 25, 2013
1 parent 51278a8 commit 51c6767
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ by default, paratrooper-chef uses following files and directories.
* config/cookbooks
* config/site-cookbooks
* config/roles
* config/environments
* config/data_bags
* config/data_bag_key

Expand Down Expand Up @@ -122,6 +123,7 @@ Following options are available.
* `:chef_cookbooks_path` - cookbooks directories list. use `["cookbooks", "site-cookbooks"]` by default.
* `:chef_nodes_path` - nodes directory. use `nodes` by default.
* `:chef_roles_path` - roles directory. use `roles` by default.
* `:chef_environments_path` - environments directory. use `environments` by default.
* `:chef_databags_path` - data bags directory. use `data_bags` by default.
* `:chef_databag_secret` - path of secret-key for data bags. use `data_bag_key` by default.

Expand Down
11 changes: 9 additions & 2 deletions lib/capistrano-paratrooper-chef/chef.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
# directory structure of chef-kitchen
set :chef_kitchen_path, "config"
set :chef_default_solo_json_path, "solo.json"
set :chef_cookbooks_path, ["cookbooks", "site-cookbooks"]
set :chef_nodes_path, "nodes"
set :chef_cookbooks_path, ["cookbooks", "site-cookbooks"]
set :chef_roles_path, "roles"
set :chef_environments_path, "environments"
set :chef_databags_path, "data_bags"
set :chef_databag_secret, "data_bag_key"

Expand Down Expand Up @@ -92,6 +93,10 @@ def role_exists?(name)
File.exist?(File.join(roles_path, name.to_s + ".rb"))
end

def environments_path
File.join(fetch(:chef_kitchen_path), fetch(:chef_environments_path))
end

def databags_path
File.join(fetch(:chef_kitchen_path), fetch(:chef_databags_path))
end
Expand Down Expand Up @@ -188,6 +193,7 @@ def generate_solo_rb
file_cache_path #{fetch(:chef_cache_dir).inspect}
cookbook_path #{kitchen.cookbooks_paths.inspect}.collect{|dir| File.join(root, dir)}
role_path File.join(root, #{kitchen.roles_path.inspect})
environments_path File.join(root, #{kitchen.environments_path.inspect})
data_bag_path File.join(root, #{kitchen.databags_path.inspect})
verbose_logging #{fetch(:chef_verbose_logging)}
CONF
Expand Down Expand Up @@ -258,7 +264,8 @@ def ensure_working_dir

stream = StringIO.new
TarWriter.new(stream) do |writer|
kitchen_paths = [cookbooks_paths, roles_path, databags_path, databag_secret_path].flatten.compact.select{|d| File.exists?(d)}
paths = [cookbooks_paths, roles_path, environments_path, databags_path, databag_secret_path]
kitchen_paths = paths.flatten.compact.select{|d| File.exists?(d)}
Find.find(*kitchen_paths) do |path|
writer.add(path)
end
Expand Down

0 comments on commit 51c6767

Please sign in to comment.