49 lines
1.8 KiB
YAML
49 lines
1.8 KiB
YAML
#!/usr/bin/ansible-playbook
|
|
# vim:ft=ansible:
|
|
---
|
|
- name: set up system
|
|
block:
|
|
- name: install required packages
|
|
apt: name="{{ minecraft_packages + minecraft_packages_extra }}"
|
|
- name: assure server user
|
|
user: name=minecraft system=yes home={{ minecraft_home }}
|
|
- name: assure operational directory
|
|
file: path={{ minecraft_home }} state=directory owner=minecraft group=minecraft mode="3775"
|
|
- name: assure systemd unit
|
|
template: src=minecraft@.service dest=/etc/systemd/system/minecraft@.service
|
|
notify: "restart minecraft {{ minecraft_name }}"
|
|
- name: set up minecraft
|
|
block:
|
|
- name: assure server directory
|
|
file: path={{ minecraft_home }}/{{ minecraft_name }} state=directory
|
|
- name: accept eula
|
|
template: src=eula.txt dest={{ minecraft_home }}/{{ minecraft_name }}/eula.txt
|
|
- name: template out env
|
|
template: src=env dest={{ minecraft_home }}/{{ minecraft_name }}/env
|
|
- name: configure server properties
|
|
lineinfile:
|
|
dest: "{{ minecraft_home }}/{{ minecraft_name }}/server.properties"
|
|
line: "{{ item.opt }}={{ item.value }}"
|
|
regex: "^{{ item.opt }}=.*"
|
|
create: yes
|
|
loop: "{{ minecraft_server_properties }}"
|
|
notify: "restart minecraft {{ minecraft_name }}"
|
|
become: yes
|
|
become_user: minecraft
|
|
|
|
# Paper - A vanilla server with plugin support
|
|
- name: set up paper
|
|
include_tasks: paper.yml
|
|
when: minecraft_paper_install
|
|
# Forge - Server- and client-side modloader
|
|
- name: set up forge
|
|
include_tasks: forge.yml
|
|
when: minecraft_forge_install and minecraft_forge_version is defined
|
|
|
|
- name: enable service
|
|
systemd: name=minecraft@{{ minecraft_name }}.service enabled=yes state=started
|
|
when: minecraft_enabled
|
|
- name: disable service
|
|
systemd: name=minecraft@{{ minecraft_name }}.service enabled=no state=stopped
|
|
when: not minecraft_enabled
|