Defined Type: dstserver::instance

Defined in:
manifests/instance.pp

Summary

Configure one cluster instance of DST and manage the sytemd service to ensure it is up and running

Overview

Parameters:

  • autosave (Boolean) (defaults to: true)

    Enable or disable automatic saving after each night

  • caves (Boolean) (defaults to: false)

    Configure and run a cave shard in addition to the overworld shard

  • clusterkey (String) (defaults to: 'dst')

    Key to authenticate the cluser nodes to each other

  • console (Boolean) (defaults to: true)

    Enable or disable the remote server console

  • description (String) (defaults to: '')

    Server Description in the public server list

  • ensure (String) (defaults to: present)

    Ensure the server is configured and ready or remove it from the node

  • intention (Enum['social', 'cooperative', 'competetive', 'madness']) (defaults to: 'social')

    Your play style intention for this instance

  • mode (Enum['survival', 'wilderness', 'endless']) (defaults to: 'survival')

    Server map mode

  • mods (Optional[Hash]) (defaults to: undef)

    Configuration Hash for mods on this instance, see section Mod Config in Readme.md

  • password (String) (defaults to: '')

    Join password for the server

  • path (String)

    Absolute path this instance profile will be configured at

  • pause (Boolean) (defaults to: true)

    Autmatically pause the game when no players are connected to the server

  • players (Integer) (defaults to: 5)

    Maximum player slots for this instance

  • pvp (Boolean) (defaults to: false)

    Enable PvP on this instance

  • servername (String) (defaults to: $name)

    Servername in the public server list, defaults to the key in the instances config hash

  • startport (Integer) (defaults to: 11031)

    Startport to use for required ports. Will obtain 7 ports in total beginning with this.

  • token (String)

    Klei dedicated server token for this instance, obtained in your account management on Klei's website

  • vote_kick (Boolean) (defaults to: true)

    Allow players to vote for kicks

  • worldgenoverrides (Optional[Hash]) (defaults to: undef)

    Configuration Hash for worldgenoverride on this instance, see section Worldgenoverride Config in Readme.md



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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'manifests/instance.pp', line 44

define dstserver::instance(
  String $path,
  String $token,

  Boolean $autosave = true,
  Boolean $caves = false,
  String $clusterkey = 'dst',
  Boolean $console = true,
  String $description = '',
  String $ensure = present,
  Enum['social', 'cooperative', 'competetive', 'madness'] $intention = 'social',
  Enum['survival', 'wilderness', 'endless'] $mode = 'survival',
  Optional[Hash] $mods = undef,
  String $password = '',
  Boolean $pause = true,
  Integer $players = 5,
  Boolean $pvp = false,
  String $servername = $name,
  Integer $startport = 11031,
  Boolean $vote_kick = true,
  Optional[Hash] $worldgenoverrides = undef,
) {
  # Path variables for later use
  $path_master = "${path}/master"
  $path_caves = "${path}/caves"

  # Server Profile Folder
  # Force removal if instance is absent
  $ensure_profiledir = $ensure ? { present => directory, default => absent }
  file{$path:
    ensure => $ensure_profiledir,
    force  => true,
  }

  # Server Cluster
  dstserver::entity::cluster{$name:
    ensure      => $ensure,
    path        => $path,
    servername  => $servername,
    token       => $token,
    mode        => $mode,
    players     => $players,
    pvp         => $pvp,
    pause       => $pause,
    name        => $name,
    description => $description,
    password    => $password,
    intention   => $intention,
    autosave    => $autosave,
    vote_kick   => $vote_kick,
    console     => $console,
    masterport  => $startport,
    clusterkey  => $clusterkey,
    require     => File[$path],
  }

  # Shard Master -> Overworld
  $override_master = $worldgenoverrides ? { undef => undef, default => $worldgenoverrides['master']}
  dstserver::entity::master{$name:
    ensure           => $ensure,
    path             => $path_master,
    ports            => [
      $startport + 1,
      $startport + 2,
      $startport + 3,
    ],
    worldgenoverride => $override_master,
    mods             => $mods,
    require          => File[$path],
  }

  # Shard Caves -> Underworld and ruins
  $override_caves = $worldgenoverrides ? { undef => undef, default => $worldgenoverrides['caves']}
  if ($ensure == 'absent') {
    # Whole instance is set absent
    $ensure_caves = $ensure
  } elsif ($caves) {
    # Caves are enabled
    $ensure_caves = present
  } else {
    # Caves are disabled
    $ensure_caves = absent
  }
  dstserver::entity::caves{$name:
    ensure           => $ensure_caves,
    path             => $path_caves,
    ports            => [
      $startport + 4,
      $startport + 5,
      $startport + 6,
    ],
    worldgenoverride => $override_caves,
    mods             => $mods,
    require          => File[$path],
  }
}