lib/chef/application/solo.rb in microwave-0.1004.2 vs lib/chef/application/solo.rb in microwave-0.1004.3
- old
+ new
@@ -62,16 +62,10 @@
:short => "-g GROUP",
:long => "--group GROUP",
:description => "Group to set privilege to",
:proc => nil
- option :json_attribs,
- :short => "-j JSON_ATTRIBS",
- :long => "--json-attributes JSON_ATTRIBS",
- :description => "Load attributes from a JSON file or URL",
- :proc => nil
-
option :node_name,
:short => "-N NODE_NAME",
:long => "--node-name NODE_NAME",
:description => "The node name for this client",
:proc => nil
@@ -80,16 +74,10 @@
:short => "-s SECONDS",
:long => "--splay SECONDS",
:description => "The splay time for running at intervals, in seconds",
:proc => lambda { |s| s.to_i }
- option :recipe_url,
- :short => "-r RECIPE_URL",
- :long => "--recipe-url RECIPE_URL",
- :description => "Pull down a remote gzipped tarball of recipes and untar it to the cookbook cache.",
- :proc => nil
-
option :version,
:short => "-v",
:long => "--version",
:description => "Show chef version",
:boolean => true,
@@ -101,57 +89,17 @@
:long => "--testrun",
:description => "Run chef in testrun mode",
:boolean => true,
:proc => lambda {|n| $testrun = true }
- attr_reader :chef_solo_json
-
def initialize
super
@chef_solo = nil
- @chef_solo_json = nil
end
def reconfigure
super
-
- if Chef::Config[:json_attribs]
- begin
- json_io = open(Chef::Config[:json_attribs])
- rescue SocketError => error
- Chef::Application.fatal!("I cannot connect to #{Chef::Config[:json_attribs]}", 2)
- rescue Errno::ENOENT => error
- Chef::Application.fatal!("I cannot find #{Chef::Config[:json_attribs]}", 2)
- rescue Errno::EACCES => error
- Chef::Application.fatal!("Permissions are incorrect on #{Chef::Config[:json_attribs]}. Please chmod a+r #{Chef::Config[:json_attribs]}", 2)
- rescue Exception => error
- Chef::Application.fatal!("Got an unexpected error reading #{Chef::Config[:json_attribs]}: #{error.message}", 2)
- end
-
- begin
- @chef_solo_json = Chef::JSONCompat.from_json(json_io.read)
- json_io.close unless json_io.closed?
- rescue JSON::ParserError => error
- Chef::Application.fatal!("Could not parse the provided JSON file (#{Chef::Config[:json_attribs]})!: " + error.message, 2)
- end
- end
-
- if Chef::Config[:recipe_url]
- cookbooks_path = Array(Chef::Config[:cookbook_path]).detect{|e| e =~ /\/cookbooks\/*$/ }
- recipes_path = File.expand_path(File.join(cookbooks_path, '..'))
- target_file = File.join(recipes_path, 'recipes.tgz')
-
- Chef::Log.debug "Creating path #{recipes_path} to extract recipes into"
- FileUtils.mkdir_p recipes_path
- path = File.join(recipes_path, 'recipes.tgz')
- File.open(path, 'wb') do |f|
- open(Chef::Config[:recipe_url]) do |r|
- f.write(r.read)
- end
- end
- Chef::Mixin::Command.run_command(:command => "tar zxvfC #{path} #{recipes_path}")
- end
end
def setup_application
end
@@ -162,10 +110,10 @@
splay = rand Chef::Config[:splay]
Chef::Log.debug("Splay sleep #{splay} seconds")
sleep splay
end
- @chef_solo = Chef::Client.new(@chef_solo_json)
+ @chef_solo = Chef::Client.new
@chef_solo.run
@chef_solo = nil
Chef::Application.exit! "Exiting", 0
rescue SystemExit => e
raise