diff --git a/README.md b/README.md index acb794e..b58c4f6 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/defaults/main.yml b/defaults/main.yml index 87c429f..b630cae 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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: diff --git a/tasks/config.yml b/tasks/config.yml index 8550d01..ea83f8e 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -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 diff --git a/tasks/install.yml b/tasks/install.yml index afd4c8b..e645a11 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -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 }}" diff --git a/tasks/ts3update.yml b/tasks/ts3update.yml index e5eda4c..9dd6285 100644 --- a/tasks/ts3update.yml +++ b/tasks/ts3update.yml @@ -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/" diff --git a/templates/ts3db.ini.j2 b/templates/ts3db.ini.j2 new file mode 100644 index 0000000..02f69ce --- /dev/null +++ b/templates/ts3db.ini.j2 @@ -0,0 +1,4 @@ +[config] +{% for k,v in teamspeak_db_ini_config.items() %} +{{ k }}={{v}} +{% endfor %} diff --git a/templates/ts3server.ini.j2 b/templates/ts3server.ini.j2 index 0f434fa..675c3ae 100644 --- a/templates/ts3server.ini.j2 +++ b/templates/ts3server.ini.j2 @@ -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 %}