You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
3.4 KiB
YAML

---
- 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: Configure service controlling scripts
template:
src: "{{ item.name }}"
dest: "{{ item.path }}"
owner: "{{ system_user }}"
group: "{{ system_user }}"
mode: "u=rx,g=r,o="
notify:
- restart minecraft server
loop:
- name: "launch.sh"
path: "{{ launch_script }}"
loop_control:
label: "{{ item.name }}"
- name: Configure server controlling scripts
template:
src: "{{ item.name }}"
dest: "{{ item.path }}"
owner: "{{ system_user }}"
group: "{{ system_user }}"
mode: "u=rx,g=r,o="
loop:
- name: "control.sh"
path: "{{ remote_control_script }}"
loop_control:
label: "{{ item.name }}"
- name: Configure apparmor profile
template:
src: "profile.apparmor"
dest: "{{ apparmor_profile }}"
owner: root
group: root
mode: "u=rw,g=r,o="
notify:
- reload apparmor profile
- restart minecraft server
- 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:
comment: "{{ domain }} minecraft server"
rule: allow
port: "{{ minecraft_port }}"
proto: tcp
- name: Allow port for minecraft query requests
ufw:
comment: "{{ domain }} minecraft query requests"
rule: allow
port: "{{ minecraft_query_port }}"
proto: udp