Puppet Class: opengrok::download

Defined in:
manifests/download.pp

Overview

Class opengrok::download

This class is called from opengrok for service download.

Parameters:



13
14
15
16
17
18
19
20
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
78
79
80
81
82
83
84
85
# File 'manifests/download.pp', line 13

class opengrok::download(
  $download_url,
  $opengrok_dir,
){

  $opengrok_fname = get_opengrok_fname($download_url)

  if 'zip' in $opengrok_fname {
    $has_zip = true
  }  else {
    $has_zip = false
  }

  if $has_zip {
    $tarball_name = $opengrok_fname[0,-5]
  }
  else {
    $tarball_name = $opengrok_fname
  }

  $version_name = $tarball_name[0,-8]


  $install_dir = "/opt/${version_name}"

  file { $install_dir:
    ensure =>  directory,
  }

  file { $opengrok_dir:
    ensure  => link,
    target  => $install_dir,
    require => File[$install_dir],
  }

  if $has_zip {
    archive { "/tmp/${opengrok_fname}":
      ensure       => present,
      extract      => true,
      extract_path => '/tmp',
      source       => $download_url,
      creates      => "/tmp/${tarball_name}",
      cleanup      => true,
      require      => [
        File[$install_dir],
      ],
    } ->
    archive { "/tmp/${tarball_name}":
      ensure          => present,
      extract         => true,
      extract_command => 'tar xfz %s --strip-components=1',
      extract_path    => $install_dir,
      creates         => "${install_dir}/bin",
      cleanup         => true,
      require         => [
        File[$install_dir],
      ],
    }
  } else {
    archive { "/tmp/${opengrok_fname}":
      ensure          => present,
      extract         => true,
      extract_command => 'tar xfz %s --strip-components=1',
      extract_path    => $install_dir,
      source          => $download_url,
      creates         => "${install_dir}/bin",
      cleanup         => true,
      require         => [
        File[$install_dir],
      ],
    }
  }
}