ansible/roles/tes3mp/tasks/main.yml

77 lines
2.4 KiB
YAML

#!/usr/bin/ansible-playbook
# vim:ft=ansible:
---
- name: Set up TES3MP
block:
- name: Set up system
block:
- name: Install required packages
apt:
name:
- libgl1
- libluajit-5.1-2
- name: Create user
user:
name: tes3mp
password: "!"
system: yes
home: "{{ tes3mp.dest }}"
- name: Template out service
template:
src: "tes3mp@.service"
dest: "/etc/systemd/system/tes3mp@.service"
register: t_service
notify: "restart tes3mp {{ tes3mp.name }}"
- name: Reload daemons
systemd:
daemon_reload: yes
when: t_service is changed
- name: Set up TES3MP
block:
- name: Create server directory
file:
path: "{{ tes3mp.dest }}/{{ tes3mp.name }}"
state: directory
owner: tes3mp
group: tes3mp
- name: Download archive
get_url:
dest: "{{ tes3mp.dest }}/{{ tes3mp.name }}-archive.tar.gz"
url: "{{ tes3mp.archive }}"
register: get_archive
- name: Install server
block:
- name: Stop service
systemd:
name: "tes3mp@{{ tes3mp.name }}"
state: stopped
- name: Unpack zip
unarchive:
src: "{{ tes3mp.dest }}/{{ tes3mp.name }}-archive.tar.gz"
remote_src: yes
dest: "{{ tes3mp.dest }}/{{ tes3mp.name }}"
when: get_archive is changed
- name: Configure server
template:
src: "{{ item.src }}"
dest: "{{ tes3mp.dest }}/{{ tes3mp.name }}/TES3MP-server/{{ item.dest }}"
loop:
- { src: "tes3mp-server-default.cfg", dest: "tes3mp-server-default.cfg" }
- { src: "config.lua", dest: "CoreScripts/scripts/config.lua" }
notify: "restart tes3mp {{ tes3mp.name }}"
become: yes
become_user: tes3mp
- name: Set up system
block:
- name: Start and enable service
systemd:
name: "tes3mp@{{ tes3mp.name }}"
enabled: yes
state: started
- name: Template out backup module
template:
src: "backup.sh"
dest: "/opt/backups/modules/tes3mp-{{ tes3mp.name }}.sh"
mode: "0600"
become: yes