|
|
|
---
|
|
|
|
|
|
|
|
- name: Install required packages
|
|
|
|
apt:
|
|
|
|
state: present
|
|
|
|
name:
|
|
|
|
- openjdk-{{ java_version }}-jre-headless
|
|
|
|
|
|
|
|
- name: Create required read only directories
|
|
|
|
file:
|
|
|
|
state: directory
|
|
|
|
path: "{{ item }}"
|
|
|
|
owner: "{{ system_user }}"
|
|
|
|
group: "{{ system_user }}"
|
|
|
|
mode: "u=rx,g=rx,o="
|
|
|
|
loop:
|
|
|
|
- "{{ installation_directory }}"
|
|
|
|
|
|
|
|
- name: Create required data directories
|
|
|
|
file:
|
|
|
|
state: directory
|
|
|
|
path: "{{ item }}"
|
|
|
|
owner: "{{ system_user }}"
|
|
|
|
group: "{{ system_user }}"
|
|
|
|
mode: "u=rwx,g=rx,o="
|
|
|
|
loop:
|
|
|
|
- "{{ data_directory }}"
|
|
|
|
- "{{ mcrcon_directory }}"
|
|
|
|
|
|
|
|
- name: Download minecraft server jar
|
|
|
|
get_url:
|
|
|
|
url: "{{ minecraft_source_link }}"
|
|
|
|
validate_certs: yes
|
|
|
|
dest: "{{ installation_directory }}/server.{{ minecraft_version }}.jar"
|
|
|
|
owner: "{{ system_user }}"
|
|
|
|
group: "{{ system_user }}"
|
|
|
|
mode: "u=r,g=r,o="
|
|
|
|
|
|
|
|
- name: Symlink minecraft server jar
|
|
|
|
file:
|
|
|
|
src: "{{ installation_directory }}/server.{{ minecraft_version }}.jar"
|
|
|
|
dest: "{{ installation_directory }}/server.jar"
|
|
|
|
state: link
|
|
|
|
owner: "{{ system_user }}"
|
|
|
|
group: "{{ system_user }}"
|
|
|
|
notify:
|
|
|
|
- restart minecraft server
|
|
|
|
|
|
|
|
- name: Clone mcrcon into source directory
|
|
|
|
become_user: "{{ system_user }}"
|
|
|
|
git:
|
|
|
|
repo: "https://github.com/Tiiffi/mcrcon.git"
|
|
|
|
dest: "{{ mcrcon_directory }}"
|
|
|
|
version: master
|
|
|
|
clone: yes
|
|
|
|
update: yes
|
|
|
|
|
|
|
|
- name: Compile mcrcon
|
|
|
|
become_user: "{{ system_user }}"
|
|
|
|
make:
|
|
|
|
chdir: "{{ mcrcon_directory }}"
|
|
|
|
target: mcrcon
|
|
|
|
|
|
|
|
- name: Accept EULA
|
|
|
|
copy:
|
|
|
|
dest: "{{ data_directory }}/eula.txt"
|
|
|
|
content: "eula=true"
|
|
|
|
owner: "{{ system_user }}"
|
|
|
|
group: "{{ system_user }}"
|
|
|
|
mode: "u=r,g=r,o="
|
|
|
|
|
|
|
|
- name: Create remote control script
|
|
|
|
template:
|
|
|
|
src: control.sh
|
|
|
|
dest: "{{ remote_control_script }}"
|
|
|
|
owner: "{{ system_user }}"
|
|
|
|
group: "{{ system_user }}"
|
|
|
|
mode: "u=rx,g=r,o="
|
|
|
|
|
|
|
|
- name: Configure minecraft server
|
|
|
|
template:
|
|
|
|
src: server.properties
|
|
|
|
dest: "{{ data_directory }}/server.properties"
|
|
|
|
owner: "{{ system_user }}"
|
|
|
|
group: "{{ system_user }}"
|
|
|
|
mode: "u=r,g=r,o="
|
|
|
|
notify:
|
|
|
|
- restart minecraft server
|
|
|
|
|
|
|
|
- name: Register service for minecraft server
|
|
|
|
template:
|
|
|
|
src: "minecraft.service"
|
|
|
|
dest: "{{ global_systemd_configuration_directory }}/{{ service_name }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "u=rw,g=r,o="
|
|
|
|
notify:
|
|
|
|
- reload systemd
|
|
|
|
- restart minecraft server
|
|
|
|
|
|
|
|
- name: Allow port for minecraft server
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: "{{ minecraft_port }}"
|
|
|
|
proto: tcp
|