minecraft multi-instance support
This commit is contained in:
parent
2b1ba0d6fc
commit
b769ea477b
@ -14,3 +14,9 @@
|
|||||||
service:
|
service:
|
||||||
name: rsyslog
|
name: rsyslog
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
|
- name: restart minecraft instances
|
||||||
|
service:
|
||||||
|
name: "minecraft@{{ item.name }}.service"
|
||||||
|
state: restarted
|
||||||
|
loop: "{{ minecraft_worlds | default([]) }}"
|
||||||
|
@ -37,13 +37,12 @@
|
|||||||
|
|
||||||
- name: create minecraft var directory
|
- name: create minecraft var directory
|
||||||
file:
|
file:
|
||||||
path: "{{ item }}"
|
path: "{{ minecraft_var_path }}/{{ item.name }}"
|
||||||
state: directory
|
state: directory
|
||||||
owner: "{{ minecraft_user }}"
|
owner: "{{ minecraft_user }}"
|
||||||
group: "{{ minecraft_group }}"
|
group: "{{ minecraft_group }}"
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
with_items:
|
loop: "{{ minecraft_worlds }}"
|
||||||
- "{{ minecraft_var_path }}"
|
|
||||||
|
|
||||||
- name: download minecraft server
|
- name: download minecraft server
|
||||||
get_url:
|
get_url:
|
||||||
@ -53,29 +52,31 @@
|
|||||||
group: "{{ minecraft_group }}"
|
group: "{{ minecraft_group }}"
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
checksum: "{{ minecraft_jar_checksum }}"
|
checksum: "{{ minecraft_jar_checksum }}"
|
||||||
notify: restart minecraft
|
notify: restart minecraft instances
|
||||||
|
|
||||||
- name: agree to the eula
|
- name: agree to the eula
|
||||||
copy:
|
copy:
|
||||||
content: "eula=true"
|
content: "eula=true"
|
||||||
dest: "{{ minecraft_var_path }}/eula.txt"
|
dest: "{{ minecraft_var_path }}/{{ item.name }}/eula.txt"
|
||||||
owner: "{{ minecraft_user }}"
|
owner: "{{ minecraft_user }}"
|
||||||
group: "{{ minecraft_group }}"
|
group: "{{ minecraft_group }}"
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
|
loop: "{{ minecraft_worlds }}"
|
||||||
|
|
||||||
- name: configure minecraft
|
- name: configure minecraft
|
||||||
template:
|
template:
|
||||||
src: server.properties.j2
|
src: server.properties.j2
|
||||||
dest: "{{ minecraft_var_path }}/server.properties"
|
dest: "{{ minecraft_var_path }}/{{ item.name }}/server.properties"
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
notify: restart minecraft
|
notify: restart minecraft instances
|
||||||
|
loop: "{{ minecraft_worlds }}"
|
||||||
|
|
||||||
- name: configure systemd unit
|
- name: configure systemd unit
|
||||||
template:
|
template:
|
||||||
src: minecraft.service.j2
|
src: minecraft.service.j2
|
||||||
dest: /etc/systemd/system/minecraft.service
|
dest: /etc/systemd/system/minecraft@.service
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
@ -84,83 +85,30 @@
|
|||||||
|
|
||||||
- name: manage minecraft service
|
- name: manage minecraft service
|
||||||
service:
|
service:
|
||||||
name: "{{ minecraft_service_name }}"
|
name: "minecraft@{{ item.name }}"
|
||||||
state: "{{ minecraft_service_state }}"
|
state: "{{ minecraft_service_state }}"
|
||||||
enabled: "{{ minecraft_service_enabled }}"
|
enabled: "{{ minecraft_service_enabled }}"
|
||||||
|
loop: "{{ minecraft_worlds }}"
|
||||||
|
|
||||||
- name: configure ops
|
#- name: configure ops
|
||||||
copy:
|
# copy:
|
||||||
content: "{{ (minecraft_ops | default([])) | to_nice_json }}"
|
# content: "{{ (minecraft_ops | default([])) | to_nice_json }}"
|
||||||
dest: "{{ minecraft_var_path }}/ops.json"
|
# dest: "{{ minecraft_var_path }}/ops.json"
|
||||||
owner: "{{ minecraft_user }}"
|
# owner: "{{ minecraft_user }}"
|
||||||
group: "{{ minecraft_group }}"
|
# group: "{{ minecraft_group }}"
|
||||||
mode: "0644"
|
# mode: "0644"
|
||||||
force: no
|
# force: no
|
||||||
notify: restart minecraft
|
# notify: restart minecraft instances
|
||||||
|
#
|
||||||
- name: configure whitelist
|
#- name: configure whitelist
|
||||||
copy:
|
# copy:
|
||||||
content: "{{ (minecraft_whitelist | default([])) | to_nice_json }}"
|
# content: "{{ (minecraft_whitelist | default([])) | to_nice_json }}"
|
||||||
dest: "{{ minecraft_var_path }}/whitelist.json"
|
# dest: "{{ minecraft_var_path }}/whitelist.json"
|
||||||
owner: "{{ minecraft_user }}"
|
# owner: "{{ minecraft_user }}"
|
||||||
group: "{{ minecraft_group }}"
|
# group: "{{ minecraft_group }}"
|
||||||
mode: "0644"
|
# mode: "0644"
|
||||||
force: no
|
# force: no
|
||||||
notify: restart minecraft
|
# notify: restart minecraft instances
|
||||||
|
|
||||||
- name: install backup script
|
|
||||||
copy:
|
|
||||||
src: minecraft-backup.sh
|
|
||||||
dest: "{{ minecraft_opt_path }}/bin/minecraft-backup"
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0700
|
|
||||||
|
|
||||||
- name: backup cron job
|
|
||||||
cron:
|
|
||||||
name: minecraft backup
|
|
||||||
minute: "0"
|
|
||||||
hour: "9"
|
|
||||||
user: root
|
|
||||||
job: "{{ minecraft_opt_path }}/bin/minecraft-backup"
|
|
||||||
|
|
||||||
- name: backup clean up cron
|
|
||||||
cron:
|
|
||||||
name: minecraft backup clean up
|
|
||||||
minute: "0"
|
|
||||||
hour: "11"
|
|
||||||
user: root
|
|
||||||
job: "find {{ minecraft_opt_path }}/backup/ -type f -name '*.tar.xz' -ctime +7 -delete"
|
|
||||||
|
|
||||||
- name: set world download password
|
|
||||||
htpasswd:
|
|
||||||
path: "{{ minecraft_opt_path }}/etc/htpasswd"
|
|
||||||
name: minecraft
|
|
||||||
password: minecraft
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0644
|
|
||||||
when: "'nginx' in ansible_play_role_names"
|
|
||||||
|
|
||||||
- name: configure nginx
|
|
||||||
template:
|
|
||||||
src: nginx.conf.j2
|
|
||||||
dest: /etc/nginx/sites-available/minecraft
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0644
|
|
||||||
when: "'nginx' in ansible_play_role_names"
|
|
||||||
notify: reload nginx
|
|
||||||
|
|
||||||
- name: activate site
|
|
||||||
file:
|
|
||||||
src: /etc/nginx/sites-available/minecraft
|
|
||||||
dest: /etc/nginx/sites-enabled/minecraft
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
state: link
|
|
||||||
when: "'nginx' in ansible_play_role_names"
|
|
||||||
notify: reload nginx
|
|
||||||
|
|
||||||
- name: install discord notifier
|
- name: install discord notifier
|
||||||
copy:
|
copy:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# {{ ansible_managed }}
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Minecraft server
|
Description=Minecraft server %i
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
@ -10,7 +10,7 @@ SuccessExitStatus=143
|
|||||||
Type=simple
|
Type=simple
|
||||||
User={{ minecraft_user }}
|
User={{ minecraft_user }}
|
||||||
Group={{ minecraft_group }}
|
Group={{ minecraft_group }}
|
||||||
WorkingDirectory={{ minecraft_var_path }}
|
WorkingDirectory={{ minecraft_var_path }}/%i
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
SyslogIdentifier=minecraft
|
SyslogIdentifier=minecraft
|
||||||
SyslogFacility={{ minecraft_syslog_facility }}
|
SyslogFacility={{ minecraft_syslog_facility }}
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
white-list: {{ (minecraft_config.whitelist | default(true)) | ternary('true', 'false') }}
|
white-list: {{ (minecraft_config.whitelist | default(true)) | ternary('true', 'false') }}
|
||||||
enforce-whitelist: {{ (minecaft_config.enfoce_whitelist | default(true)) | ternary('true', 'false') }}
|
enforce-whitelist: {{ (minecaft_config.enfoce_whitelist | default(true)) | ternary('true', 'false') }}
|
||||||
|
server-port: {{ item.port | default(25565) }}
|
||||||
|
Loading…
Reference in New Issue
Block a user