aboutsummaryrefslogtreecommitdiffstats
path: root/tasks/main.yml
blob: b5dded69eee8f99ae3a9cc4bed13d18242b53d38 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
# tasks file for teamspeak

- name: "Load OS specific variables"
  include_vars: "{{ item }}"
  with_first_found: 
    - files: 
        - "{{ ansible_distribution|lower }}.yml"
        - "{{ ansible_os_family|lower }}.yml"
        - "{{ ansible_system|lower }}.yml"
        - main.yml
      paths: 
        - ../vars

# Installation of TeamSpeak 3 Server 
- include: install.yml

# Store the TeamSpeak 3 Server directory in a short variable
- name: "Set TeamSpeak 3 Server directory fact"
  set_fact:
    ts3server_dir: "{{ teamspeak.home }}/{{ teamspeak.symlink }}/teamspeak3-server_linux_amd64"

# License file management
  # Install a license file 
- include: install_license.yml
  when: teamspeak_use_license

  # Remove a possible leftover license file when teamspeak_use_license is disabled.
  # The default is to look for it in the TeamSpeak 3 Server directory, so
  # we remove it there if the option has been disabled.
- name: "License : Clean up license in TeamSpeak 3 Server directory if needed"
  file:
    path: "{{ ts3server_dir }}/licensekey.dat"
    state: absent
  when: not teamspeak_use_license
# End of license file management

# Configuration of TeamSpeak 3 Server (if requested)
  # Create configuration file
- include: config.yml
  when: teamspeak_ini_enabled

  # Clean-up a lingering configuration file if we don't need it anymore
- name: "Configuration : Clean-up old configuration file if needed"
  file:
    path: "{{ teamspeak.home }}/{{ teamspeak.symlink }}/teamspeak3-server_linux_amd64/{{ teamspeak_ini_filename }}"
    state: absent
  when: not teamspeak_ini_enabled
# End of configuration

# Restore from backups if they exist
- include: restore_backup.yml
  when: userdata.stat is defined and userdata.stat.exists == False

# Perform the running of handlers now
# So we can do "Reload systemd" (and possibly queued clean-up) 
# before we start using the new/changed .service file.
- meta: flush_handlers
# Make sure TeamSpeak 3 Server is started and enabled
- name: Enable and start TeamSpeak 3 Server
  service:
    name: teamspeak3-server
    state: started
    enabled: yes

# Display Teamspeak 3 Server Token and Password if this is a new installation
# (a new installation has no userdata, and this is checked for in install.yml)
- include: display.yml
  when: userdata.stat is defined and userdata.stat.exists == False