Skip to content

Commit

Permalink
Add :chef_environment to change environment
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Oct 30, 2013
1 parent 874c8bd commit c42a9fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ 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_environment` - environment setting. empty by default.
* `:chef_environment_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
12 changes: 7 additions & 5 deletions lib/capistrano-paratrooper-chef/chef.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
set :chef_nodes_path, "nodes"
set :chef_cookbooks_path, ["cookbooks", "site-cookbooks"]
set :chef_roles_path, "roles"
set :chef_environments_path, "environments"
set :chef_environment, nil
set :chef_environment_path, "environments"
set :chef_databags_path, "data_bags"
set :chef_databag_secret, "data_bag_key"

Expand Down Expand Up @@ -93,8 +94,8 @@ 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))
def environment_path
File.join(fetch(:chef_kitchen_path), fetch(:chef_environment_path))
end

def databags_path
Expand Down Expand Up @@ -193,7 +194,8 @@ 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})
environment #{fetch(:chef_environment).to_s.inspect}
environment_path File.join(root, #{kitchen.environment_path.inspect})
data_bag_path File.join(root, #{kitchen.databags_path.inspect})
verbose_logging #{fetch(:chef_verbose_logging)}
CONF
Expand Down Expand Up @@ -279,7 +281,7 @@ def ensure_working_dir

stream = StringIO.new
TarWriter.new(stream) do |writer|
paths = [cookbooks_paths, roles_path, environments_path, databags_path, databag_secret_path]
paths = [cookbooks_paths, roles_path, environment_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)
Expand Down

0 comments on commit c42a9fb

Please sign in to comment.