Class: Chef::Application::Local
- Inherits:
-
Chef::Application
- Object
- Chef::Application
- Chef::Application::Local
- Defined in:
- lib/chef/application/local.rb
Instance Attribute Summary collapse
-
#chef_solo_json ⇒ Object
readonly
Returns the value of attribute chef_solo_json.
Instance Method Summary collapse
-
#initialize ⇒ Local
constructor
A new instance of Local.
- #reconfigure ⇒ Object
- #run_application ⇒ Object
- #setup_application ⇒ Object
Constructor Details
#initialize ⇒ Local
Returns a new instance of Local.
114 115 116 |
# File 'lib/chef/application/local.rb', line 114 def initialize super end |
Instance Attribute Details
#chef_solo_json ⇒ Object (readonly)
Returns the value of attribute chef_solo_json.
112 113 114 |
# File 'lib/chef/application/local.rb', line 112 def chef_solo_json @chef_solo_json end |
Instance Method Details
#reconfigure ⇒ Object
118 119 120 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 |
# File 'lib/chef/application/local.rb', line 118 def reconfigure super Chef::Config[:solo] = true if Chef::Config[:noop] require 'tvdinner/noop' 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_client_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., 2) end end @chef_client_json ||= Chef::JSONCompat.from_json("{}") @chef_client_json[:release_dir] ||= (ENV['RELEASE_DIR'] || ENV['PWD']) @chef_client_json[:project_dir] ||= (ENV['PROJECT_DIR'] || @chef_client_json[:release_dir]) end |
#run_application ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/chef/application/local.rb', line 163 def run_application loop do begin run_chef_client Chef::Application.exit! "Exiting", 0 rescue SystemExit => e raise rescue Exception => e Chef::Application.debug_stacktrace(e) Chef::Application.fatal!("#{e.class}: #{e.message}", 1) end end end |
#setup_application ⇒ Object
160 161 |
# File 'lib/chef/application/local.rb', line 160 def setup_application end |