class hadoop { exec { "download_hadoop": # Download from nearby mirror, otherwise task can time-out with default setting of '300' # command => "wget -O /tmp/hadoop-2.7.3.tar.gz http://apache.mirror.amaze.com.au/hadoop/common/hadoop-2.7.3/hadoop-2.7.3.tar.gz", command => "wget -O /tmp/hadoop-2.7.3.tar.gz http://www-us.apache.org/dist/hadoop/common/hadoop-2.7.3/hadoop-2.7.3.tar.gz ", timeout => 0, path => $path, # user => $user, # group => $group, unless => "ls ${install_dir} | grep hadoop-2.7.3", require => Package["oracle-java8-installer"] } exec { "unpack_hadoop" : command => "tar -zxf /tmp/hadoop-2.7.3.tar.gz -C ${install_dir}", path => $path, creates => "${hadoop_home}-2.7.3", require => Exec["download_hadoop"] } exec { "rename_hadoop" : command => "ln -s ${install_dir}/hadoop-2.7.3 ${install_dir}/hadoop", path => $path, creates => "${hadoop_home}", require => Exec["unpack_hadoop"] } exec { 'chown_hadoop': command => "/bin/chown -R ${user}:${group} ${hadoop_home}-2.7.3", path => '/bin', user => 'root', require => Exec["rename_hadoop"] } file { "${hadoop_home}/etc/hadoop/slaves": content => template('hadoop/slaves'), mode => 644, owner => $user, group => $group, require => Exec["chown_hadoop"] } file { "${hadoop_home}/etc/hadoop/masters": content => template('hadoop/masters'), mode => 644, owner => $user, group => $group, require => Exec["chown_hadoop"] } file { "${hadoop_home}/etc/hadoop/core-site.xml": content => template('hadoop/core-site.xml'), mode => 644, owner => $user, group => $group, require => Exec["chown_hadoop"] } file { "${hadoop_home}/etc/hadoop/mapred-site.xml": content => template('hadoop/mapred-site.xml'), mode => 644, owner => $user, group => $group, require => Exec["chown_hadoop"] } file { "${hadoop_home}/etc/hadoop/hdfs-site.xml": content => template('hadoop/hdfs-site.xml'), mode => 644, owner => $user, group => $group, require => Exec["chown_hadoop"] } file { "${hadoop_home}/etc/hadoop/yarn-site.xml": content => template('hadoop/yarn-site.xml'), mode => 644, owner => $user, group => $group, require => Exec["chown_hadoop"] } file { "${hadoop_home}/etc/hadoop/hadoop-env.sh": content => template('hadoop/hadoop-env.sh'), mode => 644, owner => $user, group => $group, require => Exec["chown_hadoop"] } file { [ "${hadoop_home}/hadoop_store", "${hadoop_home}/hadoop_store/hdfs", "${hadoop_home}/hadoop_store/hdfs/namenode", "${hadoop_home}/hadoop_store/hdfs/datanode"]: ensure => 'directory', owner => "${user}", group => "${group}", mode => 755, require => Exec["chown_hadoop"] } file { "/home/${user}/.bashrc-setup-hadoop": content => template('hadoop/setup-hadoop.bash'), mode => 644, owner => $user, group => $group, require => [ Exec["unpack_hadoop"], File["/home/${user}"] ] } file_line { "setup_hadoop_home": ensure => present, path => "/home/${user}/.bashrc", line => ". .bashrc-setup-hadoop", require => [ Exec["unpack_hadoop"], File["/home/${user}"] ] } }