aboutsummaryrefslogtreecommitdiffstats
path: root/roles/minecraft
diff options
context:
space:
mode:
authorbinary <me@rgoncalves.se>2020-11-21 16:16:02 +0100
committerbinary <me@rgoncalves.se>2020-11-21 16:16:02 +0100
commit9ab92a79b7124eebfb4604f61975c7ac6c9c1304 (patch)
treeaf33df01e247fb78d4fb830a79f7e1b0dec3c6e9 /roles/minecraft
parent44ede44c438d1a9d10b90032d8decb42bfe5ce49 (diff)
downloadinfrastructure-9ab92a79b7124eebfb4604f61975c7ac6c9c1304.tar.gz
Add openrc for minecraft.
Diffstat (limited to 'roles/minecraft')
-rw-r--r--roles/minecraft/tasks/main.yml32
-rw-r--r--roles/minecraft/vars/main.yml2
2 files changed, 30 insertions, 4 deletions
diff --git a/roles/minecraft/tasks/main.yml b/roles/minecraft/tasks/main.yml
index 1b9142e..d75ff07 100644
--- a/roles/minecraft/tasks/main.yml
+++ b/roles/minecraft/tasks/main.yml
@@ -3,10 +3,15 @@
---
+- name: create minecraft group
+ group:
+ name: "{{ minecraft_group }}"
+ state: present
+
- name: create minecraft user
user:
name: "{{ minecraft_user }}"
- group: "{{ minecraft_user }}"
+ group: "{{ minecraft_group }}"
- name: create minecraft directory
file:
@@ -24,8 +29,27 @@
- name: enable eula
lineinfile:
- file: "{{ minecraft_dir }}/eula.txt"
+ path: "{{ minecraft_dir }}/eula.txt"
regexp: "^eula=false"
line: eula=true
- become: true
- become_user: "{{ minecraft_user }}"
+ owner: "{{ minecraft_user }}"
+ group: "{{ minecraft_group }}"
+ mode: 0600
+ create: true
+
+- name: generate launch script
+ template:
+ src: launch.sh.j2
+ dest: "{{ minecraft_dir }}/launch.sh"
+ owner: "{{ minecraft_user }}"
+ group: "{{ minecraft_group }}"
+ mode: 0700
+
+- name: create service minecraft server
+ include_role: name=rc
+ vars:
+ rc_cmd: java
+ rc_args: "-jar -Xms{{ minecraft_ram }} -Xmx{{ minecraft_ram }} -XX:+UseG1GC -jar server.jar nogui"
+ rc_user: "{{ minecraft_user }}:{{ minecraft_group }}"
+ rc_dir: "{{ minecraft_dir }}"
+ rc_name: minecraft
diff --git a/roles/minecraft/vars/main.yml b/roles/minecraft/vars/main.yml
index 1fc2549..f280e73 100644
--- a/roles/minecraft/vars/main.yml
+++ b/roles/minecraft/vars/main.yml
@@ -4,6 +4,8 @@
---
minecraft_user: "minecraft"
+minecraft_group: "minecraft"
minecraft_dir: "/data/minecraft"
minecraft_bin: "server.jar"
+minecraft_ram: "4G"
minecraft_url: "https://papermc.io/api/v1/paper/1.16.4/274/download"
remember that computers suck.