From e1bb7393bb5e73afc1813bfe1c27f38c227a9dc3 Mon Sep 17 00:00:00 2001 From: Krzysztof Wilczynski Date: Wed, 23 Mar 2011 02:17:32 +0000 Subject: Create destination directory on-demand i.e. when missing ... Signed-off-by: Krzsysztof Wilczynski --- persistent_crontab_minutes.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'persistent_crontab_minutes.rb') diff --git a/persistent_crontab_minutes.rb b/persistent_crontab_minutes.rb index 44c6328..5a76868 100644 --- a/persistent_crontab_minutes.rb +++ b/persistent_crontab_minutes.rb @@ -27,6 +27,11 @@ module Puppet::Parser::Functions file = "/puppet/state/crontab/#{host}-#{job}.minutes" file = File.join(modules, file) + # Get the directory portion from the file name ... + directory = File.dirname(file) + + FileUtils.mkdir_p(directory) unless File.directory?(directory) + if FileTest.exists?(file) File.open(file, 'r') { |f| value = f.read.to_i } -- cgit v1.2.3