title: Ensure directory tree exists from variable
body: <p>In puppet I am trying to install a package on a windows machine. The package can take the <code>INSTALLDIR</code> parameter, which determines where it installs. I want to ensure that the directory that the package is installing to exists. However, unless I am mistaken, puppet is not the nicest for managing whole directory trees. The suggested methods online seem to be either managing each folder in the tree separately like so:</p>
  
  <pre><code>file{
      ['parent','parent/firstchild', 'parent/firstchild/lastchild]:
      ensure =&gt; directory, 
  }
  </code></pre>
  
  <p>or having the directory structure already present in the modules file folder, or running an exec that creates the directory tree (which I would like to avoid as it is not exactly ensuring a state, which is the goal of puppet).</p>
  
  <p><strong>How would I check if a directory is present and if not create it in puppet <em>from</em> a variable?</strong></p>
  
  <p>Relevant code:</p>
  
  <pre><code>$installDir = "C:/folder1/folder2/folder3"
  
  package{ "MagicalPackage":
          ensure  =&gt; $installValue,
          source  =&gt; 'magic.msi',
          install_options =&gt; ["INSTALLDIR=${installDir}"],
  
  }
  </code></pre>