Compare commits
2 Commits
831655600c
...
b769ea477b
Author | SHA1 | Date | |
---|---|---|---|
b769ea477b | |||
2b1ba0d6fc |
@ -11,8 +11,8 @@ minecraft_port: 25565
|
||||
minecraft_user: minecraft
|
||||
minecraft_group: minecraft
|
||||
|
||||
minecraft_jar_url: https://launcher.mojang.com/v1/objects/4d1826eebac84847c71a77f9349cc22afd0cf0a1/server.jar
|
||||
minecraft_jar_checksum: sha256:a0c062686bee5a92d60802ca74d198548481802193a70dda6d5fe7ecb7207993
|
||||
minecraft_jar_url: https://launcher.mojang.com/v1/objects/bb2b6b1aefcd70dfd1892149ac3a215f6c636b07/server.jar
|
||||
minecraft_jar_checksum: sha256:80cf86dc2004ec6a2dc0183d1c75a9af3ba0669f7c332e4247afb1d76fb67e8a
|
||||
|
||||
minecraft_opt_path: /opt/minecraft
|
||||
minecraft_var_path: "{{ minecraft_opt_path }}/var"
|
||||
|
@ -14,3 +14,9 @@
|
||||
service:
|
||||
name: rsyslog
|
||||
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
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
path: "{{ minecraft_var_path }}/{{ item.name }}"
|
||||
state: directory
|
||||
owner: "{{ minecraft_user }}"
|
||||
group: "{{ minecraft_group }}"
|
||||
mode: "0755"
|
||||
with_items:
|
||||
- "{{ minecraft_var_path }}"
|
||||
loop: "{{ minecraft_worlds }}"
|
||||
|
||||
- name: download minecraft server
|
||||
get_url:
|
||||
@ -53,29 +52,31 @@
|
||||
group: "{{ minecraft_group }}"
|
||||
mode: "0644"
|
||||
checksum: "{{ minecraft_jar_checksum }}"
|
||||
notify: restart minecraft
|
||||
notify: restart minecraft instances
|
||||
|
||||
- name: agree to the eula
|
||||
copy:
|
||||
content: "eula=true"
|
||||
dest: "{{ minecraft_var_path }}/eula.txt"
|
||||
dest: "{{ minecraft_var_path }}/{{ item.name }}/eula.txt"
|
||||
owner: "{{ minecraft_user }}"
|
||||
group: "{{ minecraft_group }}"
|
||||
mode: "0644"
|
||||
loop: "{{ minecraft_worlds }}"
|
||||
|
||||
- name: configure minecraft
|
||||
template:
|
||||
src: server.properties.j2
|
||||
dest: "{{ minecraft_var_path }}/server.properties"
|
||||
dest: "{{ minecraft_var_path }}/{{ item.name }}/server.properties"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify: restart minecraft
|
||||
notify: restart minecraft instances
|
||||
loop: "{{ minecraft_worlds }}"
|
||||
|
||||
- name: configure systemd unit
|
||||
template:
|
||||
src: minecraft.service.j2
|
||||
dest: /etc/systemd/system/minecraft.service
|
||||
dest: /etc/systemd/system/minecraft@.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
@ -84,83 +85,30 @@
|
||||
|
||||
- name: manage minecraft service
|
||||
service:
|
||||
name: "{{ minecraft_service_name }}"
|
||||
name: "minecraft@{{ item.name }}"
|
||||
state: "{{ minecraft_service_state }}"
|
||||
enabled: "{{ minecraft_service_enabled }}"
|
||||
loop: "{{ minecraft_worlds }}"
|
||||
|
||||
- name: configure ops
|
||||
copy:
|
||||
content: "{{ (minecraft_ops | default([])) | to_nice_json }}"
|
||||
dest: "{{ minecraft_var_path }}/ops.json"
|
||||
owner: "{{ minecraft_user }}"
|
||||
group: "{{ minecraft_group }}"
|
||||
mode: "0644"
|
||||
force: no
|
||||
notify: restart minecraft
|
||||
|
||||
- name: configure whitelist
|
||||
copy:
|
||||
content: "{{ (minecraft_whitelist | default([])) | to_nice_json }}"
|
||||
dest: "{{ minecraft_var_path }}/whitelist.json"
|
||||
owner: "{{ minecraft_user }}"
|
||||
group: "{{ minecraft_group }}"
|
||||
mode: "0644"
|
||||
force: no
|
||||
notify: restart minecraft
|
||||
|
||||
- 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: configure ops
|
||||
# copy:
|
||||
# content: "{{ (minecraft_ops | default([])) | to_nice_json }}"
|
||||
# dest: "{{ minecraft_var_path }}/ops.json"
|
||||
# owner: "{{ minecraft_user }}"
|
||||
# group: "{{ minecraft_group }}"
|
||||
# mode: "0644"
|
||||
# force: no
|
||||
# notify: restart minecraft instances
|
||||
#
|
||||
#- name: configure whitelist
|
||||
# copy:
|
||||
# content: "{{ (minecraft_whitelist | default([])) | to_nice_json }}"
|
||||
# dest: "{{ minecraft_var_path }}/whitelist.json"
|
||||
# owner: "{{ minecraft_user }}"
|
||||
# group: "{{ minecraft_group }}"
|
||||
# mode: "0644"
|
||||
# force: no
|
||||
# notify: restart minecraft instances
|
||||
|
||||
- name: install discord notifier
|
||||
copy:
|
||||
|
@ -1,7 +1,7 @@
|
||||
# {{ ansible_managed }}
|
||||
|
||||
[Unit]
|
||||
Description=Minecraft server
|
||||
Description=Minecraft server %i
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
@ -10,7 +10,7 @@ SuccessExitStatus=143
|
||||
Type=simple
|
||||
User={{ minecraft_user }}
|
||||
Group={{ minecraft_group }}
|
||||
WorkingDirectory={{ minecraft_var_path }}
|
||||
WorkingDirectory={{ minecraft_var_path }}/%i
|
||||
Restart=on-failure
|
||||
SyslogIdentifier=minecraft
|
||||
SyslogFacility={{ minecraft_syslog_facility }}
|
||||
|
@ -1,2 +1,3 @@
|
||||
white-list: {{ (minecraft_config.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