add minecraft server
This commit is contained in:
parent
992c60bf25
commit
1454bc4e40
11
hosts
11
hosts
|
@ -30,10 +30,15 @@ all:
|
||||||
nfs_libraries:
|
nfs_libraries:
|
||||||
- 192.168.20.30:/mnt/pool0/media/Movies
|
- 192.168.20.30:/mnt/pool0/media/Movies
|
||||||
- 192.168.20.30:/mnt/pool0/media/Series
|
- 192.168.20.30:/mnt/pool0/media/Series
|
||||||
homeassistant:
|
minecraft-server:
|
||||||
hosts:
|
hosts:
|
||||||
homeassistant:
|
minecraft-server:
|
||||||
ansible_host: 192.168.20.32
|
ansible_host: 192.168.20.32
|
||||||
|
mc_server_memory: 3500M
|
||||||
|
mc_server_ops:
|
||||||
|
- uuid: 649a9370-5cad-4553-93c8-cf0af25208dd
|
||||||
|
name: jirost
|
||||||
|
level: 4
|
||||||
k3s:
|
k3s:
|
||||||
children:
|
children:
|
||||||
k3s-server:
|
k3s-server:
|
||||||
|
@ -67,7 +72,7 @@ all:
|
||||||
bastions:
|
bastions:
|
||||||
k3s:
|
k3s:
|
||||||
plex:
|
plex:
|
||||||
homeassistant:
|
minecraft-server:
|
||||||
vars:
|
vars:
|
||||||
ansible_user: ansible
|
ansible_user: ansible
|
||||||
ansible_password: !vault |
|
ansible_password: !vault |
|
||||||
|
|
|
@ -22,6 +22,6 @@
|
||||||
roles:
|
roles:
|
||||||
- plex
|
- plex
|
||||||
|
|
||||||
- hosts: homeassistant
|
- hosts: minecraft-server
|
||||||
roles:
|
roles:
|
||||||
- homeassistant
|
- minecraft-server
|
|
@ -0,0 +1,3 @@
|
||||||
|
mc_server_version: 15c777e2cfe0556eef19aab534b186c0c6f277e1
|
||||||
|
mc_server_memory: 1000M
|
||||||
|
mc_server_ops: []
|
|
@ -0,0 +1 @@
|
||||||
|
eula=true
|
|
@ -0,0 +1,14 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Minecraft Server
|
||||||
|
Documentation=https://minecraft.fandom.com/wiki/Tutorials/Setting_up_a_server
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=minecraft
|
||||||
|
Group=minecraft
|
||||||
|
WorkingDirectory=/srv/minecraft-server
|
||||||
|
ExecStart=/bin/bash /srv/minecraft-server/minecraft-server.sh
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -0,0 +1,5 @@
|
||||||
|
- name: Restart server
|
||||||
|
systemd:
|
||||||
|
name: minecraft-server
|
||||||
|
daemon_reload: yes
|
||||||
|
state: restarted
|
|
@ -0,0 +1,57 @@
|
||||||
|
# based on https://minecraft.fandom.com/wiki/Tutorials/Setting_up_a_server#Debian,_Ubuntu,_Raspbian
|
||||||
|
|
||||||
|
- name: Install required packages
|
||||||
|
apt:
|
||||||
|
update_cache: yes
|
||||||
|
name:
|
||||||
|
- openjdk-18-jre-headless
|
||||||
|
|
||||||
|
- name: Add user "minecraft"
|
||||||
|
user:
|
||||||
|
name: minecraft
|
||||||
|
create_home: false
|
||||||
|
shell: /bin/false
|
||||||
|
system: true
|
||||||
|
|
||||||
|
- name: Create install directory
|
||||||
|
file:
|
||||||
|
path: /srv/minecraft-server
|
||||||
|
owner: minecraft
|
||||||
|
group: minecraft
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: Download server jar
|
||||||
|
get_url:
|
||||||
|
url: https://piston-data.mojang.com/v1/objects/{{ mc_server_version }}/server.jar
|
||||||
|
dest: /srv/minecraft-server
|
||||||
|
notify: Restart server
|
||||||
|
|
||||||
|
- name: Accept EULA
|
||||||
|
copy:
|
||||||
|
src: eula.txt
|
||||||
|
dest: /srv/minecraft-server/eula.txt
|
||||||
|
|
||||||
|
- name: Configure server ops
|
||||||
|
copy:
|
||||||
|
content: "{{ mc_server_ops }}"
|
||||||
|
dest: /srv/minecraft-server/ops.json
|
||||||
|
notify: Restart server
|
||||||
|
|
||||||
|
- name: Install server script
|
||||||
|
template:
|
||||||
|
src: minecraft-server.sh
|
||||||
|
dest: /srv/minecraft-server/minecraft-server.sh
|
||||||
|
notify: Restart server
|
||||||
|
|
||||||
|
- name: Install minecraft-server systemd unit
|
||||||
|
copy:
|
||||||
|
src: minecraft-server.service
|
||||||
|
dest: /etc/systemd/system/minecraft-server.service
|
||||||
|
mode: 0644
|
||||||
|
notify: Restart server
|
||||||
|
|
||||||
|
- name: Enable minecraft-server service
|
||||||
|
systemd:
|
||||||
|
name: minecraft-server
|
||||||
|
daemon_reload: yes
|
||||||
|
enabled: yes
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
exec /usr/bin/java -Xmn{{ mc_server_memory }} -Xmx{{ mc_server_memory }} -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar /srv/minecraft-server/server.jar
|
Loading…
Reference in New Issue