From cfe9012e324693e8e9c098641ed0fb8cd4a7a110 Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Sat, 22 Aug 2020 10:00:13 -0500 Subject: [PATCH] remove minecraft multi-instance support --- roles/minecraft/defaults/main.yaml | 3 +- roles/minecraft/handlers/main.yaml | 6 --- roles/minecraft/tasks/main.yaml | 42 ++++--------------- .../minecraft/templates/minecraft.service.j2 | 4 +- 4 files changed, 12 insertions(+), 43 deletions(-) diff --git a/roles/minecraft/defaults/main.yaml b/roles/minecraft/defaults/main.yaml index bc7cd13..b45b217 100644 --- a/roles/minecraft/defaults/main.yaml +++ b/roles/minecraft/defaults/main.yaml @@ -15,8 +15,7 @@ minecraft_jar_url: https://launcher.mojang.com/v1/objects/bb2b6b1aefcd70dfd18921 minecraft_jar_checksum: sha256:80cf86dc2004ec6a2dc0183d1c75a9af3ba0669f7c332e4247afb1d76fb67e8a minecraft_opt_path: /opt/minecraft -minecraft_var_path: "{{ minecraft_opt_path }}/var" -minecraft_backup_path: "{{ minecraft_opt_path }}/backup" +minecraft_var_path: /var/opt/minecraft minecraft_syslog_facility: local5 diff --git a/roles/minecraft/handlers/main.yaml b/roles/minecraft/handlers/main.yaml index b9176f5..9ff27b7 100644 --- a/roles/minecraft/handlers/main.yaml +++ b/roles/minecraft/handlers/main.yaml @@ -14,9 +14,3 @@ service: name: rsyslog state: restarted - -- name: restart minecraft instances - service: - name: "minecraft@{{ item.name }}.service" - state: restarted - loop: "{{ minecraft_worlds | default([]) }}" diff --git a/roles/minecraft/tasks/main.yaml b/roles/minecraft/tasks/main.yaml index 873150c..1501e6c 100644 --- a/roles/minecraft/tasks/main.yaml +++ b/roles/minecraft/tasks/main.yaml @@ -37,12 +37,11 @@ - name: create minecraft var directory file: - path: "{{ minecraft_var_path }}/{{ item.name }}" + path: "{{ minecraft_var_path }}" state: directory owner: "{{ minecraft_user }}" group: "{{ minecraft_group }}" mode: "0755" - loop: "{{ minecraft_worlds }}" - name: download minecraft server get_url: @@ -52,31 +51,29 @@ group: "{{ minecraft_group }}" mode: "0644" checksum: "{{ minecraft_jar_checksum }}" - notify: restart minecraft instances + notify: restart minecraft - name: agree to the eula copy: content: "eula=true" - dest: "{{ minecraft_var_path }}/{{ item.name }}/eula.txt" + dest: "{{ minecraft_var_path }}/eula.txt" owner: "{{ minecraft_user }}" group: "{{ minecraft_group }}" mode: "0644" - loop: "{{ minecraft_worlds }}" - name: configure minecraft template: src: server.properties.j2 - dest: "{{ minecraft_var_path }}/{{ item.name }}/server.properties" + dest: "{{ minecraft_var_path }}/server.properties" owner: root group: root mode: 0644 - notify: restart minecraft instances - loop: "{{ minecraft_worlds }}" + notify: restart minecraft - name: configure systemd unit template: src: minecraft.service.j2 - dest: /etc/systemd/system/minecraft@.service + dest: /etc/systemd/system/minecraft.service owner: root group: root mode: 0644 @@ -85,30 +82,9 @@ - name: manage minecraft service service: - name: "minecraft@{{ item.name }}" - state: "{{ item.state | default(minecraft_service_state) }}" - enabled: "{{ item.enabled | default(minecraft_service_enabled) }}" - loop: "{{ minecraft_worlds }}" - - #- name: configure ops - # copy: - # content: "{{ (minecraft_ops | default([])) | to_nice_json }}" - # dest: "{{ minecraft_var_path }}/ops.json" - # owner: "{{ minecraft_user }}" - # group: "{{ minecraft_group }}" - # mode: "0644" - # force: no - # notify: restart minecraft instances - # - #- name: configure whitelist - # copy: - # content: "{{ (minecraft_whitelist | default([])) | to_nice_json }}" - # dest: "{{ minecraft_var_path }}/whitelist.json" - # owner: "{{ minecraft_user }}" - # group: "{{ minecraft_group }}" - # mode: "0644" - # force: no - # notify: restart minecraft instances + name: minecraft.service + state: "{{ minecraft_service_state }}" + enabled: "{{ minecraft_service_enabled }}" - name: install discord notifier copy: diff --git a/roles/minecraft/templates/minecraft.service.j2 b/roles/minecraft/templates/minecraft.service.j2 index 2b95e49..e8e558d 100644 --- a/roles/minecraft/templates/minecraft.service.j2 +++ b/roles/minecraft/templates/minecraft.service.j2 @@ -1,7 +1,7 @@ # {{ ansible_managed }} [Unit] -Description=Minecraft server %i +Description=Minecraft server After=network.target [Service] @@ -10,7 +10,7 @@ SuccessExitStatus=143 Type=simple User={{ minecraft_user }} Group={{ minecraft_group }} -WorkingDirectory={{ minecraft_var_path }}/%i +WorkingDirectory={{ minecraft_var_path }} Restart=on-failure SyslogIdentifier=minecraft SyslogFacility={{ minecraft_syslog_facility }}