Add new host and enroll it in Paper

Note: currently untested, hopefully shit Just Werks
This commit is contained in:
Salt 2020-10-10 22:44:17 -05:00
parent 64a0b2b9ec
commit abb8090c9b
9 changed files with 211 additions and 69 deletions

View File

@ -98,3 +98,4 @@ all:
38313431663734343931333462316633643935353038313934663466303834636533616165353961 38313431663734343931333462316633643935353038313934663466303834636533616165353961
6438356265656532396363323532616437353831613261323037 6438356265656532396363323532616437353831613261323037
hosts: hosts:
paper1.9iron.club:

View File

@ -5,74 +5,17 @@
roles: roles:
- role: base-backups - role: base-backups
tags: [ backups ] tags: [ backups ]
- hosts: tes3mp1.9iron.club - hosts: paper1.9iron.club
roles: roles:
- role: tes3mp - role: gitweb
tags: [ tes3mp ]
tasks:
- name: Assure CNAME record
route53:
state: present
overwrite: yes
zone: 9iron.club
type: CNAME
record: tes3mp.9iron.club
ttl: 3600
value: [ "{{ inventory_hostname }}." ]
become: yes
tags: [ dns ]
- hosts: mc1.9iron.club
roles:
- role: base-backups
tags: [ backups ]
# - role: minecraft-forge
# vars:
# mcname: "me5"
# mczip: "https://www.9iron.club/files/me5.zip"
# mcforge: "1.12.2-14.23.5.2854"
# mcmotd: "ME5 is Fun Edition"
# mcport: 25565
# mcgamemode: 0
# mcviewdist: 14
# mcleveltype: "default"
# tags: [ gameserver, minecraft, me5 ]
- role: tmodloader
vars: vars:
terraria_difficulty: 1 gitweb_repo: "https://git.9iron.club/salt/thefuck.how"
terraria_name: "calamity" gitweb_url: "thefuck.how"
terraria_password: "dicks" gitweb_webroot: "/var/www/thefuck.how"
tags: [ gameserver, terraria, calamity ] - role: minecraft-paper
tasks: vars:
- name: Assure Minecraft CNAME record paper_name: "thefuckhow"
route53: paper_mc_motd: "Brett's new serber"
state: present paper_jre_xms: 1024m
overwrite: yes paper_jre_xmx: 2048m
zone: 9iron.club tags: [ gameserver, minecraft, paper ]
type: CNAME
record: "me5.mc.9iron.club."
ttl: 3600
value: [ "{{ inventory_hostname }}." ]
become: yes
tags: [ dns, minecraft, me5 ]
- name: Assure Minecraft SRV record
route53:
state: present
overwrite: yes
zone: 9iron.club
type: SRV
record: "_minecraft._tcp.me5.mc.9iron.club."
ttl: 3600
value: [ "1 10 25565 {{ inventory_hostname }}." ]
become: yes
tags: [ dns, minecraft, me5 ]
- name: Assure Terraria record
route53:
state: present
overwrite: yes
zone: 9iron.club
type: CNAME
record: "calamity.9iron.club"
ttl: 3600
value: [ "{{ inventory_hostname }}." ]
become: yes
tags: [ dns, terraria, calamity ]

View File

@ -0,0 +1,26 @@
# vim:ft=ansible:
paper_name: default
# Service configuration
paper_downloadurl: "https://papermc.io/api/v1/paper/1.16.3/latest/download"
paper_home: /var/lib/minecraft-paper
paper_stopmessage: "Server is going down for maintenance"
# Java configuration
paper_jre_xms: 2048m
paper_jre_xmx: 4096m
# Minecraft configuration
paper_mc_difficulty: normal
paper_mc_gamemode: 0
paper_mc_gensettings: ""
paper_mc_leveltype: default
paper_mc_maxplayers: 10
paper_mc_motd: A new Paper server
paper_mc_pvp: "true"
paper_mc_spawnprotection: 4
paper_mc_viewdist: 12
paper_mc_whitelist: "false"
# Server configuration
paper_port: 25565

View File

@ -0,0 +1,9 @@
#!/usr/bin/ansible-playbook
# vim:ft=ansible:
---
- name: "restart paper {{ paper_name }}"
systemd:
daemon_reload: yes
name: "paper@{{ paper_name }}"
state: restarted
become: yes

View File

@ -0,0 +1,56 @@
#!/usr/bin/ansible-playbook
# vim:ft=ansible:
---
- name: Set up Paper server
block:
- name: Set up system
block:
- name: Install required packages
apt:
name:
- openjdk-8-jre
- screen
- name: Assure server user
user:
name: minecraft-paper
system: yes
home: "{{ paper_home }}"
- name: Assure var directory
file:
path: "{{ paper_home }}"
state: directory
owner: minecraft-paper
group: minecraft-paper
# Sticky, SetGID
mode: "3775"
- name: Assure systemd unit
template:
src: "paper@.service"
dest: /etc/systemd/system/paper@.service
notify: "restart paper {{ paper_name }}"
- name: Set up server "{{ paper_name }}"
block:
- name: Assure server directory
file:
path: "{{ paper_home }}/{{ paper_name }}"
state: directory
owner: minecraft-paper
group: minecraft-paper
- name: Configure server.properties
template: src=server.properties dest="{{ paper_home }}/{{ paper_name }}/server.properties"
notify: "restart paper {{ paper_name }}"
- name: Accept EULA
template: src=eula.txt dest="{{ paper_home }}/{{ paper_name }}/eula.txt"
- name: Download Paper
get_url: url="{{ paper_downloadurl }}" dest="{{ paper_home }}/{{ paper_name }}/server.jar"
notify: "restart paper {{ paper_name }}"
become: yes
become_user: minecraft-paper
- name: Enable service
systemd: name="paper@{{ paper_name }}" enabled=yes state=started
- name: Template out backup module
template:
src: backup.sh
dest: "/opt/backups/modules/paper-{{ paper_name }}.sh"
mode: "0600"
become: yes

View File

@ -0,0 +1,28 @@
#! /bin/bash
#
# paper-{{ paper_name }}.sh
# Backup script for Minecraft. Meant to be sourced by our main backup script
# Copyright (C) 2020 Vintage Salt <rehashedsalt@cock.li>
#
# Distributed under terms of the MIT license.
#
set -e
export OUTDIR="$BACKUPSDIR/{{ paper_name }}"
# Sanity checks
if [ -z "$BACKUPSDIR" ]; then
log "BACKUPSDIR was undefined. Run the main backup script instead of this one."
return 1
fi
if ! [ -d "$OUTDIR" ]; then
if ! mkdir "$OUTDIR"; then
log "Unable to find or create output directory: $OUTDIR"
return 2
fi
fi
# WE MAKE BACKUP NOW SERGEI
tar czf "$OUTDIR/{{ paper_name }}-$(date -Iseconds)-full.tar.gz" "{{ paper_home }}/{{ paper_name }}/"

View File

@ -0,0 +1,2 @@
# Tacos best food yadda yadda
eula=true

View File

@ -0,0 +1,39 @@
#
# Licensed under the terms of the MIT license
# Source: https://github.com/agowa338/MinecraftSystemdUnit/
# vim:ft=dosini:
#
[Unit]
Description=Paper Minecraft Server %i
After=network.target
[Service]
User=minecraft
Group=mc-admin
WorkingDirectory={{ paper_home }}/%i
PrivateUsers=true
ProtectSystem=full
ProtectHome=true
# Implies MountFlags=slave
ProtectKernelTunables=true
# Implies NoNewPrivileges=yes
ProtectKernelModules=true
# Implies MountAPIVFS=yes
ProtectControlGroups=true
ExecStart=/bin/sh -c '/usr/bin/screen -DmS %i /usr/bin/java -Xms{{ paper_jre_xms }} -Xmx{{ paper_jre_xmx }} -jar server.jar nogui'
ExecReload=/usr/bin/screen -p 0 -S %i -X eval 'stuff "reload"\\015'
ExecStop=/usr/bin/screen -p 0 -S %i -X eval 'stuff "say {{ paper_stopmessage }}"\\015'
ExecStop=/usr/bin/screen -p 0 -S %i -X eval 'stuff "save-all"\\015'
ExecStop=/usr/bin/screen -p 0 -S %i -X eval 'stuff "stop"\\015'
ExecStop=/bin/sleep 5
Restart=always
# Restart after 24hrs
RuntimeMaxSecs=86400
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,38 @@
# Minecraft server properties
allow-flight=true
allow-nether=true
difficulty={{ paper_mc_difficulty }}
enable-command-block=true
enable-query=false
enable-rcon=false
force-gamemode=false
gamemode={{ paper_mc_gamemode }}
generate-structures=true
generator-settings={{ paper_mc_gensettings }}
hardcore=false
level-name=world
level-seed=
level-type={{ paper_mc_leveltype }}
max-build-height=256
max-players={{ paper_mc_maxplayers }}
max-tick-time=60000
max-world-size=29999984
motd={{ paper_mc_motd }}
network-compression-threshold=256
online-mode=true
op-permission-level=4
player-idle-timeout=0
prevent-proxy-connections=false
pvp={{ paper_mc_pvp }}
resource-pack=
resource-pack-sha1=
server-ip=
server-port={{ paper_port }}
snooper-enabled=false
spawn-animals=true
spawn-monsters=true
spawn-npcs=true
spawn-protection={{ paper_mc_spawnprotection }}
use-native-transport=true
view-distance={{ paper_mc_viewdist }}
white-list={{ paper_mc_whitelist }}