Defined Type: storm::common_directory

Defined in:
manifests/common_directory.pp

Summary

Check if a directory path exists. If not, a new directory is created with specific owner and permissions.

Overview

Examples:

Basic usage

storm::common_directory { 'check-root-dir':
  path => '/storage',
}

Parameters:

  • path (String)

    The directory path. Required.

  • owner (String) (defaults to: 'storm')

    Directory's owner. Optional. Default: 'storm'.

  • group (String) (defaults to: 'storm')

    Directory's group. Optional. Default: 'storm'.

  • permissions (String) (defaults to: '755')

    Directory's permissions. Optional. Default: '755'.

  • recurse (Boolean) (defaults to: false)

    If recursion is enabled. Optional. Default: false.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'manifests/common_directory.pp', line 22

define storm::common_directory (
  String $path,
  String $owner = 'storm',
  String $group = 'storm',
  String $permissions = '755',
  Boolean $recurse = false,
) {

  exec { "mkdir_${title}":
    command => "/bin/mkdir -p ${path}",
    unless  => "/bin/test -d ${path}",
    creates => $path,
  }

  $opt = $recurse ? {
    true => '-R',
    default => '',
  }
  exec { "chown_${title}":
    command => "/bin/chown ${opt} ${owner}:${group} ${path}",
    require => Exec["mkdir_${title}"],
  }
  exec { "chmod_${title}":
    command => "/bin/chmod ${$permissions} ${path}",
    require => Exec["chown_${title}"],
  }
}