also manage directory as puppet user needs write perms as well
authormh <mh@immerda.ch>
Fri, 29 Jan 2016 18:14:12 +0000 (19:14 +0100)
committermh <mh@immerda.ch>
Fri, 29 Jan 2016 18:14:12 +0000 (19:14 +0100)
manifests/yaml.pp
spec/classes/yaml_spec.rb

index 8ac0071..aca164b 100644 (file)
@@ -6,7 +6,8 @@
 #                      Default: /var/lib/trocla/trocla_data.yaml
 #                      This should be managed using the package.
 class trocla::yaml(
-  $data_file = '/var/lib/trocla/trocla_data.yaml',
+  $manage_data_dir = true,
+  $data_file       = '/var/lib/trocla/trocla_data.yaml',
 ) {
 
   class{'trocla::config':
@@ -19,10 +20,20 @@ class trocla::yaml(
     },
   }
 
-  file{$data_file:
-    ensure  => file,
-    owner   => puppet,
-    group   => 0,
-    mode    => '0600';
+  if $manage_data_dir {
+    $data_dir = dirname($data_file)
+    file{$data_dir:
+      ensure  => directory,
+      owner   => puppet,
+      group   => 0,
+      mode    => '0600';
+    }
+  }
+  file{
+    $data_file:
+      ensure  => file,
+      owner   => puppet,
+      group   => 0,
+      mode    => '0600';
   }
 }
index c5912f2..53ee507 100644 (file)
@@ -27,6 +27,12 @@ store_options:
   adapter_options:
     :file: /var/lib/trocla/trocla_data.yaml
 ") }
+    it { should contain_file('/var/lib/trocla').with(
+      :ensure => 'directory',
+      :owner  => 'puppet',
+      :group  => 0,
+      :mode   => '0600'
+    )}
     it { should contain_file('/var/lib/trocla/trocla_data.yaml').with(
       :ensure => 'file',
       :owner  => 'puppet',