Puppet Class: nomad::install

Defined in:
manifests/install.pp

Overview

This class is called from nomad::init to install the config file.



4
5
6
7
8
9
10
11
12
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
# File 'manifests/install.pp', line 4

class nomad::install {
  if $nomad::data_dir {
    file { $nomad::data_dir:
      ensure => 'directory',
      owner  => $nomad::user,
      group  => $nomad::group,
      mode   => $nomad::data_dir_mode,
    }
  }

  if $nomad::plugin_dir {
    file { $nomad::plugin_dir:
      ensure => 'directory',
      owner  => $nomad::user,
      group  => $nomad::group,
      mode   => $nomad::plugin_dir_mode,
    }
  }

  case $nomad::install_method {
    'url': {
      $install_path = '/opt/puppet-archive'

      include 'archive'
      file { [$install_path, "${install_path}/nomad-${nomad::version}"]:
        ensure => directory,
      }
      -> archive { "${install_path}/nomad-${nomad::version}.${nomad::download_extension}":
        ensure       => present,
        source       => $nomad::real_download_url,
        extract      => true,
        extract_path => "${install_path}/nomad-${nomad::version}",
        creates      => "${install_path}/nomad-${nomad::version}/nomad",
      }
      -> file {
        "${install_path}/nomad-${nomad::version}/nomad":
          owner => 'root',
          group => 0, # 0 instead of root because OS X uses "wheel".
          mode  => '0555';
        "${nomad::bin_dir}/nomad":
          ensure => link,
          notify => $nomad::notify_service,
          target => "${install_path}/nomad-${nomad::version}/nomad";
      }
    }
    'package': {
      if $nomad::manage_repo {
        include hashi_stack::repo
        Class['hashi_stack::repo'] -> Package[$nomad::package_name]
      }
      package { $nomad::package_name:
        ensure => $nomad::version,
      }

      if $nomad::data_dir {
        Package[$nomad::package_name] -> File[$nomad::data_dir]
      }
      if $nomad::plugin_dir {
        Package[$nomad::package_name] -> File[$nomad::plugin_dir]
      }
    }
    'none': {}
    default: {
      fail("The provided install method ${nomad::install_method} is invalid")
    }
  }
}