ansible/roles/minecraft-paper/tasks/main.yml

61 lines
2.2 KiB
YAML
Raw Normal View History

#!/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
2020-10-12 10:18:47 -05:00
template: src=eula.txt dest="{{ paper_home }}/{{ paper_name }}/eula.txt" mode="0644"
- name: Download Paper
get_url: url="{{ paper_downloadurl }}" dest="{{ paper_home }}/{{ paper_name }}/server.jar"
notify: "restart paper {{ paper_name }}"
2020-10-12 10:18:47 -05:00
- name: Template out hourly backup job
template: src=hourly.sh dest="{{ paper_home }}/{{ paper_name }}/hourly.sh" mode="0775"
- name: Set up hourly backup job
cron: minute="0" name="{{ paper_name }}-nightly" job="{{ paper_home }}/{{ paper_name }}/hourly.sh"
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