diff options
author | Stefan Joosten <stefan@sjoosten.nl> | 2016-08-26 00:31:49 +0200 |
---|---|---|
committer | Stefan Joosten <stefan@sjoosten.nl> | 2016-08-26 00:31:49 +0200 |
commit | 9f7b61ea916c73b556d19b5c1d982ea9e5fb007f (patch) | |
tree | 84c0ad246251245224e63de848742625d878f481 | |
parent | be6b41e5c246d4c249c3d068b543a0f97326f3ac (diff) | |
parent | 7ef374edd6f40c1d8a754fdd58dba22efb707932 (diff) | |
download | ansible-teamspeak-9f7b61ea916c73b556d19b5c1d982ea9e5fb007f.tar.gz ansible-teamspeak-9f7b61ea916c73b556d19b5c1d982ea9e5fb007f.tar.xz ansible-teamspeak-9f7b61ea916c73b556d19b5c1d982ea9e5fb007f.zip |
Merge branch 'issue3'
Add the functionality to include a TeamSpeak 3 Server license file.
Close issue #3
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | README.md | 12 | ||||
-rw-r--r-- | defaults/main.yml | 6 | ||||
-rw-r--r-- | tasks/config.yml | 5 | ||||
-rw-r--r-- | tasks/install.yml | 14 | ||||
-rw-r--r-- | tasks/install_license.yml | 18 | ||||
-rw-r--r-- | tasks/main.yml | 26 | ||||
-rw-r--r-- | tasks/ts3update.yml | 8 | ||||
-rw-r--r-- | templates/ts3server.ini.j2 | 11 |
9 files changed, 76 insertions, 26 deletions
@@ -1,2 +1,2 @@ *.swp - +files/licensekey.dat @@ -33,7 +33,7 @@ These variables define properties for the user thats going to run the TeamSpeak * `teamspeak.symlink`: Name of symlink to point to current TeamSpeak 3 server directory. Defaults to "current". * `teamspeak.version`: Version of Teamspeak 3 Server to install. Defaults to "3.0.12.4". * `teamspeak.checksum`: SHA256 checksum of archive of TeamSpeak 3 server version for verification purposes. Example: "sha256:6bb0e8c8974fa5739b90e1806687128342b3ab36510944f576942e67df7a1bd9" -* `teamspeak.keep`: Amount of TeamSpeak 3 server versions to keep installed, includes the currently installed version. A setting of "3" keeps the current and two previous version installed, which is the default. In case an upgrade goes wrong, you simply rewind the `teamspeak.version` and `teamspeak.checksum` to the older version and run the role again to downgrade back to a known good. +* `teamspeak.keep`: Amount of TeamSpeak 3 server versions to keep installed, includes the currently installed version. A setting of "2" keeps the current and two previous version installed, which is the default. In case an upgrade goes wrong, you simply rewind the `teamspeak.version` and `teamspeak.checksum` to the older version and run the role again to downgrade back to a known good. ### Further configuraton To configure TeamSpeak 3 Server a INI-style configuration file is used. If you require detailed configuration, enable creation of such a file by setting the `teamspeak_ini_enabled` to `yes`. For example by defining it that way in host or group vars in your playbook. A INI file containing your configuration will be created. @@ -41,9 +41,17 @@ To configure TeamSpeak 3 Server a INI-style configuration file is used. If you r * `teamspeak_ini_enabled`: Set to `yes` if you want use the configuration options listed below. It will create INI-style configuration file for the TeamSpeak 3 Server to use. Defaults to `no`. * `teamspeak_ini_filename`: Name of the INI-style configuration file. Defaults to `ts3server.ini`. +#### License file + +If you have a TeamSpeak 3 Server license, you can have this role install it for you. Place your license file called `licensekey.dat` in the `files/` directory of this role. Tip: if you use Git, add that path to your `.gitignore` to make sure you do not push it somewhere by accident. + +* `teamspeak_use_license`: Set to `yes` to have your license set up. Default is `no`. +* `teamspeak_license_srcfile`: TeamSpeak 3 Server license file on Ansible host to copy to target. Default searches for the license file at `files/licensekey.dat` +* `teamspeak_licensepath`: Used to specify a directory where your license should be located on the target host. If a non-existent directory is specified it will be created for you. Make sure you enable the use of a INI configuration file, otherwise this option will be ineffective. The default is to leave this variable empty, which will place the license file in the same directory as the TeamSpeak 3 Server is installed in. + #### Network configuration -The following configuration blocks can be used to configure the TeamSpeak 3 Server as you please. Make sure to define the configuration blocks in full as they contain nested properties. Most reliable way would be to copy a block from the `defaults/main.yml` into your own definitions file and edit accordingly. +The network configuration block can be used to configure the TeamSpeak 3 Server as you please. Make sure to define the configuration block in full as it contains nested properties. Most reliable way would be to copy a block from the `defaults/main.yml` into your own definitions file and edit accordingly. Description of the `teamspeak_network` configuration block and it's options: diff --git a/defaults/main.yml b/defaults/main.yml index 3b36967..1a5cb49 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -14,6 +14,10 @@ teamspeak: teamspeak_ini_enabled: no teamspeak_ini_filename: ts3server.ini +teamspeak_use_license: no +teamspeak_license_srcfile: files/licensekey.dat +teamspeak_licensepath: + teamspeak_network: voice: default_port: 9987 @@ -25,5 +29,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/config.yml b/tasks/config.yml index 3e9f003..3a9035a 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -1,10 +1,7 @@ --- # configuration tasks for teamspeak -- name: Set TeamSpeak 3 Server directory fact - set_fact: - ts3server_dir: "{{ teamspeak.home }}/{{ teamspeak.symlink }}/teamspeak3-server_linux_amd64" -- name: Create TeamSpeak 3 Server configuration file +- name: "Configuration : Create TeamSpeak 3 Server configuration file" template: src: ts3server.ini.j2 dest: "{{ ts3server_dir }}/{{ teamspeak_ini_filename }}" diff --git a/tasks/install.yml b/tasks/install.yml index 1dcebb2..afd4c8b 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -2,7 +2,7 @@ # install tasks file for teamspeak # Start of installation -- name: Create Teamspeak user +- name: "Install : Create Teamspeak user" user: name: "{{ teamspeak.user }}" comment: "{{ teamspeak.comment }}" @@ -10,7 +10,7 @@ shell: "{{ teamspeak.shell }}" system: yes -- name: Download TeamSpeak {{ teamspeak.version }} Server files +- name: "Install : Download TeamSpeak {{ teamspeak.version }} Server files" get_url: url: "http://dl.4players.de/ts/releases/{{ teamspeak.version }}/teamspeak3-server_linux_amd64-{{ teamspeak.version }}.tar.bz2" dest: "{{ teamspeak.home }}/teamspeak3-server_linux_amd64-{{ teamspeak.version }}.tar.bz2" @@ -18,7 +18,7 @@ owner: "{{ teamspeak.user }}" group: "{{ teamspeak.user }}" -- name: Create TeamSpeak {{ teamspeak.version }} Server directory +- name: "Install : Create TeamSpeak {{ teamspeak.version }} Server directory" file: path: "{{ teamspeak.home }}/teamspeak3-server_linux_amd64-{{ teamspeak.version }}" state: directory @@ -27,7 +27,7 @@ register: mkdir # If a new directory has been created, check for (current) user data. -- name: Checking for a currently installed TeamSpeak 3 Server with user data +- name: "Install : Checking for a currently installed TeamSpeak 3 Server with user data" stat: path: "{{ teamspeak.home }}/{{ teamspeak.symlink }}/teamspeak3-server_linux_amd64/files" register: userdata @@ -38,7 +38,7 @@ when: userdata.stat.exists is defined and userdata.stat.exists == True # Created a new directory? Extract the files into it. Overwrites existing. -- name: Extract TeamSpeak {{ teamspeak.version }} Server files +- name: "Install : Extract TeamSpeak {{ teamspeak.version }} Server files" unarchive: copy: no src: "{{ teamspeak.home }}/teamspeak3-server_linux_amd64-{{ teamspeak.version }}.tar.bz2" @@ -47,7 +47,7 @@ group: "{{ teamspeak.user }}" when: mkdir.changed -- name: Create/Update symlink to TeamSpeak {{ teamspeak.version }} Server +- name: "Install : Create/Update symlink to TeamSpeak {{ teamspeak.version }} Server" file: src: "{{ teamspeak.home }}/teamspeak3-server_linux_amd64-{{ teamspeak.version }}" dest: "{{ teamspeak.home }}/{{ teamspeak.symlink }}" @@ -57,7 +57,7 @@ notify: - Restart TeamSpeak 3 Server -- name: Install TeamSpeak 3 systemctl service file +- name: "Install : Install TeamSpeak 3 systemctl service file" template: src: teamspeak3-server.service.j2 dest: "{{ systemd_service_file_path }}/teamspeak3-server.service" diff --git a/tasks/install_license.yml b/tasks/install_license.yml new file mode 100644 index 0000000..25c9365 --- /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: "{{ teamspeak_license_srcfile }}" + 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/tasks/ts3update.yml b/tasks/ts3update.yml index 2d5587f..e5eda4c 100644 --- a/tasks/ts3update.yml +++ b/tasks/ts3update.yml @@ -1,18 +1,18 @@ --- # tasks file for teamspeak -- name: Check if a TeamSpeak 3 Server systemd service unit exists +- name: "Update : Check if a TeamSpeak 3 Server systemd service unit exists" stat: path: "{{ systemd_service_file_path }}/teamspeak3-server.service" register: ts3_systemd_service -- name: Stop currently running TeamSpeak 3 Server instance +- name: "Update : Stop currently running TeamSpeak 3 Server instance" service: name: teamspeak3-server state: stopped when: ts3_systemd_service.stat.exists -- name: Copy existing TeamSpeak 3 Server data to new TeamSpeak {{ teamspeak.version }} Server directory +- name: "Update : Copy existing TeamSpeak 3 Server data to new TeamSpeak {{ teamspeak.version }} Server directory" synchronize: src: "{{ teamspeak.home }}/{{ teamspeak.symlink }}/teamspeak3-server_linux_amd64/" dest: "{{ teamspeak.home }}/teamspeak3-server_linux_amd64-{{ teamspeak.version }}/teamspeak3-server_linux_amd64/" @@ -20,7 +20,7 @@ notify: - Prune older TeamSpeak 3 Server versions -- name: Make sure ownership is set to {{ teamspeak.user }} +- name: "Update : Make sure ownership is set to {{ teamspeak.user }}" file: path: "{{ teamspeak.home }}/teamspeak3-server_linux_amd64-{{ teamspeak.version }}/teamspeak3-server_linux_amd64/" state: directory 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 %} |