Puppet Class: dstserver::setup

Defined in:
manifests/setup.pp

Summary

Create the dstserver system user and required directories in its home location. Ensure, SteamCMD is available, place install and update scripts and install DST via SteamCMD. Place required systemd service units in the system folder.

Overview

Parameters:

  • ensure (Enum['present', 'absent'])

    Ensure, DST is installed and configured or remove the system service scripts

  • user (String)

    Username for the dstserver system user

  • homedir (String)

    Home directory for the system user and install location for all DST related data

  • app_id (Integer)

    ID of the DST Server App in Steam

  • masters (Array[String])

    List of DST master shards to restart with systemctl during update

  • caves (Array[String])

    List of DST cave shards to restart with systemctl during update

  • bin_dir (String) (defaults to: "${homedir}/bin")

    Directory to store required scripts in

  • install_dir (String) (defaults to: "${homedir}/app")

    Directory to install DST into

  • profile_dir (String) (defaults to: "${homedir}/.klei")

    Required location of the Klei profile directory



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
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
113
114
115
116
117
118
119
120
121
122
# File 'manifests/setup.pp', line 26

class dstserver::setup (
  Enum['present', 'absent'] $ensure,
  String $user,
  String $homedir,
  Integer $app_id,
  Array[String] $masters,
  Array[String] $caves,
  String $bin_dir = "${homedir}/bin",
  String $install_dir = "${homedir}/app",
  String $profile_dir = "${homedir}/.klei"
) {
  # DSTServer requires steamcmd to be installed
  class { 'steamcmd': }

  File{
    owner => $user,
    group => $user,
  }

  # create the system user for dst servers
  # will be removed if dstserver is ensured to be absent
  user{$user:
    ensure     => $ensure,
    comment    => 'System User for Dont Starve Togehter Gameservers',
    home       => $homedir,
    managehome => true,
    password   => '!!',
    shell      => '/bin/bash',
    system     => true,
  }

  if $ensure == 'present' {
    file{$bin_dir:
      ensure  => directory,
      require => User[$user],
    }
    # Install app from steam
    file{"${bin_dir}/install-dst.sh":
      ensure  => present,
      content => epp('dstserver/install.sh', {
        install_dir => $install_dir,
        app_id      => $app_id,
      }),
      mode    => '0500',
      require => File[$bin_dir],
    }
    exec{'install-dst':
      command => "${bin_dir}/install-dst.sh",
      user    => $user,
      creates => "${install_dir}/version.txt",
      require => [
        Class['steamcmd'],
        File["${bin_dir}/install-dst.sh"],
        ],
    }
    # Place app update script

    file{"${bin_dir}/update-dst.sh":
      ensure  => present,
      mode    => '0500',
      content => epp('dstserver/update.sh', {
        master => $masters,
        caves  => $caves,
      }),
      require => File[$bin_dir],
    }

    # create required folders
    file{$profile_dir:
      ensure  => directory,
      require => User['server-dst'],
    }
    file{'dst-serverprofiles':
      ensure  => directory,
      path    => "${profile_dir}/DoNotStarveTogether",
      require => File[$profile_dir],
    }
  }

  # Install or remove service script
  file{'service-dst-master':
    ensure  => $ensure,
    path    => '/etc/systemd/system/dst-master@.service',
    content => epp('dstserver/master.service', {
      install_dir => $install_dir,
      home_dir    => $homedir,
    }),
  }
  file{'service-dst-caves':
    ensure  => $ensure,
    path    => '/etc/systemd/system/dst-caves@.service',
    content => epp('dstserver/cave.service', {
      install_dir => $install_dir,
      home_dir    => $homedir,
    }),
  }
}