2020-05-15 10:11:32 -05:00
|
|
|
#!/usr/bin/ansible-playbook
|
|
|
|
# vim:ft=ansible:
|
|
|
|
---
|
|
|
|
- name: Set up Terraria user
|
|
|
|
block:
|
|
|
|
- name: Install required packages
|
|
|
|
apt:
|
|
|
|
name:
|
|
|
|
- mono-complete
|
|
|
|
- name: Assure terraria admin group
|
|
|
|
group:
|
|
|
|
name: ter-admin
|
|
|
|
- name: Assure server user
|
|
|
|
user:
|
|
|
|
name: terraria
|
|
|
|
group: ter-admin
|
|
|
|
system: yes
|
|
|
|
home: "{{ terraria_root }}"
|
|
|
|
- name: Assure var directory
|
|
|
|
file:
|
|
|
|
path: "{{ terraria_root }}"
|
|
|
|
state: directory
|
|
|
|
owner: root
|
2020-05-15 10:40:14 -05:00
|
|
|
group: ter-admin
|
2020-05-15 10:11:32 -05:00
|
|
|
# Sticky, SetGID
|
|
|
|
mode: "3770"
|
|
|
|
- name: Assure systemd unit
|
|
|
|
template:
|
|
|
|
src: "terraria@.service"
|
|
|
|
dest: "/etc/systemd/system/terraria@.service"
|
|
|
|
- name: Reload available daemons
|
|
|
|
systemd:
|
|
|
|
daemon_reload: yes
|
|
|
|
become: yes
|
|
|
|
- name: Set up Terraria server
|
|
|
|
block:
|
|
|
|
- name: Create server directory
|
|
|
|
file:
|
|
|
|
path: "{{ terraria_root }}/{{ terraria_name }}"
|
|
|
|
state: directory
|
|
|
|
- name: Check for existing install
|
|
|
|
stat:
|
|
|
|
path: "{{ terraria_root }}/{{ terraria_name }}/TerrariaServer"
|
|
|
|
register: stat_server_binary
|
|
|
|
- name: Unpack archive
|
|
|
|
block:
|
|
|
|
- name: Download zip
|
|
|
|
get_url:
|
|
|
|
dest: "{{ terraria_root }}/{{ terraria_name }}/pack.zip"
|
|
|
|
url: "{{ terraria_zip }}"
|
|
|
|
- name: Unpack zip
|
|
|
|
unarchive:
|
|
|
|
src: "{{ terraria_root }}/{{ terraria_name }}/pack.zip"
|
|
|
|
remote_src: yes
|
|
|
|
dest: "{{ terraria_root }}/{{ terraria_name }}"
|
|
|
|
- name: Move zip contents
|
|
|
|
shell: mv "{{ terraria_root }}/{{ terraria_name }}/Dedicated Server/*" "{{ terraria_root }}/{{ terraria_name }}"
|
2020-05-15 10:49:42 -05:00
|
|
|
- name: Create worlds directory
|
|
|
|
file:
|
|
|
|
path: "{{ terraria_root }}/{{ terraria_name }}/worlds"
|
|
|
|
owner: terraria
|
|
|
|
group: ter-admin
|
|
|
|
state: directory
|
2020-05-15 10:11:32 -05:00
|
|
|
when: not stat_server_binary.stat.exists
|
|
|
|
- name: Configure server
|
|
|
|
block:
|
|
|
|
- name: Template out server config
|
|
|
|
template:
|
|
|
|
src: config
|
|
|
|
dest: "{{ terraria_root }}/{{ terraria_name }}/config"
|
|
|
|
become: yes
|
|
|
|
- name: Enable service
|
|
|
|
systemd:
|
|
|
|
name: "terraria@{{ terraria_name }}"
|
|
|
|
daemon_reload: yes
|
|
|
|
enabled: yes
|
|
|
|
state: started
|
|
|
|
become: yes
|