# HG changeset patch # User Luke Hoersten # Date 1590890262 18000 # Node ID ad75fc2d2853ec2fcbef96952b2ac43b3db9662f # Parent 78242f9f4010677ca3f7556ff5f480cdad614f3d Added papermc role. diff -r 78242f9f4010 -r ad75fc2d2853 papermc/defaults/main.yaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/papermc/defaults/main.yaml Sat May 30 20:57:42 2020 -0500 @@ -0,0 +1,10 @@ +--- + +papermc_user: "papermc" +papermc_version: "1.15.2" +papermc_build: "327" +papermc_url: "https://papermc.io/api/v1/paper/{{papermc_version}}/{{papermc_build}}/download" +papermc_dir: "/opt/papermc" +papermc_motd: "A Minecraft Server" +papermc_mem: "2G" +papermc_world_dir: "{{papermc_dir}}" diff -r 78242f9f4010 -r ad75fc2d2853 papermc/files/eula.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/papermc/files/eula.txt Sat May 30 20:57:42 2020 -0500 @@ -0,0 +1,1 @@ +eula=true diff -r 78242f9f4010 -r ad75fc2d2853 papermc/files/ops.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/papermc/files/ops.json Sat May 30 20:57:42 2020 -0500 @@ -0,0 +1,8 @@ +[ + { + "uuid": "98827ef9-601c-49fd-b575-abc8de019854", + "name": "Lukemute", + "level": 4, + "bypassesPlayerLimit": true + } +] \ No newline at end of file diff -r 78242f9f4010 -r ad75fc2d2853 papermc/handlers/main.yaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/papermc/handlers/main.yaml Sat May 30 20:57:42 2020 -0500 @@ -0,0 +1,5 @@ +--- + +- name: restart papermc + become: yes + systemd: name="papermc.service" state="restarted" daemon_reload="yes" diff -r 78242f9f4010 -r ad75fc2d2853 papermc/tasks/main.yaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/papermc/tasks/main.yaml Sat May 30 20:57:42 2020 -0500 @@ -0,0 +1,66 @@ +--- + +- name: add papermc user + become: yes + user: name="{{papermc_user}}" home="{{papermc_dir}}" + +- name: install jre + become: yes + apt: name="default-jre-headless" + +- name: download papermc + become: yes + get_url: + url: "{{papermc_url}}" + dest: "{{papermc_dir}}/server.jar" + mode: "0755" + notify: restart papermc + +- name: configure eula and ops + become: yes + copy: + src: "{{item}}" + dest: "{{papermc_dir}}/{{item}}" + owner: "{{papermc_user}}" + group: "{{papermc_user}}" + loop: + - "eula.txt" + - "ops.json" + notify: restart papermc + +- name: set motd + become: yes + lineinfile: + path: "{{papermc_dir}}/server.properties" + regexp: "^motd=" + line: "motd={{papermc_motd}}" + notify: restart papermc + +- name: create world file directory + become: yes + file: + path: "{{papermc_world_dir}}" + state: "directory" + owner: "{{papermc_user}}" + group: "{{papermc_user}}" + mode: "0755" + +- name: set world files + become: yes + lineinfile: + path: "{{papermc_dir}}/bukkit.yml" + regexp: "^ world-container:" + line: " world-container: {{papermc_world_dir}}" + insertbefore: "^ permissions-file:" + notify: restart papermc + +- name: install systemd service + become: yes + template: + src: "papermc.service.j2" + dest: "/lib/systemd/system/papermc.service" + notify: restart papermc + +- name: ensure service is started + become: yes + systemd: name="papermc.service" enabled="yes" state="started" diff -r 78242f9f4010 -r ad75fc2d2853 papermc/templates/papermc.service.j2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/papermc/templates/papermc.service.j2 Sat May 30 20:57:42 2020 -0500 @@ -0,0 +1,22 @@ +[Unit] +Description=PaperMC Server +Documentation=https://paper.readthedocs.io/en/latest/server/getting-started.html + +Wants=network.target +After=network.target + +[Service] +User={{papermc_user}} +Group={{papermc_user}} +WorkingDirectory={{papermc_dir}} +Restart=on-failure +RestartSec=20 5 +ExecStart=/usr/bin/java -Xms{{papermc_mem}} -Xmx{{papermc_mem}} -jar server.jar + +PrivateTmp=true +ProtectSystem=full +NoNewPrivileges=true +PrivateDevices=true + +[Install] +WantedBy=multi-user.target