243: def need_to_run?
244: force = resource[:force]
245: return_value = true
246: begin
247: open_augeas
248: filter = resource[:onlyif]
249: unless filter == ""
250: cmd_array = parse_commands(filter)[0]
251: command = cmd_array[0];
252: begin
253: case command
254: when "get"; return_value = process_get(cmd_array)
255: when "match"; return_value = process_match(cmd_array)
256: end
257: rescue Exception => e
258: fail("Error sending command '#{command}' with params #{cmd_array[1..-1].inspect}/#{e.message}")
259: end
260: end
261:
262: unless force
263:
264:
265:
266: if return_value and get_augeas_version >= "0.3.6"
267: debug("Will attempt to save and only run if files changed")
268: set_augeas_save_mode(SAVE_NOOP)
269: do_execute_changes
270: save_result = @aug.save
271: saved_files = @aug.match("/augeas/events/saved")
272: if save_result and not files_changed?
273: debug("Skipping becuase no files were changed")
274: return_value = false
275: else
276: debug("Files changed, should execute")
277: end
278: end
279: end
280: ensure
281: close_augeas
282: end
283: return return_value
284: end