Monday, August 01, 2016

There is no rocket science in Puppet :)


 My 1st puppet module to download Java


class wso2base::download_java {
  $oracle_repo = 'http://download.oracle.com/otn-pub/java/jdk/7u75-b13/'
  $oracle_header = '"Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie"'
  $java_package = 'jdk-7u75-linux-x64.tar.gz'
  $java_dir     = '/opt/java/'

  file { '/opt/java/': ensure => directory, recurse => true }

  exec {
    "${name}_download_java":
      path    => ["/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],
      cwd     => "/opt/java/",
      unless  => "test -f ${java_dir}${java_package}",
      command => "wget --no-cookies --no-check-certificate --header ${oracle_header} ${oracle_repo}/${java_package}";

    "${name}_extract_java":
      path    => ["/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],
      cwd     => "/opt/java/",
      command => "tar xvfz ${java_package}",
      require => Exec["${name}_download_java"];

  }

}

No comments: