Class: Chef::Application::Solo
Instance Attribute Summary collapse
Instance Method Summary
collapse
#configure_chef, #configure_logging, debug_stacktrace, exit!, fatal!, #run
Constructor Details
#initialize ⇒ Solo
115
116
117
118
119
|
# File 'lib/chef/application/solo.rb', line 115
def initialize
super
@chef_solo = nil
@chef_solo_json = nil
end
|
Instance Attribute Details
#chef_solo_json ⇒ Object
Returns the value of attribute chef_solo_json.
113
114
115
|
# File 'lib/chef/application/solo.rb', line 113
def chef_solo_json
@chef_solo_json
end
|
Instance Method Details
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/chef/application/solo.rb', line 121
def reconfigure
super
Chef::Config[:solo] = true
if Chef::Config[:daemonize]
Chef::Config[:interval] ||= 1800
end
if Chef::Config[:json_attribs]
begin
json_io = case Chef::Config[:json_attribs]
when /^(http|https):\/\//
@rest = Chef::REST.new(Chef::Config[:json_attribs], nil, nil)
@rest.get_rest(Chef::Config[:json_attribs], true).open
else
open(Chef::Config[:json_attribs])
end
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
|