1
0
Fork 0
ansible-minecraft-server/roles/minecraft-server/tasks/main.yaml

57 lines
1.3 KiB
YAML
Raw Normal View History

2023-06-13 14:01:08 +00:00
# based on https://minecraft.fandom.com/wiki/Tutorials/Setting_up_a_server#Debian,_Ubuntu,_Raspbian
- name: Install required packages
apt:
update_cache: yes
name:
- openjdk-18-jre-headless
- name: Add user "minecraft"
user:
name: minecraft
create_home: false
shell: /bin/false
system: true
- name: Create install directory
file:
path: /srv/minecraft-server
owner: minecraft
group: minecraft
state: directory
- name: Download server jar
get_url:
url: https://piston-data.mojang.com/v1/objects/{{ mc_server_version }}/server.jar
dest: /srv/minecraft-server
2023-06-13 23:11:16 +00:00
notify: Restart server
2023-06-13 14:01:08 +00:00
- name: Accept EULA
copy:
src: eula.txt
dest: /srv/minecraft-server/eula.txt
2023-06-13 16:40:58 +00:00
- name: Configure server ops
copy:
content: "{{ mc_server_ops }}"
dest: /srv/minecraft-server/ops.json
2023-06-13 23:11:16 +00:00
notify: Restart server
2023-06-13 16:40:58 +00:00
2023-06-13 14:01:08 +00:00
- name: Install server script
template:
src: minecraft-server.sh
dest: /srv/minecraft-server/minecraft-server.sh
2023-06-13 23:11:16 +00:00
notify: Restart server
2023-06-13 14:01:08 +00:00
- name: Install minecraft-server systemd unit
copy:
src: minecraft-server.service
dest: /etc/systemd/system/minecraft-server.service
mode: 0644
2023-06-13 23:11:16 +00:00
notify: Restart server
2023-06-13 14:01:08 +00:00
- name: Enable minecraft-server service
systemd:
name: minecraft-server
daemon_reload: yes
enabled: yes