# HG changeset patch # User Luke Hoersten # Date 1589336665 18000 # Node ID 31de177274a16033be21cbf7b0ca8593391596ac # Parent ea20908c39046f95685b80d26de3d73d23dc70a1 Added minecraft server role. diff -r ea20908c3904 -r 31de177274a1 minecraft/defaults/main.yaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/minecraft/defaults/main.yaml Tue May 12 21:24:25 2020 -0500 @@ -0,0 +1,6 @@ +--- + +minecraft_user: "minecraft" +minecraft_url: "https://launcher.mojang.com/v1/objects/bb2b6b1aefcd70dfd1892149ac3a215f6c636b07/server.jar" +minecraft_dir: "/opt/minecraft" +minecraft_motd: "" diff -r ea20908c3904 -r 31de177274a1 minecraft/files/eula.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/minecraft/files/eula.txt Tue May 12 21:24:25 2020 -0500 @@ -0,0 +1,1 @@ +eula=true diff -r ea20908c3904 -r 31de177274a1 minecraft/handlers/main.yaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/minecraft/handlers/main.yaml Tue May 12 21:24:25 2020 -0500 @@ -0,0 +1,5 @@ +--- + +- name: restart minecraft + become: yes + systemd: name="minecraft.service" state="restarted" daemon_reload="yes" diff -r ea20908c3904 -r 31de177274a1 minecraft/tasks/main.yaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/minecraft/tasks/main.yaml Tue May 12 21:24:25 2020 -0500 @@ -0,0 +1,42 @@ +--- + +- name: add minecract user + become: yes + user: name="{{minecraft_user}}" home="{{minecraft_dir}}" + +- name: install jre + become: yes + apt: name="default-jre-headless" + +- name: download minecraft + become: yes + get_url: + url: "{{minecraft_url}}" + dest: "{{minecraft_dir}}/server.jar" + mode: "0755" + notify: restart minecraft + +- name: configure eula + become: yes + copy: + src: "eula.txt" + dest: "{{minecraft_dir}}/eula.txt" + +- name: configure minecraft + become: yes + template: + src: "server.properties.j2" + dest: "{{minecraft_dir}}/server.properties" + owner: "{{minecraft_user}}" + group: "{{minecraft_user}}" + notify: restart minecraft + +- name: install systemd service + become: yes + template: + src: "minecraft.service.j2" + dest: "/lib/systemd/system/minecraft.service" + +- name: ensure service is started + become: yes + systemd: name="minecraft.service" enabled="yes" state="started" diff -r ea20908c3904 -r 31de177274a1 minecraft/templates/minecraft.service.j2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/minecraft/templates/minecraft.service.j2 Tue May 12 21:24:25 2020 -0500 @@ -0,0 +1,22 @@ +[Unit] +Description=Minecraft Server +Documentation=https://minecraft.gamepedia.com/Tutorials/Setting_up_a_server + +Wants=network.target +After=network.target + +[Service] +User={{minecraft_user}} +Group={{minecraft_user}} +WorkingDirectory={{minecraft_dir}} +Restart=on-failure +RestartSec=20 5 +ExecStart=/usr/bin/java -Xms1536M -Xmx1536M -jar server.jar nogui + +PrivateTmp=true +ProtectSystem=full +NoNewPrivileges=true +PrivateDevices=true + +[Install] +WantedBy=multi-user.target diff -r ea20908c3904 -r 31de177274a1 minecraft/templates/server.properties.j2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/minecraft/templates/server.properties.j2 Tue May 12 21:24:25 2020 -0500 @@ -0,0 +1,44 @@ +broadcast-rcon-to-ops=true +view-distance=10 +max-build-height=256 +server-ip= +level-seed= +rcon.port=25575 +gamemode=survival +server-port=25565 +allow-nether=true +enable-command-block=false +enable-rcon=false +enable-query=false +op-permission-level=4 +prevent-proxy-connections=false +generator-settings= +resource-pack= +level-name=world +rcon.password= +player-idle-timeout=0 +motd={{minecraft_motd}} +query.port=25565 +force-gamemode=false +hardcore=false +white-list=false +broadcast-console-to-ops=true +pvp=true +spawn-npcs=true +generate-structures=true +spawn-animals=true +snooper-enabled=true +difficulty=easy +function-permission-level=2 +network-compression-threshold=256 +level-type=default +spawn-monsters=true +max-tick-time=60000 +enforce-whitelist=false +use-native-transport=true +max-players=20 +resource-pack-sha1= +spawn-protection=16 +online-mode=true +allow-flight=false +max-world-size=29999984