From 5faac022394d4b74ae06e9d20ec3c085cb3e2489 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Thu, 12 Mar 2015 10:08:44 -0400 Subject: [PATCH] Ensure filepath exists Before we can write facter facts of hiera hieras, we need for the directory to exist. Change-Id: Id855da44d9e2cb06824ed3507158aeaa466768f7 --- library/puppet | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/puppet b/library/puppet index 22b5f89..8ef2862 100644 --- a/library/puppet +++ b/library/puppet @@ -88,7 +88,8 @@ def _get_facter_dir(): def _write_structured_data(basedir, basename, data): - # Ensure filepath? + if not os.path.exists(basedir): + os.makedirs(basedir) file_path = os.path.join(basedir, "{0}.json".format(basename)) with os.fdopen( os.open(file_path, os.O_CREAT | os.O_WRONLY, 0o600),