A simple cookbook for installing and maintaining multiple types of Minecraft servers.
It currently supports 4 different type of Minecraft servers:
It also has support for Spigot's BuildTools.
If you find any bugs or have any ideas of how this cookbook could be improved, don't be afraid to create an issue on the GitHub page!
- Chef 12.5+
- Centos 6+
- Ubuntu 14+
Note: On some distros of Linux, when trying to log into a GNU screen, you might receive a similar error to this: "Cannot open your terminal '/dev/pts/0' - please check."
You will need to execute script /dev/null
to gain access to it. This is because the screen was initially owned by root before the current user. If you have a way to fix this securely (no chmodding /dev/pts/x) please fill free to post an issue.
In your Berksfile include this cookbook by putting cookbook 'minecraft-server', git: 'git://github.com/Mac-Genius/minecraft-server.git'
. Then inside your metadata.rb file include depends 'minecraft-server'
.
There are a few recipes, but they are not intended for use! You should use the custom resources provided by this cookbook. These recipes are intended for testing purposes only. They should only be used as examples.
This provides all the dependencies for this cookbook, including Java, screen, unzip, and git.
Actions
:install
: installs the dependencies
Attributes
name
: the name of the resourceinstall_all
: installs all dependencies needed to run a Minecraft serverinstall_git
: installs gitinstall_java
: installs javainstall_screen
: installs screeninstall_unzip
: installs unzipjava_flavor
: what kind of java should be installed (oracle, openjdk, etc.)java_version
: the java version that should be installed
This will setup the vanilla Minecraft server including the service files.
Actions
:create
: installs the Minecraft server:update
: updates the Minecraft server's jar and world:delete
: uninstalls the Minecraft server
Attributes
name
: the name of the servereula
: whether you agree to Minecraft terms of service. You need to agree to it during the:create
action to ensure the server is createdgroup
: the group permission that owns the server files. defaults tochefminecraft
owner
: the owner permission that owns the server files. defaults tochefminecraft
path
: the path to the server directory. defaults to/opt/minecraft_servers
reset_world
: whether to reset the world when using the:update
actionsnapshot
: whether the server should be a snapshotversion
: the version of minecraft to install. Defaults to the latest versionworld
: a url to a zipped world file
This will update the server properties
Actions
:update
: updates the Minecraft server's server.properties file
Attributes
name
: the name of the serversettings
: a hash of the server propertiesgroup
: the group permission that owns the server files. defaults tochefminecraft
owner
: the owner permission that owns the server files. defaults tochefminecraft
path
: the path to the server directory. defaults to/opt/minecraft_servers
This will create the necessary service files and run, restart, and stop the Minecraft server.
Actions
:start
: start the Minecraft server:stop
: stop the Minecraft server:restart
: restart the Minecraft server:enable
: enables the Minecraft server to restart after a server reboot:disable
: disables automatic Minecraft startup:create
: creates the service files for the Minecraft server:update
: updates the service files for the Minecraft server:delete
: deletes the service files for the Minecraft server
Attributes
service_name
: the name of the service for a Minecraft servercommands
: a command or list of commands to be ran after a server startes or before a server stopscommand_delay
: the delay between the execution of Minecraft commandsgroup
: the group permission that owns the server files. defaults tochefminecraft
owner
: the owner permission that owns the server files. defaults tochefminecraft
path
: the path to the server directory. defaults to/opt/minecraft_servers
jar_name
: the name of the jar excluding the '.jar' at the end
This will setup the Spigot Minecraft server including the service files.
Actions
:create
: installs the Spigot Minecraft server:update
: updates the Spigot Minecraft server's jar and world:delete
: uninstalls the Spigot Minecraft server
Attributes
name
: the name of the serverbuild_tools_dir
: the directory to put BuildTools. Defaults to/opt/build_tools
eula
: whether you agree to Minecraft terms of service. You need to agree to it during the:create
action to ensure the server is createdgroup
: the group permission that owns the server files, defaults tochefminecraft
jar_source
: the url of an external Spigot jar fileowner
: the owner permission that owns the server files. defaults tochefminecraft
path
: the path to the server directory. defaults to/opt/minecraft_servers
reset_world
: whether to reset the world when using the:update
actionversion
: the version of minecraft to install. Defaults to the latest versionworld
: a url to a zipped world fileupdate_jar
: whether to check for a patch for the current version of Spigot
This will setup the Spigot server's spigot.yml file.
Actions
:update
: updates the Spigot server's spigot.yml file:reset
: resets the spigot.yml file back to its default form
Attributes
name
: the name of the serversettings
: the settings for the spigot.yml as a hashgroup
: the group permission that owns the server files. defaults tochefminecraft
owner
: the owner permission that owns the server files. defaults tochefminecraft
path
: the path to the server directory. defaults to/opt/minecraft_servers
This will setup the Bukkit Minecraft server including the service files.
Actions
:create
: installs the Bukkit Minecraft server:update
: updates the Bukkit Minecraft server's jar and world:delete
: uninstalls the Bukkit Minecraft server
Attributes
name
: the name of the serverbuild_tools_dir
: the directory to put BuildTools. Defaults to/opt/build_tools
eula
: whether you agree to Minecraft terms of service. You need to agree to it during the:create
action to ensure the server is createdgroup
: the group permission that owns the server files. defaults tochefminecraft
jar_source
: the url of an external Bukkit jar fileowner
: the owner permission that owns the server files. defaults tochefminecraft
path
: the path to the server directory. defaults to/opt/minecraft_servers
reset_world
: whether to reset the world when using the:update
actionversion
: the version of minecraft to install. Defaults to the latest versionworld
: a url to a zipped world fileupdate_jar
: whether to check for a patch for the current version of Bukkit
This will setup the Bukkit server's bukkit.yml file.
Actions
:update
: updates the Bukkit server's bukkit.yml file:reset
: resets the bukkit.yml file back to its default form
Attributes
name
: the name of the serversettings
: the settings for the bukkit.yml as a hashgroup
: the group permission that owns the server files. defaults tochefminecraft
owner
: the owner permission that owns the server files. defaults tochefminecraft
path
: the path to the server directory. defaults to/opt/minecraft_servers
This will install, update, and delete plugins.
Actions
:install
: installs the Bukkit plugin:update
: updates the Bukkit plugin:delete
: removes the Bukkit plugin
Attributes
id
: the name of the plugin from the url. ex) http://dev.bukkit.org/bukkit-plugins/group
: the group permission that owns the server files. defaults tochefminecraft
owner
: the owner permission that owns the server files. defaults tochefminecraft
path
: the path to the server directory. defaults to/opt/minecraft_servers
servers
: a string or list of server names to install, update, or delete a plugin onversion
: the version of the plugin to install. Defaults to the latest versionsource
: a url to the jar. Only needed if the plugin is not on Bukkit.org. spigotmc.org/resources links do not work because of Cloudflare!
This will allowing adding, editing, and removing items from a plugin's config.yml file or other configurable .yml file.
Note: To remove an item from a config file, simply add '$r$' in front of the name of the item to be removed.
Actions
:update
: updates the config file with the settings from thesettings
property:reset
: resets the config file by deleting it and allowing the server to create a new one
Attributes
:file_name
: the name of the file to edit. the default name is config.yml:group
: the group permission that owns the config file. defaults tochefminecraft
:name
: the name of the plugin that the config belongs to. defaults tochefminecraft
:owner
: the owner permission that owns the config file:path
: the path of the server folder. defaults to/opt/minecraft_servers
:servers
: a string or an array of strings containing the servers with the plugin to be updated:settings
: a hash containing the settings to be changed
This will setup BuildTools for creating the Bukkit and Spigot jars. When using the spigot_server/bukkit_server resource, that resource will automatically build the jars. You do not need to use this.
Actions
:install
: installs BuildTools:reset
: resets the bukkit.yml file back to its default form
Attributes
name
: the name of the servergroup
: the group permission that owns the server files. defaults tochefminecraft
owner
: the owner permission that owns the server files. defaults tochefminecraft
path
: the path to the server directory. defaults to/opt/minecraft_servers
source
: the link to BuildTools. defaults to the latest stable versionupdate_jar
: whether the current version of Spigot or Bukkit should be updatedversion
: the version of Spigot or Bukkit to build
This will setup the Bungeecord Proxy server including the service files.
Actions
:create
: installs the Bunegeecord server:update
: updates the Bunegeecord server's jar:delete
: uninstalls the Bunegeecord server
Attributes
name
: the name of the servergroup
: the group permission that owns the server files. defaults tochefminecraft
jar_source
: the url of an external Bungeecord jar fileowner
: the owner permission that owns the server files. defaults tochefminecraft
path
: the path to the server directory. defaults to/opt/minecraft_servers
update_jar
: whether to update the Bungeecord jarversion
: the version of minecraft to install. defaults to the latest version
This will setup the Bungeecord server's config.yml file.
Actions
:update
: updates the Bungeecord server's config.yml:reset
: resets the config.yml file back to its default form
Attributes
name
: the name of the serversettings
: the settings for the config.yml as a hashgroup
: the group permission that owns the server files. defaults tochefminecraft
owner
: the owner permission that owns the server files. defaults tochefminecraft
path
: the path to the server directory. defaults to/opt/minecraft_servers
# installs all dependencies
minecraft_depend 'dependencies' do
install_all true
end
# installs the server and service files
minecraft_server 'test' do
eula true
action :create
end
# set properties for the server
server_properties 'test' do
settings({
:motd => 'Welcome to a Chef example server!',
:enable_command_block => true,
:difficulty => 3
})
end
# starts the server
minecraft_service 'test' do
commands 'say Server is now online!'
action :start
end
# updates the server version and resets the world
# this will automatically stop and restart your server
minecraft_server 'test' do
reset_world true
version '1.9.4'
action :update
end
# starts the server
minecraft_service 'test' do
commands ['say The server is restarting!', 'say It will be back soon!']
action :stop
end
# set properties for the server
server_properties 'test' do
settings({
:motd => 'Welcome to a Chef example server!',
:enable_command_block => true,
:difficulty => 3
})
end
# starts the server
minecraft_service 'test' do
commands 'say Server is now online!'
action :start
end
# uninstalls the server and service files
minecraft_server 'test' do
action :delete
end
(replace spigot with bukkit to create a bukkit server)
# installs all dependencies
minecraft_depend 'dependencies' do
install_all true
end
# installs the server and service files
spigot_server 'test' do
eula true
action :create
end
# set properties for the server
server_properties 'test' do
settings({
:motd => 'Welcome to a Chef example server!',
:enable_command_block => true,
:difficulty => 3
})
end
# update the spigot.yml file
spigot_yml 'test' do
settings({
settings => {
:debug => true
}
})
end
bukkit_plugin 'worldedit' do
servers 'test'
action :install
end
bukkit_plugin 'Essentials' do
source 'https://hub.spigotmc.org/jenkins/job/spigot-essentials/lastSuccessfulBuild/artifact/Essentials/target/Essentials-2.x-SNAPSHOT.jar'
servers 'test'
action :install
end
# Updates Essentials' config.yml file
# $r$ removes a settings
bukkit_plugin_config 'Essentials' do
servers 'test'
settings ({
'debug' => true,
'player-commands' => [
'$r$compass',
'$r$warp'
]
})
end
# starts the server
minecraft_service 'test' do
commands 'say Server is now online!'
action :start
end
(replace spigot with bukkit to create a bukkit server)
# installs all dependencies
minecraft_depend 'dependencies' do
install_all true
end
# installs the server and service files
bungeecord_server 'test' do
action :create
end
# set properties for the server
bungeecord_config_yml node['minecraft']['server-name'] do
settings ({
'listeners' => [
{
'motd' => '&1A Generic motd',
'host' => '0.0.0.0:25565',
'max_players' => 30,
'force_default_server' => true
}
],
'ip_forward' => true
})
action :update
end
# starts the server
minecraft_service 'test' do
action :start
end