diff options
Diffstat (limited to 'roles')
-rw-r--r-- | roles/minecraft/tasks/main.yml | 32 | ||||
-rw-r--r-- | roles/minecraft/vars/main.yml | 2 |
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" |