ansible-role-minecraft/tasks/main.yml

49 lines
1.8 KiB
YAML
Raw Normal View History

2020-12-28 12:27:18 -06:00
#!/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
2020-12-28 12:27:18 -06:00
- 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
2020-12-28 12:27:18 -06:00
- name: set up paper
include_tasks: paper.yml
2020-12-28 12:27:18 -06:00
when: minecraft_paper_install
# Forge - Server- and client-side modloader
2020-12-28 12:27:18 -06:00
- name: set up forge
include_tasks: forge.yml
2020-12-28 12:27:18 -06:00
when: minecraft_forge_install and minecraft_forge_version is defined
2020-12-28 12:27:18 -06:00
- name: enable service
systemd: name=minecraft@{{ minecraft_name }}.service enabled=yes state=started
2020-12-29 08:23:06 -06:00
when: minecraft_enabled
- name: disable service
systemd: name=minecraft@{{ minecraft_name }}.service enabled=no state=stopped
when: not minecraft_enabled