Page MenuHomePhabricator
Authored By
stwalkerster
Nov 17 2016, 12:12 AM
Size
6 KB
Referenced Files
None
Subscribers
None
class minecraftHost {
minecraft{ "mc1.5" : port => 25566, ensure => "absent" }
minecraft{ "ohai" : port => 25566, ensure => "absent" }
minecraft{ "creative" : port => 25567, ensure => "absent" }
minecraft{ "cowgate" :
port => 25568,
ensure => "present",
levelName => "cowgate",
resourcePackUrl => "https\://dl.dropboxusercontent.com/u/12606274/Underbelly/UnderbellyResources.zip",
messageOfTheDay => "The venues in \u00A7l\u00A75Underbelly Cowgate\u00A7r, block by block, with a hint of \u00A7ksomething",
difficulty => 2,
}
minecraft{ "crew" :
port => 25569,
ensure => "present",
messageOfTheDay => "HW Events Crew",
difficulty => 2,
}
minecraft{ "os-gb" : port => 25570, ensure => "absent" }
minecraft{ "combatupdate" :
port => 25571,
ensure => "present",
messageOfTheDay => "1.9 Combat Update World",
resourcePackUrl => "https\://dl.dropboxusercontent.com/u/12606274/combatupdate2.zip",
difficulty => 2,
viewDistance => 12,
}
minecraft{ "creativetest" : port => 25572, ensure => "purged" }
}
class minecraftHost::mapper ( $ensure = 'present', $latestVersion = '1.11' ) {
if $ensure == 'present' {
exec {
'mcoverviewer-apt-repo-add':
unless => '/bin/grep "deb http://overviewer.org/debian ./" /etc/apt/sources.list.d/*',
command => "/bin/echo 'deb http://overviewer.org/debian ./' > /etc/apt/sources.list.d/mcoverviewer.list";
'mcoverviewer-aptgetupdate':
subscribe => Exec['mcoverviewer-apt-repo-add'],
refreshonly => true,
command => "/usr/bin/apt-get update";
}
file { "/var/lib/jenkins/.minecraft/versions/${latestVersion}" :
ensure => directory,
owner => 'jenkins',
group => 'jenkins',
mode => 755,
}
$clientjarurl = "https://s3.amazonaws.com/Minecraft.Download/versions/${latestVersion}/${latestVersion}.jar"
exec { "minecraft-mapper-downloadclient" :
command => "/usr/bin/wget -q ${clientjarurl} -O ${latestVersion}.jar",
creates => "/var/lib/jenkins/.minecraft/versions/${latestVersion}/${latestVersion}.jar",
cwd => "/var/lib/jenkins/.minecraft/versions/${latestVersion}",
require => File[ "/var/lib/jenkins/.minecraft/versions/${latestVersion}" ],
}
certificate { "mc.stwalkerster.co.uk" :
webRoot => "/mnt/jenkins/mc-overviewer/maps",
hostnames => [ "cowgate.mc.stwalkerster.co.uk" ]
}
vhost { "mc.stwalkerster.co.uk" :
ensure => $ensure,
serveraliases => [ "cowgate.mc.stwalkerster.co.uk" ],
ssl => "only",
letsencrypt => "mc.stwalkerster.co.uk",
priority => 20,
monitoring => "present",
docroot => "/mnt/jenkins/mc-overviewer/maps",
useModPhp => no,
}
}
package { minecraft-overviewer :
ensure => $ensure ? {
'present' => latest,
default => absent,
};
}
}
define minecraft (
$unixname = $title,
$mem = "1024",
$ensure = "present",
$port = 25565,
$version = "1.11",
$levelName = "world",
$resourcePackUrl = "",
$maxPlayers = 6,
$viewDistance = 8,
$messageOfTheDay = "${title} @ stwalkerster.co.uk",
$defaultGamemode = 0,
$forceDefaultGamemode = "false",
$difficulty = 0,
$useWhitelist = "true",
) {
file { "/mnt/minecraft/${unixname}" :
ensure => $ensure ? {
'purged' => 'absent',
default => 'directory'
},
owner => minecraft,
group => ldapUsers,
force => $ensure ? {
'purged' => yes,
default => no
},
backup => false,
}
if $ensure != 'purged' {
file { "/mnt/minecraft/${unixname}/minecraft_server.jar" :
ensure => link,
owner => minecraft,
group => ldapUsers,
target => "/mnt/minecraft/${unixname}/minecraft_server.${version}.jar",
require => File[ "/mnt/minecraft/${unixname}" ],
notify => Service[ "minecraft-${unixname}" ],
}
file { "/mnt/minecraft/${unixname}/eula.txt" :
ensure => present,
owner => 'minecraft',
group => 'minecraft',
content => "eula=true",
require => File[ "/mnt/minecraft/${unixname}" ],
notify => Service[ "minecraft-${unixname}" ],
}
file { "/mnt/minecraft/${unixname}/server.properties" :
ensure => present,
owner => 'minecraft',
group => 'minecraft',
mode => 644,
}
augeas { "minecraft-${unixname}-augeas" :
lens => "Properties.lns",
incl => "/mnt/minecraft/${unixname}/server.properties",
changes => [
"set \"level-name\" \"${levelName}\"",
"set \"server-port\" \"${port}\"",
"set \"force-gamemode\" \"${forceDefaultGamemode}\"",
"set \"white-list\" \"${useWhitelist}\"",
"set \"resource-pack\" \"${resourcePackUrl}\"",
"set \"difficulty\" \"${difficulty}\"",
"set \"enable-command-block\" \"true\"",
"set \"gamemode\" \"${defaultGamemode}\"",
"set \"max-players\" \"${maxPlayers}\"",
"set \"view-distance\" \"${viewDistance}\"",
"set \"motd\" \"${messageOfTheDay}\"",
"set \"spawn-protection\" \"0\""
],
notify => Service[ "minecraft-${unixname}" ],
}
$serverjarurl = "https://s3.amazonaws.com/Minecraft.Download/versions/${version}/minecraft_server.${version}.jar"
exec { "minecraft-${unixname}-downloadserver" :
command => "/usr/bin/wget -q ${serverjarurl} -O minecraft_server.${version}.jar",
creates => "/mnt/minecraft/${unixname}/minecraft_server.${version}.jar",
cwd => "/mnt/minecraft/${unixname}/",
require => File[ "/mnt/minecraft/${unixname}" ],
notify => Service[ "minecraft-${unixname}" ],
}
service { "minecraft-${unixname}" :
enable => $ensure ? {
'present' => true,
'absent' => false,
default => false,
},
ensure => $ensure ? {
'present' => running,
'absent' => stopped,
default => stopped,
},
provider => upstart,
require => File[ "/etc/init/minecraft-${unixname}.conf" ],
}
monitor_net_service { "minecraft-${unixname}" :
hostname => $hostname,
description => "Minecraft ${unixname}",
checkcommand => "check_tcp",
arguments => "${port}",
ensure => $ensure ,
servicegroup => "applications"
}
}
file { "/etc/init/minecraft-${unixname}.conf" :
mode => 0644,
owner => root,
group => root,
content => template( "minecraft/upstart.erb" ),
require => File[ "/mnt/minecraft/${unixname}" ],
ensure => $ensure ? {
'purged' => 'absent',
default => 'present'
}
}
if $ensure == 'purged' {
file { "/etc/init/minecraft-${unixname}.override" :
ensure => absent,
backup => false,
}
file { "/mnt/minecraft/minecraft-${unixname}.fifo" :
ensure => absent,
backup => false,
}
}
}

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/4h/jg/6ftyvasrwtcm2fft
Default Alt Text
(6 KB)

Event Timeline