125: def apply(options = {})
126: @applying = true
127:
128:
129:
130: expire()
131:
132: Puppet::Util::Storage.load if host_config?
133: transaction = Puppet::Transaction.new(self)
134:
135: transaction.tags = options[:tags] if options[:tags]
136: transaction.ignoreschedules = true if options[:ignoreschedules]
137:
138: transaction.addtimes :config_retrieval => self.retrieval_duration
139:
140:
141: begin
142: transaction.evaluate
143: rescue Puppet::Error => detail
144: puts detail.backtrace if Puppet[:trace]
145: Puppet.err "Could not apply complete catalog: %s" % detail
146: rescue => detail
147: puts detail.backtrace if Puppet[:trace]
148: Puppet.err "Got an uncaught exception of type %s: %s" % [detail.class, detail]
149: ensure
150:
151:
152: Puppet::Util::Storage.store if host_config?
153: end
154:
155: yield transaction if block_given?
156:
157: transaction.send_report if host_config and (Puppet[:report] or Puppet[:summarize])
158:
159: return transaction
160: ensure
161: @applying = false
162: cleanup()
163: transaction.cleanup if defined? transaction and transaction
164: end