Add a bunch of dysfunctional crap

This commit is contained in:
Salt 2021-01-09 22:35:20 -06:00
parent 661bc4e4e1
commit c3ca975e85
4 changed files with 76 additions and 0 deletions

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# ansible-role-terraria
A role to install a Terraria server.

17
defaults/main.yml Normal file
View File

@ -0,0 +1,17 @@
# vim:ft=ansible:
terraria_name: default
terraria_version: blah
terraria_enabled: yes
terraria_restart_delay: 5
# Packages
# Put any extra dependencies (for mods, etc.) in _extra
terraria_packages:
- mono-complete
terraria_packages_extra: []
# Server configuration
#terraria_downloadurl:
# Service configuration
terraria_home: /opt/terraria

20
tasks/main.yml Normal file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env ansible-playbook
# vim:ft=ansible:
---
- name: set up system
block:
- name: install required packages
apt: name="{{ terraria_packages + terraria_packages_extra }}"
- name: assure server user
user: name=terraria system=yes home={{ terraria_home }}
- name: assure operational directory
file: path={{ terraria_home }} state=directory owner=terraria group=terraria mode="3775"
- name: assure systemd unit
template: src=terraria@.service dest=/etc/systemd/system/terraria@.service
notify: "restart terraria {{ terraria_name }}"
- name: set up terraria
block:
- name: assure server directory
file: path={{ terraria_home }}/{{ terraria_name }} state=directory
become: yes
become_user: terraria

View File

@ -0,0 +1,36 @@
#
# Licensed under the terms of the MIT license
# vim:ft=dosini:
#
[Unit]
Description=Terraria Server %i
After=network.target
[Service]
User=terraria
Group=terraria
WorkingDirectory={{ terraria_home }}/%i
EnvironmentFile={{ terraria_home }}/%i/env
PrivateUsers=true
ProtectSystem=full
ProtectHome=true
# Implies MountFlags=slave
ProtectKernelTunables=true
# Implies NoNewPrivileges=yes
ProtectKernelModules=true
# Implies MountAPIVFS=yes
ProtectControlGroups=true
ExecStart=/bin/sh -c '/usr/bin/screen -DmS %i /usr/bin/java -Xms${JRE_XMS} -Xmx${JRE_XMX} -jar server.jar nogui'
ExecReload=/usr/bin/screen -p 0 -S %i -X eval 'stuff "reload"\\015'
ExecStop=/usr/bin/screen -p 0 -S %i -X eval 'stuff "say Server is going down: Service was stopped"\\015'
ExecStop=/usr/bin/screen -p 0 -S %i -X eval 'stuff "save-all"\\015'
ExecStop=/usr/bin/screen -p 0 -S %i -X eval 'stuff "stop"\\015'
Restart=always
[Install]
WantedBy=multi-user.target