Compare commits
No commits in common. "0041c0e82d037ad09c6e683c3140e50bf7f066a3" and "c3ca975e8583365d459fcf5533842c36322c4ed8" have entirely different histories.
0041c0e82d
...
c3ca975e85
40
README.md
40
README.md
@ -1,43 +1,3 @@
|
|||||||
# ansible-role-terraria
|
# ansible-role-terraria
|
||||||
|
|
||||||
A role to install a Terraria server.
|
A role to install a Terraria server.
|
||||||
|
|
||||||
## Supported Configuration
|
|
||||||
|
|
||||||
The role supporst the following distros:
|
|
||||||
|
|
||||||
* Anything Debian-like
|
|
||||||
|
|
||||||
The only real dependency is Mono. If you can get that installed some other way, the role will probably work on any distro.
|
|
||||||
|
|
||||||
## Basic Setup
|
|
||||||
|
|
||||||
Template out the role, ensuring it has root privileges. Consider setting the following vars:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
terraria_name: Name of the subdirectory of the server
|
|
||||||
terraria_version: The Terraria version string, sans periods (ex. 1412)
|
|
||||||
terraria_enabled: Boolean to determine the state of the server (defaults to yes)
|
|
||||||
```
|
|
||||||
|
|
||||||
More handy variables can be found in `defaults`.
|
|
||||||
|
|
||||||
You can manage server-config through the `terraria_config` dictionary:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
terraria_config:
|
|
||||||
max-players: 8
|
|
||||||
password: supersecret
|
|
||||||
```
|
|
||||||
|
|
||||||
Run the play and enjoy.
|
|
||||||
|
|
||||||
## Administration
|
|
||||||
|
|
||||||
The role will install servers as systemd units. A server named `default` will have the unit `terraria@default.service`. The server runs as its own user.
|
|
||||||
|
|
||||||
To access the server console, invoke `screen` as the `terraria` user. For example, to access the console of a server named `default`, use `sudo -u terraria screen -r default`.
|
|
||||||
|
|
||||||
## TODO
|
|
||||||
|
|
||||||
The biggest issue is that Redigit doesn't have a very... friendly server URL scheme. Often, if you want to download an updated server package, you'll have to manually change the `terraria_downloadurl`. Solutions to this problem are welcome.
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# vim:ft=ansible:
|
# vim:ft=ansible:
|
||||||
terraria_name: default
|
terraria_name: default
|
||||||
terraria_version: 1412
|
terraria_version: blah
|
||||||
terraria_enabled: yes
|
terraria_enabled: yes
|
||||||
terraria_restart_delay: 5
|
terraria_restart_delay: 5
|
||||||
|
|
||||||
@ -11,14 +11,7 @@ terraria_packages:
|
|||||||
terraria_packages_extra: []
|
terraria_packages_extra: []
|
||||||
|
|
||||||
# Server configuration
|
# Server configuration
|
||||||
terraria_downloadurl: "https://terraria.org/system/dedicated_servers/archives/000/000/042/original/terraria-server-{{ terraria_version }}.zip"
|
#terraria_downloadurl:
|
||||||
terraria_config_default:
|
|
||||||
autocreate: 3
|
|
||||||
difficulty: 0
|
|
||||||
port: 7777
|
|
||||||
world: "{{ terraria_home }}/{{ terraria_name }}/worlds/world.wld"
|
|
||||||
worldpath: "{{ terraria_home }}/{{ terraria_name }}/worlds"
|
|
||||||
terraria_config: {}
|
|
||||||
|
|
||||||
# Service configuration
|
# Service configuration
|
||||||
terraria_home: /opt/terraria
|
terraria_home: /opt/terraria
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
#!/usr/bin/ansible-playbook
|
|
||||||
# vim:ft=ansible:
|
|
||||||
---
|
|
||||||
- name: "restart terraria {{ terraria_name }}"
|
|
||||||
systemd:
|
|
||||||
name: "terraria@{{ terraria_name }}"
|
|
||||||
state: restarted
|
|
||||||
become: yes
|
|
||||||
when: terraria_enabled
|
|
@ -16,36 +16,5 @@
|
|||||||
block:
|
block:
|
||||||
- name: assure server directory
|
- name: assure server directory
|
||||||
file: path={{ terraria_home }}/{{ terraria_name }} state=directory
|
file: path={{ terraria_home }}/{{ terraria_name }} state=directory
|
||||||
- name: download server zip
|
|
||||||
get_url: url={{ terraria_downloadurl }} dest={{ terraria_home }}/{{ terraria_name }}/server.zip
|
|
||||||
register: download_server
|
|
||||||
- name: install server
|
|
||||||
block:
|
|
||||||
- name: assure server unzip directory
|
|
||||||
file: path={{ terraria_home }}/{{ terraria_name }}/server state=directory
|
|
||||||
- name: unpack zip
|
|
||||||
unarchive: src={{ terraria_home }}/{{ terraria_name }}/server.zip dest={{ terraria_home }}/{{ terraria_name }}/server remote_src=yes
|
|
||||||
- name: template out installer
|
|
||||||
template: src=install-server.sh dest={{ terraria_home }}/{{ terraria_name }}/install-server.sh
|
|
||||||
- name: run installer
|
|
||||||
command:
|
|
||||||
chdir: "{{ terraria_home }}/{{ terraria_name }}"
|
|
||||||
argv: [ "bash", "./install-server.sh" ]
|
|
||||||
notify: "restart terraria {{ terraria_name }}"
|
|
||||||
when: download_server is changed
|
|
||||||
- name: configure server settings
|
|
||||||
lineinfile:
|
|
||||||
dest: "{{ terraria_home }}/{{ terraria_name }}/config"
|
|
||||||
line: "{{ item.key }}={{ item.value }}"
|
|
||||||
regex: "^{{ item.key }}=.*"
|
|
||||||
create: yes
|
|
||||||
with_dict: "{{ terraria_config_default | combine(terraria_config) }}"
|
|
||||||
notify: "restart terraria {{ terraria_name }}"
|
|
||||||
become: yes
|
become: yes
|
||||||
become_user: terraria
|
become_user: terraria
|
||||||
- name: enable service
|
|
||||||
systemd: name=terraria@{{ terraria_name }}.service enabled=yes state=started
|
|
||||||
when: terraria_enabled
|
|
||||||
- name: disable service
|
|
||||||
systemd: name=terraria@{{ terraria_name }}.service enabled=no state=stopped
|
|
||||||
when: not terraria_enabled
|
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
#! /bin/sh
|
|
||||||
|
|
||||||
# Find out where our server lives
|
|
||||||
# Ideally, this won't change at all over time. @redigit please keep these
|
|
||||||
# naming conventions
|
|
||||||
directory="server/{{ terraria_version }}/Linux"
|
|
||||||
echo "Syncing from $directory/"
|
|
||||||
|
|
||||||
# Now we rsync everything from that directory here, which should set us up
|
|
||||||
rsync -av "$directory"/ ./
|
|
||||||
|
|
||||||
# I'm not sure if it's just zip being zip or if it's Redigit not packing
|
|
||||||
# them properly, but I've found that the server executables tend to not have
|
|
||||||
# the right permissions
|
|
||||||
echo "Fixing permissions on server binaries"
|
|
||||||
find -maxdepth 1 -type f -iname "terrariaserver*" -exec chmod +x {} +
|
|
@ -11,7 +11,7 @@ After=network.target
|
|||||||
User=terraria
|
User=terraria
|
||||||
Group=terraria
|
Group=terraria
|
||||||
WorkingDirectory={{ terraria_home }}/%i
|
WorkingDirectory={{ terraria_home }}/%i
|
||||||
#EnvironmentFile={{ terraria_home }}/%i/env
|
EnvironmentFile={{ terraria_home }}/%i/env
|
||||||
PrivateUsers=true
|
PrivateUsers=true
|
||||||
ProtectSystem=full
|
ProtectSystem=full
|
||||||
ProtectHome=true
|
ProtectHome=true
|
||||||
@ -22,10 +22,13 @@ ProtectKernelModules=true
|
|||||||
# Implies MountAPIVFS=yes
|
# Implies MountAPIVFS=yes
|
||||||
ProtectControlGroups=true
|
ProtectControlGroups=true
|
||||||
|
|
||||||
ExecStart=/bin/sh -c '/usr/bin/screen -DmS %i ./TerrariaServer.bin.x86_64 -config config'
|
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 "say Server is going down: Service was stopped"\\015'
|
||||||
ExecStop=/usr/bin/screen -p 0 -S %i -X eval 'stuff "exit"\\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
|
Restart=always
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user