aboutsummaryrefslogtreecommitdiffstats
path: root/tasks/main.yml
blob: e31f3ab285e4344e89f1ecc45208d808e6cb6964 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---

- 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"
      skip: true
      paths:
        - ../vars

- name: "Ensure teamspeak user exists"
  user:
    name: "{{ teamspeak.user }}"
    comment: "{{ teamspeak.comment }}"
    home: "{{ teamspeak.home }}"
    shell: "{{ teamspeak.shell }}"
    system: yes

- name: "Ensure everything is owned by {{ teamspeak.user }}"
  file:
    path: "{{ teamspeak.home }}"
    state: directory
    owner: "{{ teamspeak.user }}"
    group: "{{ teamspeak.user }}"
    recurse: yes

- name: "Check teamspeak server version"
  slurp:
    src: "{{ teamspeak.home }}/VERSION"
  ignore_errors: yes
  register: ts3version

- include_tasks: install.yml
  when: ts3version.content|default(None)|b64decode != teamspeak.version

- name: "Create teamspeak server configuration file"
  template:
    src: ts3server.ini.j2
    dest: "{{ teamspeak.home }}/{{ teamspeak_ini_filename }}"
    mode: 0644
    owner: "{{ teamspeak.user }}"
    group: "{{ teamspeak.user }}"
  when: teamspeak_ini_enabled
  notify:
    - Restart teamspeak server

- name: "Configuration : Create TeamSpeak 3 database server configuration file"
  template:
    src: ts3db_mariadb.ini.j2
    dest: "{{ teamspeak.home }}/ts3db_mariadb.ini"
    mode: 0644
    owner: "{{ teamspeak.user }}"
    group: "{{ teamspeak.user }}"
  notify:
    - Restart teamspeak server
  when: teamspeak_db.plugin == 'ts3db_mariadb'

- name: "Ensure license directory exists"
  file:
    path: "{{ teamspeak_licensepath }}"
    state: directory
  when: teamspeak_licensepath is not none and teamspeak_use_license

- name: "Copy the license file"
  copy:
    src: "{{ teamspeak_license_srcfile }}"
    dest: "{{ teamspeak_licensepath if teamspeak_licensepath is not none else teamspeak.home }}/licensekey.dat"
    owner: "{{ teamspeak.user }}"
    group: "{{ teamspeak.user }}"
    mode: 0400
  when: teamspeak_use_license
  notify:
    - Restart teamspeak server

- name: "Install : Accept license for TeamSpeak {{ teamspeak.version }} server"
  copy:
    dest: "{{ teamspeak.home }}/.ts3server_license_accepted"
    content: ""
    owner: "{{ teamspeak.user }}"
    group: "{{ teamspeak.user }}"
  when: accept_teamspeak_license
  notify:
    - Restart teamspeak server

- name: "Install systemd service file"
  template:
    src: teamspeak3-server.service.j2
    dest: "{{ systemd_service_file_path }}/teamspeak3-server.service"
    mode: 0644
    owner: root
    group: root
  notify:
    - Restart teamspeak server

- name: "Ensure teamspeak server is running and enabled"
  systemd:
    name: teamspeak3-server
    state: started
    enabled: yes
    daemon_reload: yes