135: def run(options = {})
136: begin
137: prepare()
138: rescue Exception => detail
139: puts detail.backtrace if Puppet[:trace]
140: Puppet.err "Failed to prepare catalog: %s" % detail
141: end
142:
143: if catalog = options[:catalog]
144: options.delete(:catalog)
145: elsif ! catalog = retrieve_catalog
146: Puppet.err "Could not retrieve catalog; skipping run"
147: return
148: end
149:
150: begin
151: benchmark(:notice, "Finished catalog run") do
152: catalog.apply(options)
153: end
154: rescue => detail
155: puts detail.backtrace if Puppet[:trace]
156: Puppet.err "Failed to apply catalog: %s" % detail
157: end
158:
159:
160:
161: Puppet::Network::HttpPool.clear_http_instances
162: end