57 lines
1.2 KiB
YAML
57 lines
1.2 KiB
YAML
# 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: "{{ mc_server_jar }}"
|
|
dest: /srv/minecraft-server
|
|
notify: Restart server
|
|
|
|
- name: Accept EULA
|
|
copy:
|
|
src: eula.txt
|
|
dest: /srv/minecraft-server/eula.txt
|
|
|
|
- name: Configure server ops
|
|
copy:
|
|
content: "{{ mc_server_ops }}"
|
|
dest: /srv/minecraft-server/ops.json
|
|
notify: Restart server
|
|
|
|
- name: Install server script
|
|
template:
|
|
src: minecraft-server.sh
|
|
dest: /srv/minecraft-server/minecraft-server.sh
|
|
notify: Restart server
|
|
|
|
- name: Install minecraft-server systemd unit
|
|
copy:
|
|
src: minecraft-server.service
|
|
dest: /etc/systemd/system/minecraft-server.service
|
|
mode: 0644
|
|
notify: Restart server
|
|
|
|
- name: Enable minecraft-server service
|
|
systemd:
|
|
name: minecraft-server
|
|
daemon_reload: yes
|
|
enabled: yes |