Q:

recursively make directory tree in puppet without purging

I want to create the directory structure /var/www/apps/example/current/public if it doesn't exist using puppet. If it already exists I don't want to purge the contents of the directories. How do I do this? Below is what I have so far:
file { "/var/www/apps/example/current/public":
  owner => 'deploy',
  group => 'users',
  ensure => "directory",
  purge => false,
  recurse => true
}

This gives me
 Cannot create /var/www/apps/example/current/public; parent directory /var/www/apps/example/current does not exist

A:

The recurse parameter does not allow you to create parent directories. It is used to enforce property values such as owner, mode etc. on directory contents and subdirectories recursively.
file { '/var/www':
    owner   => 'www-data',
    recurse => true,
}

As a matter of fact, Puppet currently cannot automatically create all parent directories. You should add all relevant directories as resources instead.
file { [ '/var/www/apps',
         '/var/www/apps/example',
         '/var/www/apps/example/current',
         '/var/www/apps/example/current/public', ]:
           ensure => directory,
           ...
}

Existing content will remain unmolested. There is no need to pass the purge parameter.

A:

  exec { "Create ${mydir}":
    creates => $mydir,
    command => "mkdir -p ${mydir}",
    path => $::path
  } -> file { $mydir : }

The last line is so that other resources (e.g., files to create inside $mydir) can depend on File[$mydir] as though it was possible to create it with a plain old file {} block, which it really should.

