Puppet Class: storj::install

Defined in:
manifests/install.pp

Summary

This class install Storj requirements and binaries.

Overview

Examples:

include storj::install

Parameters:

  • version (Pattern[/\d+\.\d+\.\d+/]) (defaults to: $storj::version)

    Storj release. See github.com/storj/storj/releases

  • os (String) (defaults to: $storj::os)

    Operating system.

  • arch (String) (defaults to: $storj::arch)

    Architecture (amd64, arm64 or arm).

  • base_dir (Stdlib::Absolutepath) (defaults to: $storj::base_dir)

    Base directory where Storj is extracted.

  • bin_dir (Stdlib::Absolutepath) (defaults to: $storj::bin_dir)

    Directory where binaries are located.

  • download_extension (String) (defaults to: $storj::download_extension)

    Extension of Storj binaries archive.

  • download_url (Stdlib::HTTPUrl) (defaults to: $storj::real_download_url)

    Complete URL corresponding to the Storj release, default to undef.

  • extract_command (Optional[String]) (defaults to: $storj::extract_command)

    Custom command passed to the archive resource to extract the downloaded archive.

  • config_dir (Stdlib::Absolutepath) (defaults to: $storj::config_dir)

    Directory where configuration are located.

  • manage_user (Boolean) (defaults to: $storj::manage_user)

    Whether to create user for storj or rely on external code for that.

  • manage_group (Boolean) (defaults to: $storj::manage_group)

    Whether to create user for storj or rely on external code for that.

  • user (String) (defaults to: $storj::user)

    User running storj.

  • group (String) (defaults to: $storj::group)

    Group under which storj is running.

  • user_shell (Stdlib::Absolutepath) (defaults to: $storj::user_shell)

    if requested, we create a user for storj. The default shell is false. It can be overwritten to any valid path.

  • extra_groups (Array[String]) (defaults to: $storj::extra_groups)

    Add other groups to the managed user.



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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'manifests/install.pp', line 35

class storj::install (
  Pattern[/\d+\.\d+\.\d+/] $version            = $storj::version,
  String                   $os                 = $storj::os,
  String                   $arch               = $storj::arch,
  Stdlib::Absolutepath     $base_dir           = $storj::base_dir,
  Stdlib::Absolutepath     $bin_dir            = $storj::bin_dir,
  String                   $download_extension = $storj::download_extension,
  Stdlib::HTTPUrl          $download_url       = $storj::real_download_url,
  Optional[String]         $extract_command    = $storj::extract_command,
  Stdlib::Absolutepath     $config_dir         = $storj::config_dir,

  # User Management
  Boolean                  $manage_user        = $storj::manage_user,
  Boolean                  $manage_group       = $storj::manage_group,
  String                   $user               = $storj::user,
  String                   $group              = $storj::group,
  Stdlib::Absolutepath     $user_shell         = $storj::user_shell,
  Array[String]            $extra_groups       = $storj::extra_groups,
) {
  ensure_packages('unzip', { ensure => 'present' })

  archive { "/tmp/identity_${version}.${download_extension}":
    ensure          => 'present',
    extract         => true,
    extract_path    => "${base_dir}/storj-${version}.${os}-${arch}",
    source          => $download_url,
    checksum_verify => false,
    creates         => "${base_dir}/storj-${version}.${os}-${arch}/identity",
    cleanup         => true,
    extract_command => $extract_command,
  }
  file {
    "${base_dir}/storj-${version}.${os}-${arch}":
      ensure => 'directory',
      owner  => 'root',
      group  => 0, # 0 instead of root because OS X uses "wheel".
      mode   => '0755';
    "${base_dir}/storj-${version}.${os}-${arch}/identity":
      owner => 'root',
      group => 0, # 0 instead of root because OS X uses "wheel".
      mode  => '0555';
    "${bin_dir}/identity":
      ensure => link,
      target => "${base_dir}/storj-${version}.${os}-${arch}/identity";
  }

  File["${base_dir}/storj-${version}.${os}-${arch}"]
  -> Archive["/tmp/identity_${version}.${download_extension}"]
  -> File["${base_dir}/storj-${version}.${os}-${arch}/identity"]
  -> File["${bin_dir}/identity"]

  if $manage_user {
    ensure_resource('user', [ $user ], {
      ensure => 'present',
      system => true,
      groups => concat([$group, 'docker'], $extra_groups),
      shell  => $user_shell,
    })

    User[$user] -> File[$config_dir]

    if $manage_group {
      Group[$group] -> User[$user]
    }
  }
  if $manage_group {
    ensure_resource('group', [ $group ], {
      ensure => 'present',
      system => true,
    })
  }

  file { $config_dir:
    ensure => 'directory',
    owner  => $user,
    group  => $group,
  }
}