diff options
author | Stefan Joosten <stefan@sjoosten.nl> | 2016-08-25 16:21:09 +0200 |
---|---|---|
committer | Stefan Joosten <stefan@sjoosten.nl> | 2016-08-25 16:21:09 +0200 |
commit | b331fee529dc21d54b3a495d6fa68029a3920648 (patch) | |
tree | 1711f4d4f76f4b47b618cfa613d0ec7cad3b1941 | |
parent | 819bb41873e49c520fc4506dfc00d46b6e849f44 (diff) | |
download | ansible-teamspeak-b331fee529dc21d54b3a495d6fa68029a3920648.tar.gz ansible-teamspeak-b331fee529dc21d54b3a495d6fa68029a3920648.tar.xz ansible-teamspeak-b331fee529dc21d54b3a495d6fa68029a3920648.zip |
Add logic to install a TeamSpeak 3 Server License file to the target host. Fixes issue #3.
-rw-r--r-- | defaults/main.yml | 5 | ||||
-rw-r--r-- | tasks/install_license.yml | 18 | ||||
-rw-r--r-- | tasks/main.yml | 26 | ||||
-rw-r--r-- | templates/ts3server.ini.j2 | 11 |
4 files changed, 52 insertions, 8 deletions
diff --git a/defaults/main.yml b/defaults/main.yml index a4ff7e4..3036c26 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -14,6 +14,9 @@ teamspeak: teamspeak_ini_enabled: no teamspeak_ini_filename: ts3server.ini +teamspeak_use_license: no +teamspeak_licensepath: + teamspeak_network: voice: default_port: 9987 @@ -25,5 +28,5 @@ teamspeak_network: port: 10011 ip: 0.0.0.0 -teamspeak_machine_id: teamspeak_create_default_virtualserver: yes +teamspeak_machine_id: diff --git a/tasks/install_license.yml b/tasks/install_license.yml new file mode 100644 index 0000000..b54b551 --- /dev/null +++ b/tasks/install_license.yml @@ -0,0 +1,18 @@ +--- +# License install tasks for role teamspeak + +- name: "License : Create directory for license" + file: + path: "{{ teamspeak_licensepath }}" + state: directory + when: teamspeak_licensepath is not none + +- name: "License : Copy the license file" + copy: + src: licensekey.dat + dest: "{{ teamspeak_licensepath if teamspeak_licensepath is not none else ts3server_dir }}/licensekey.dat" + owner: "{{ teamspeak.user }}" + group: "{{ teamspeak.user }}" + mode: 0400 + notify: + - Restart TeamSpeak 3 Server diff --git a/tasks/main.yml b/tasks/main.yml index 0eaa630..9e619fc 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -15,16 +15,38 @@ # 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: Clean-up configuration + # 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 # Perform the running of handlers now # So we can do "Reload systemd" (and possibly queued clean-up) diff --git a/templates/ts3server.ini.j2 b/templates/ts3server.ini.j2 index 6c3f341..e92691c 100644 --- a/templates/ts3server.ini.j2 +++ b/templates/ts3server.ini.j2 @@ -1,7 +1,3 @@ -{% if teamspeak_machine_id is not none %} -machine_id={{ teamspeak_machine_id }} -{% endif %} - default_voice_port={{ teamspeak_network.voice.default_port }} voice_ip={{ teamspeak_network.voice.ip }} filetransfer_port={{ teamspeak_network.filetransfer.port }} @@ -12,4 +8,9 @@ query_ip={{ teamspeak_network.query.ip }} {% if teamspeak_create_default_virtualserver %} create_default_virtualserver=1 {% endif %} - +{% if teamspeak_use_license and teamspeak_licensepath is not none %} +licensepath={{ teamspeak_licensepath }}/ +{% endif %} +{% if teamspeak_machine_id is not none %} +machine_id={{ teamspeak_machine_id }} +{% endif %} |