ansible/roles/tes3mp/tasks/main.yml

75 lines
2.3 KiB
YAML
Raw Normal View History

2020-08-23 23:12:39 -05:00
#!/usr/bin/ansible-playbook
# vim:ft=ansible:
---
- name: Set up TES3MP
block:
- name: Set up system
block:
2020-08-23 23:38:01 -05:00
- name: Install required packages
apt:
name:
- libluajit-5.1-2
2020-08-23 23:12:39 -05:00
- 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
2020-08-23 23:39:01 -05:00
notify: "restart tes3mp {{ tes3mp.name }}"
2020-08-23 23:12:39 -05:00
- 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
2020-08-23 23:36:20 -05:00
- name: Configure server
template:
src: "{{ item.src }}"
dest: "{{ tes3mp.dest }}/{{ tes3mp.name }}/{{ item.dest }}"
loop:
- { src: "tes3mp-server-default.cfg", dest: "tes3mp-server-default.cfg" }
notify: "restart tes3mp {{ tes3mp.name }}"
become: yes
become_user: tes3mp
2020-08-23 23:12:39 -05:00
- 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