├── .bumpversion.cfg ├── .dockerignore ├── .gitignore ├── .rspec ├── .travis.yml ├── AUTHORS.rst ├── CHANGELOG.rst ├── LICENSE ├── Makefile ├── README.rst ├── Vagrantfile ├── defaults └── main.yml ├── docker-compose.yml ├── docker ├── centos7 │ ├── Dockerfile │ ├── chef-stable.repo │ └── chef.asc ├── jessie64 │ └── Dockerfile ├── trusty64 │ ├── Dockerfile │ ├── chef-stable.list │ └── chef.asc └── xenial64 │ ├── Dockerfile │ ├── chef-stable.list │ └── chef.asc ├── files └── eula.txt ├── handlers └── main.yml ├── library └── minecraft_server_file.py ├── meta └── main.yml ├── scripts ├── ci.sh └── install-docker.sh ├── tasks ├── acl.yml ├── configure.yml ├── download │ ├── latest-curl.yml │ ├── latest-uri.yml │ ├── latest.yml │ ├── main.yml │ ├── minecraft.yml │ └── spigot.yml ├── empty.yml ├── install │ ├── main.yml │ ├── minecraft.yml │ └── spigot.yml ├── main.yml └── setup │ ├── Debian.yml │ ├── RedHat.yml │ ├── main.yml │ ├── supervisor.yml │ ├── supervisor │ ├── Debian.yml │ └── RedHat.yml │ ├── systemd.yml │ └── systemd │ └── Ubuntu.yml ├── templates ├── acl.json.j2 ├── minecraft.conf.j2 ├── minecraft.service.j2 ├── minecraft.socket.j2 └── tmpfiles.d │ └── minecraft.conf.j2 ├── tests ├── hooks │ ├── after_download.yml │ ├── after_install.yml │ ├── after_setup.yml │ ├── after_start.yml │ ├── before_download.yml │ ├── before_install.yml │ ├── before_setup.yml │ └── before_start.yml ├── inventory ├── minecraft.yml ├── spec │ ├── minecraft_spec.rb │ └── spigot_spec.rb └── spigot.yml └── vars ├── Debian.yml ├── RedHat.yml ├── Ubuntu.yml └── main.yml /.bumpversion.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 3.1.0 3 | commit = True 4 | tag = True 5 | 6 | [bumpversion:file:README.md] 7 | 8 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .git/ 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | 3 | #Vagrant Files 4 | .vagrant/* 5 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --format documentation 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: generic 3 | sudo: required 4 | services: 5 | - docker 6 | env: 7 | global: 8 | - DOCKER_COMPOSE_VERSION=1.17.1 9 | matrix: 10 | - OS=jessie64 SERVER=minecraft PROCESS_CONTROL=systemd 11 | - OS=jessie64 SERVER=minecraft PROCESS_CONTROL=supervisor 12 | - OS=trusty64 SERVER=minecraft PROCESS_CONTROL=supervisor 13 | - OS=xenial64 SERVER=minecraft PROCESS_CONTROL=systemd 14 | - OS=centos7 SERVER=minecraft PROCESS_CONTROL=systemd 15 | - OS=jessie64 SERVER=spigot PROCESS_CONTROL=systemd 16 | - OS=jessie64 SERVER=spigot PROCESS_CONTROL=supervisor 17 | - OS=xenial64 SERVER=spigot PROCESS_CONTROL=systemd 18 | - OS=centos7 SERVER=spigot PROCESS_CONTROL=systemd 19 | before_install: 20 | - sudo -E ./scripts/install-docker.sh 21 | install: true 22 | script: 23 | - make "${OS}" test 24 | notifications: 25 | email: false 26 | webhooks: https://galaxy.ansible.com/api/v1/notifications/ 27 | -------------------------------------------------------------------------------- /AUTHORS.rst: -------------------------------------------------------------------------------- 1 | - Ben Webber (`**@benwebber** `__) 2 | - Mark Côté (`**@markrcote** `__) 3 | - Simon McCartney (`**@simonmcc** `__) 4 | -------------------------------------------------------------------------------- /CHANGELOG.rst: -------------------------------------------------------------------------------- 1 | ansible-minecraft changelog 2 | =========================== 3 | 4 | Unreleased 5 | ---------- 6 | 7 | Added 8 | ~~~~~ 9 | 10 | - (`#7 `__) Support `Spigot `__. 11 | 12 | Deprecated 13 | ~~~~~~~~~~ 14 | 15 | - Deprecate ``minecraft_supervisor_name`` in favour of ``minecraft_service_name``. 16 | 17 | Fixed 18 | ~~~~~ 19 | 20 | - When using ``curl`` to check the latest release, execute the task locally instead of on the remote host. 21 | 22 | 3.1.0 (2016-12-10) 23 | ------------------ 24 | 25 | Added 26 | ~~~~~ 27 | 28 | - Add support for Ubuntu 16.04 LTS (using systemd). 29 | 30 | Fixed 31 | ~~~~~ 32 | 33 | - Downgrade Travis CI Docker version by force to resolve build error. 34 | - Remove unsupported Debian version from Galaxy metadata. 35 | 36 | 3.0.1 (2016-12-10) 37 | ------------------ 38 | 39 | Fixed 40 | ~~~~~ 41 | 42 | - (`#9 `__) Fixed `RuntimeError` regression when building ACL files. 43 | 44 | 3.0.0 (2016-07-15) 45 | ------------------ 46 | 47 | Added 48 | ~~~~~ 49 | 50 | - (`#5 `__) Manage ``server.properties`` by setting ``minecraft_server_properties`` (Mark Côté). 51 | - (`#6 `__) Hooks: Include additional tasks at specific points during execution. 52 | 53 | Changed 54 | ~~~~~~~ 55 | 56 | - Install latest major release of Minecraft by default. 57 | 58 | Fixed 59 | ~~~~~ 60 | 61 | - (`#4 `__) Improve build documentation. 62 | 63 | 2.2.0 (2016-05-30) 64 | ------------------ 65 | 66 | Added 67 | ~~~~~ 68 | 69 | - It is now possible to install the latest major release of Minecraft using ``minecraft_version: latest``. 70 | 71 | Deprecated 72 | ~~~~~~~~~~ 73 | 74 | - The hard-coded default version (currently ``1.9``) will be replaced with ``latest`` in the next major version. 75 | 76 | Fixed 77 | ~~~~~ 78 | 79 | - Only generate ACL JSON files if the variables (e.g., ``minecraft_ops``) are non-empty. 80 | - Resolve deprecation warnings. 81 | 82 | 2.1.1 (2016-03-08) 83 | ------------------ 84 | 85 | - Notify Galaxy on successful build. 86 | 87 | 2.1.0 (2016-03-08) 88 | ------------------ 89 | 90 | Added 91 | ~~~~~ 92 | 93 | - Integrate Travis CI for automated integration testing. 94 | 95 | Changed 96 | ~~~~~~~ 97 | 98 | - Replace Vagrant test environments with Docker test harness. 99 | 100 | Fixed 101 | ~~~~~ 102 | 103 | - Correct minimum Ansible version (requires Ansible 1.8+). 104 | 105 | 2.0.0 (2016-03-01) 106 | ------------------ 107 | 108 | Added 109 | ~~~~~ 110 | 111 | - Add `AUTHORS `__ file. 112 | 113 | Changed 114 | ~~~~~~~ 115 | 116 | - Install latest 1.9 release by default. 117 | - Change default process supervisor (``minecraft_process_control``) from ``supervisor`` to ``systemd``. 118 | 119 | 1.4.0 (2016-01-23) 120 | ------------------ 121 | 122 | Changed 123 | ------- 124 | 125 | - Replace ACL script with Ansible module. 126 | 127 | 1.3.1 (2015-11-29) 128 | ------------------ 129 | 130 | Fixed 131 | ----- 132 | 133 | - Fix table rendering on Ansible Galaxy. 134 | 135 | 1.3.0 (2015-11-29) 136 | ------------------ 137 | 138 | Added 139 | ----- 140 | 141 | - Add Vagrant integration test suite. 142 | 143 | Deprecated 144 | ---------- 145 | 146 | - The default process supervisor (``minecraft_process_control``) will change from ``supervisor`` to ``systemd`` in the next major version. 147 | 148 | Fixed 149 | ----- 150 | 151 | - Configure Supervisor to run Java with absolute path (``/usr/bin/java``). 152 | - Add RHEL/CentOS to supported platforms on Ansible Galaxy. 153 | 154 | 1.2.0 (2015-11-26) 155 | ------------------ 156 | 157 | Added 158 | ----- 159 | 160 | - Add support for CentOS 7. 161 | 162 | Fixed 163 | ----- 164 | 165 | - Create ``/run/minecraft`` directory properly using ``systemd-tmpfiles`` 166 | - Fix socket permissions for systemd < 214. 167 | - Do not update apt cache. 168 | - Download server before starting the service for the first time. 169 | 170 | 1.1.0 (2015-11-24) 171 | ------------------ 172 | 173 | Added 174 | ----- 175 | 176 | - Support systemd. 177 | - Add Debian 8 test environment. 178 | 179 | Changed 180 | ------- 181 | 182 | - Bump default server version to ``1.8.8``. 183 | 184 | 1.0.0 (2015-11-23) 185 | ------------------ 186 | 187 | Initial release 188 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | 204 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | BOXES := $(notdir $(wildcard docker/*)) 2 | 3 | PROCESS_CONTROL ?= systemd 4 | SERVER ?= minecraft 5 | 6 | define USAGE 7 | targets: 8 | 9 | all build all Docker images (default) 10 | clean remove all Docker images 11 | help show this screen 12 | 13 | machine targets: 14 | 15 | build image 16 | clean remove image 17 | test provision and test 18 | 19 | machines: 20 | 21 | $(BOXES) 22 | 23 | variables: 24 | 25 | PROCESS_CONTROL Choose from 'supervisor' or 'systemd'. Default: 'systemd'. 26 | SERVER Choose from 'minecraft' or 'spigot'. Default: 'minecraft'. 27 | endef 28 | 29 | is_machine_target = $(if $(findstring $(firstword $(MAKECMDGOALS)),$(BOXES)),true,false) 30 | 31 | all: 32 | docker-compose build 33 | 34 | clean: 35 | ifeq (true,$(call is_machine_target)) 36 | docker rmi -f ansibleminecraft_$(firstword $(MAKECMDGOALS)) 37 | else 38 | -docker images -q ansibleminecraft* | xargs docker rmi -f 39 | endif 40 | 41 | help: 42 | @echo $(info $(USAGE)) 43 | 44 | test: 45 | ifeq (true,$(call is_machine_target)) 46 | ./scripts/ci.sh $(firstword $(MAKECMDGOALS)) $(PROCESS_CONTROL) $(SERVER) 47 | else 48 | $(error `test` requires a machine name, see `make help`) 49 | endif 50 | 51 | $(BOXES): 52 | # Don't build an image just to delete it. 53 | ifeq (,$(findstring clean,$(lastword $(MAKECMDGOALS)))) 54 | { docker images ansibleminecraft_$@ | grep $@; } && exit || docker-compose build $@ 55 | endif 56 | 57 | .PHONY: all \ 58 | clean \ 59 | help \ 60 | test 61 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ansible-minecraft 2 | ================= 3 | 4 | |Install from Ansible Galaxy| |Travis CI build status| |Chat on gitter.im| 5 | 6 | This role installs `Minecraft `__ or `Spigot `__ and configures it to run under `systemd `__ or `Supervisor `__. 7 | 8 | **If you're viewing this at** https://github.com/devops-coop/ansible-minecraft/**, you're reading the documentation for the master branch.** `View documentation for the latest release (3.1.0). `__ 9 | 10 | Requirements 11 | ------------ 12 | 13 | - **Optional:** Python 2.7 on the Ansible control machine to generate user ACLs 14 | - **Optional:** Ansible 2.0.2+ or ``curl`` on the control machine to fetch the latest Minecraft version 15 | 16 | Install 17 | ------- 18 | 19 | :: 20 | 21 | ansible-galaxy install devops-coop.minecraft 22 | 23 | 24 | Features 25 | -------- 26 | 27 | - supports `vanilla Minecraft `__ and `Spigot `__ 28 | - supports Debian 8, Ubuntu 14.04, Ubuntu 16.04, and RHEL/CentOS 7 29 | - supports different process supervisors on different platforms 30 | 31 | +----------------+--------------+-----------+ 32 | | OS | Supervisor | systemd | 33 | +================+==============+===========+ 34 | | Debian 8 | ✓ | ✓ | 35 | +----------------+--------------+-----------+ 36 | | Ubuntu 14.04 | ✓ | | 37 | +----------------+--------------+-----------+ 38 | | Ubuntu 16.04 | | ✓ | 39 | +----------------+--------------+-----------+ 40 | | CentOS 7 | | ✓ | 41 | +----------------+--------------+-----------+ 42 | 43 | - safely stops the server using `stop `__ when running under **systemd** 44 | - uses `Docker `__ and `Inspec `__ to run integration tests 45 | - manages user ACLs 46 | - manages ``server.properties`` 47 | - hooks: include arbitrary tasks at specific stages during execution 48 | 49 | Versioning 50 | ---------- 51 | 52 | This project follows `semantic versioning `__. 53 | 54 | In the context of semantic versioning, consider the role contract to be defined by the role variables. 55 | 56 | - Changes that require user intervention will increase the **major** version. This includes changing the default value of a role variable. 57 | - Changes that do not require user intervention, but add backwards-compatible features, will increase the **minor** version. 58 | - Bug fixes will increase the **patch** version. 59 | 60 | Refer to the `change log `__ for upcoming changes. 61 | 62 | Role variables 63 | -------------- 64 | 65 | The following variable defaults are defined in ``defaults/main.yml``. 66 | 67 | ``minecraft_version`` 68 | Minecraft version to install (default: ``latest``) 69 | 70 | Examples: 71 | 72 | .. code:: yaml 73 | 74 | minecraft_version: latest 75 | minecraft_version: 1.10 76 | minecraft_version: 1.9.1 77 | minecraft_version: 16w21a 78 | 79 | ``minecraft_url`` 80 | Minecraft download URL (default: 81 | ``https://s3.amazonaws.com/Minecraft.Download/versions``) 82 | 83 | ``minecraft_user`` 84 | system user Minecraft runs as (default: ``minecraft``) 85 | 86 | ``minecraft_group`` 87 | system group Minecraft runs as (default: ``minecraft``) 88 | 89 | ``minecraft_home`` 90 | directory to install Minecraft to (default: ``/srv/minecraft``) 91 | 92 | ``minecraft_max_memory`` 93 | Java max memory (``-Xmx``) to allocate (default: ``1024M``) 94 | 95 | ``minecraft_initial_memory`` 96 | Java initial memory (``-Xms``) to allocate (default: ``1024M``) 97 | 98 | ``minecraft_service_name`` 99 | systemd service name or Supervisor program name (default: ``minecraft``) 100 | 101 | ``minecraft_supervisor_name`` 102 | **DEPRECATED:** Supervisor program name (default: ``{{ minecraft_service_name }}``) 103 | 104 | ``minecraft_process_control`` 105 | Choose between ``systemd`` and ``supervisor`` (default: ``systemd``). 106 | 107 | ``minecraft_whitelist`` 108 | list of Minecraft usernames to whitelist (default: ``[]``) 109 | 110 | ``minecraft_ops`` 111 | list of Minecraft usernames to make server ops (default: ``[]``) 112 | 113 | ``minecraft_banned_players`` 114 | list of Minecraft usernames to ban (default: ``[]``) 115 | 116 | ``minecraft_banned_ips`` 117 | list of IP addresses to ban (default: ``[]``) 118 | 119 | ``minecraft_server_properties`` 120 | dictionary of server.properties entries (e.g. ``server-port: 25565``) to set (default: ``{}``) 121 | 122 | ``minecraft_server`` 123 | choose between ``minecraft`` or ``spigot`` (default: ``minecraft``) 124 | 125 | Hooks and run stages 126 | -------------------- 127 | 128 | **ansible-minecraft** organizes execution into a number of run stages: 129 | 130 | ``setup`` 131 | - install prerequisites (e.g., Java) 132 | - create Minecraft user and group 133 | 134 | ``download`` 135 | - fetch the latest version of from the launcher API 136 | - download Minecraft 137 | 138 | ``install`` 139 | - symlink version to ``minecraft_server.jar`` 140 | - agree to EULA 141 | 142 | ``acl`` 143 | - configure server ACLs (whitelist, banned players, etc.) 144 | 145 | ``configure`` 146 | - set ``server.properties`` 147 | 148 | ``start`` 149 | - (re)start server 150 | 151 | You can execute custom tasks before or after specific stages. Simply specify a `task include file `__ using the relevant role variable: 152 | 153 | .. code:: yaml 154 | 155 | - hosts: minecraft 156 | roles: 157 | - role: devops-coop.minecraft 158 | minecraft_hook_before_start: "{{ playbook_dir }}/download-world-from-s3.yml" 159 | 160 | The available hooks are: 161 | 162 | ``minecraft_hook_before_setup`` 163 | run before ``setup`` tasks 164 | 165 | ``minecraft_hook_after_setup`` 166 | run after ``setup`` tasks 167 | 168 | ``minecraft_hook_before_download`` 169 | run before ``download`` tasks 170 | 171 | ``minecraft_hook_after_download`` 172 | run after ``download`` tasks 173 | 174 | ``minecraft_hook_before_install`` 175 | run before ``install`` tasks 176 | 177 | ``minecraft_hook_after_install`` 178 | run after ``install`` tasks 179 | 180 | ``minecraft_hook_before_start`` 181 | run before ``start`` tasks 182 | 183 | ``minecraft_hook_after_start`` 184 | run after ``start`` tasks 185 | 186 | Example 187 | ------- 188 | 189 | .. code:: yaml 190 | 191 | - hosts: minecraft 192 | roles: 193 | - { role: devops-coop.minecraft, minecraft_whitelist: ["jeb_", "dinnerbone"]} 194 | 195 | Contributing 196 | ------------ 197 | 198 | The best way to contribute is to use this role to deploy your own Minecraft server! We really appreciate bug reports from the wild. 199 | 200 | If you'd like to help with the project itself, here are some other ways you can contribute: 201 | 202 | - Add support for additional servers like `Cuberite `__. 203 | - Write integration tests for Minecraft- or Spigot-specific configuration. 204 | - Share useful hooks. 205 | 206 | Testing 207 | ~~~~~~~ 208 | Testing can be done using the provided Vagrantfile or by installing `Docker `__ and `Docker Compose `__ locally. 209 | 210 | Testing with Vagrant 211 | """"""""""""""""""""" 212 | This role includes a Vagrantfile used with a Docker-based test harness that approximates the Travis CI setup for integration testing. Using Vagrant allows all contributors to test on the same platform and avoid false test failures due to untested or incompatible docker versions. 213 | 214 | 1. Install `Vagrant `__ and `VirtualBox `__. 215 | 216 | 2. Run ``vagrant up`` from the same directory as the Vagrantfile in this repository. 217 | 218 | 3. SSH into the VM with: ``vagrant ssh`` 219 | 220 | 4. Run tests with ``make``. 221 | 222 | :: 223 | 224 | make -C /vagrant xenial64 test 225 | 226 | Integration tests use **systemd** by default. Set ``PROCESS_CONTROL`` to change this: 227 | 228 | :: 229 | 230 | make -C /vagrant trusty64 test PROCESS_CONTROL=supervisor 231 | 232 | See ``make help`` for more information including a full list of available targets. 233 | 234 | Testing with Docker and Docker Compose locally 235 | """""""""""""""""""""""""""""""""""""""""""""""" 236 | Alternatively, you can install `Docker `__ and `Docker Compose `__ to run these tests locally on your machine. 237 | 238 | 1. Install `Docker `__ and `Docker Compose `__. 239 | 240 | 2. Run tests with ``make``. 241 | 242 | :: 243 | 244 | make jessie64 test 245 | 246 | Integration tests use **systemd** by default. Set ``PROCESS_CONTROL`` to change this: 247 | 248 | :: 249 | 250 | make trusty64 test PROCESS_CONTROL=supervisor 251 | 252 | See ``make help`` for more information including a full list of available targets. 253 | 254 | License 255 | ------- 256 | 257 | Apache 2.0 258 | 259 | Disclaimer 260 | ---------- 261 | 262 | To automate the installation, this role automatically accepts the `Minecraft EULA `__. Be aware that by using this role, you implicitly accept the same EULA. 263 | 264 | .. |Travis CI build status| image:: https://travis-ci.org/devops-coop/ansible-minecraft.svg?branch=master 265 | :target: https://travis-ci.org/devops-coop/ansible-minecraft 266 | .. |Install from Ansible Galaxy| image:: https://img.shields.io/badge/role-devops--coop.minecraft-blue.svg 267 | :target: https://galaxy.ansible.com/devops-coop/minecraft/ 268 | .. |Chat on gitter.im| image:: https://badges.gitter.im/gitterHQ/gitter.png 269 | :target: https://gitter.im/devops-coop/ansible-minecraft 270 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # Defines our Vagrant environment 2 | # 3 | # -*- mode: ruby -*- 4 | # vi: set ft=ruby : 5 | 6 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 7 | VAGRANTFILE_API_VERSION = "2" 8 | 9 | $setupScript = <