Defined Type: hadoop::mkdir
- Defined in:
- manifests/mkdir.pp
Overview
Define hadoop::mkdir
Creates a directory on HDFS. Skip everything, if a $touchfile exists.
Parameters
- *(title)*
-
The name of the directory is in the title of the resource instance.
- touchfile
-
(required)
- owner
-
undef
- group
-
undef
- mode
-
undef
Requirement
-
working HDFS
-
configured local HDFS client
21 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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'manifests/mkdir.pp', line 21
define hadoop::mkdir($touchfile, $owner = undef, $group = undef, $mode = undef, $recursive = false) {
$dir = $title
$env = [ "KRB5CCNAME=FILE:/tmp/krb5cc_nn_puppet_${touchfile}" ]
$path = '/sbin:/usr/sbin:/bin:/usr/bin'
$puppetfile = "/var/lib/hadoop-hdfs/.puppet-${touchfile}"
include ::hadoop::common::config
if $hadoop::hdfs_enable {
include ::hadoop::common::hdfs::config
}
if ($recursive) {
$chown_args=' -R'
} else {
$chown_args=''
}
if $hadoop::zookeeper_deployed {
# directory
exec { "hadoop-dir:${dir}":
command => "hdfs dfs -mkdir -p ${dir}",
path => $path,
environment => $env,
unless => "hdfs dfs -test -d ${dir}",
user => 'hdfs',
creates => $puppetfile,
}
File["${hadoop::confdir}/core-site.xml"] -> Exec["hadoop-dir:${dir}"]
if $hadoop::hdfs_enable {
File["${hadoop::confdir}/hdfs-site.xml"] -> Exec["hadoop-dir:${dir}"]
}
# ownership
if $owner and $owner != '' or $group and $group != '' {
exec { "hadoop-chown:${dir}":
command => "hdfs dfs -chown${chown_args} ${owner}:${group} ${dir}",
path => $path,
environment => $env,
user => 'hdfs',
creates => $puppetfile,
}
Exec["hadoop-dir:${dir}"] -> Exec["hadoop-chown:${dir}"]
}
# mode
if $mode and $mode != '' {
exec { "hadoop-chmod:${dir}":
command => "hdfs dfs -chmod ${mode} ${dir}",
path => $path,
environment => $env,
user => 'hdfs',
creates => $puppetfile,
}
Exec["hadoop-dir:${dir}"] -> Exec["hadoop-chmod:${dir}"]
}
}
}
|