Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 4 #17

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ Description of the `teamspeak_network` configuration block and it's options:
* `teamspeak_network.query.port`: TCP port used for ServerQuery connections. Default at TCP port 10011.
* `teamspeak_network.query.ip`: IP address where to listen for inbound ServerQuery connections. Default at 0.0.0.0, which binds any IP address.

#### Database configuration

The database configuration block is for setting the database. Supported: sqlite (default), mariadb. MySQL support has been deprecated from server version 3.0.11.
MariaDB connection only works with a vaild teamspeak license.

Description of the database configuration block and it's options:
* `teamspeak_db_plugin`: Setting the database plugin; Options: sqlite3,mariadb. Default: sqlite3.
__This is only used if the db_plugin is mariadb.__
* `teamspeak_db_ini_filename:` Database configuration file in the teamspeak server folder.
* `teamspeak_db_ini_config.host`: MariaDB Hostname or IP for connection to the database server.
* `teamspeak_db_ini_config.port`: MariaDB Port for hostname connection.
* `teamspeak_db_ini_config.socket`: MariaDB Socket connection instate of hostname:port.
* `teamspeak_db_ini_config.database`: MariaDB TeamSpeak database name.
* `teamspeak_db_ini_config.username`: MariaDB Login username.
* `teamspeak_db_ini_config.password`: MariaDB Login password.


#### Other options

* `teamspeak_ini_machine_id`: Teamspeak server machine ID. Used for running provide multiple instances on the same database with a unique ID. Default is empty.
Expand Down
10 changes: 10 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ teamspeak:
teamspeak_ini_enabled: no
teamspeak_ini_filename: ts3server.ini

teamspeak_db_plugin: sqlite3
teamspeak_db_ini_filename: "ts3db.ini"
teamspeak_db_ini_config:
host: "127.0.0.1"
port: 3306
socket: ""
database: "ts3"
username: "DB_USERNAME"
password: "PASSWORD!@#"

teamspeak_use_license: no
teamspeak_license_srcfile: files/licensekey.dat
teamspeak_licensepath:
Expand Down
12 changes: 12 additions & 0 deletions tasks/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
notify:
- Restart TeamSpeak 3 Server

- block:
- name: "Configuration : Template file for MariaDB Config"
template:
src: ts3db.ini.j2
dest: "{{ ts3server_dir }}/{{ teamspeak_db_ini_filename }}"
mode: 0640
owner: "{{ teamspeak.user }}"
group: "{{ teamspeak.user }}"
notify:
- Restart TeamSpeak 3 Server
when: "teamspeak_db_plugin == 'mariadb'"

- name: "Configuration : Start TeamSpeak 3 Server"
service:
name: teamspeak3-server
Expand Down
8 changes: 6 additions & 2 deletions tasks/install.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
---
# install tasks file for teamspeak

# Start of installation
- name: "Install : MariaDB library"
apt:
name: libmariadb2
state: present
when: "teamspeak_db_plugin == 'mariadb'"

- name: "Install : Create Teamspeak user"
user:
name: "{{ teamspeak.user }}"
Expand Down
13 changes: 10 additions & 3 deletions tasks/ts3update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@
state: stopped
when: ts3_systemd_service.stat.exists

- name: "Update : Copy existing TeamSpeak 3 Server data to new TeamSpeak {{ teamspeak.version }} Server directory"
- name: "Update : Copy existing TeamSpeak 3 Server `files` 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/"
src: "{{ teamspeak.home }}/{{ teamspeak.symlink }}/teamspeak3-server_linux_amd64/files/"
dest: "{{ teamspeak.home }}/teamspeak3-server_linux_amd64-{{ teamspeak.version }}/teamspeak3-server_linux_amd64/files/"
delegate_to: "{{ inventory_hostname }}"
notify:
- Prune older TeamSpeak 3 Server versions

- name: "Update : Copy existing TeamSpeak 3 Server `sqlite` file to new TeamSpeak {{ teamspeak.version }} Server directory"
synchronize:
src: "{{ teamspeak.home }}/{{ teamspeak.symlink }}/teamspeak3-server_linux_amd64/files/ts3server.sqlitedb"
dest: "{{ teamspeak.home }}/teamspeak3-server_linux_amd64-{{ teamspeak.version }}/teamspeak3-server_linux_amd64/files/ts3server.sqlitedb"
delegate_to: "{{ inventory_hostname }}"
when: "teamspeak_db_plugin == 'sqlite3'"

- name: "Update : Make sure ownership is set to {{ teamspeak.user }}"
file:
path: "{{ teamspeak.home }}/teamspeak3-server_linux_amd64-{{ teamspeak.version }}/teamspeak3-server_linux_amd64/"
Expand Down
4 changes: 4 additions & 0 deletions templates/ts3db.ini.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[config]
{% for k,v in teamspeak_db_ini_config.items() %}
{{ k }}={{v}}
{% endfor %}
8 changes: 8 additions & 0 deletions templates/ts3server.ini.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ licensepath={{ teamspeak_licensepath }}/
{% if teamspeak_machine_id is not none %}
machine_id={{ teamspeak_machine_id }}
{% endif %}

{% if teamspeak_db_plugin == 'mariadb' %}
dbplugin=ts3db_mariadb
dbpluginparameter={{ teamspeak_db_ini_filename }}
dbsqlpath=sql/
dbsqlcreatepath=create_mariadb/
query_skipbruteforcecheck=0
{% endif %}