diff options
author | Stefan Joosten <stefan@sjoosten.nl> | 2016-07-29 22:37:34 +0200 |
---|---|---|
committer | Stefan Joosten <stefan@sjoosten.nl> | 2016-07-29 22:37:34 +0200 |
commit | 8572c3561235cb6433fd1a43024a6537397a852a (patch) | |
tree | 33e13583081d00b515a8e3abaca08c8bdf4f396a | |
download | ansible-teamspeak-8572c3561235cb6433fd1a43024a6537397a852a.tar.gz ansible-teamspeak-8572c3561235cb6433fd1a43024a6537397a852a.tar.xz ansible-teamspeak-8572c3561235cb6433fd1a43024a6537397a852a.zip |
Initial commit of Ansible teamspeak role.
-rw-r--r-- | .travis.yml | 29 | ||||
-rw-r--r-- | LICENSE | 22 | ||||
-rw-r--r-- | README.md | 50 | ||||
-rw-r--r-- | defaults/main.yml | 10 | ||||
-rw-r--r-- | handlers/main.yml | 2 | ||||
-rw-r--r-- | meta/main.yml | 48 | ||||
-rw-r--r-- | tasks/main.yml | 73 | ||||
-rw-r--r-- | templates/teamspeak3-server.service.j2 | 14 | ||||
-rw-r--r-- | tests/inventory | 1 | ||||
-rw-r--r-- | tests/test.yml | 5 | ||||
-rw-r--r-- | vars/debian.yml | 1 | ||||
-rw-r--r-- | vars/redhat.yml | 1 |
12 files changed, 256 insertions, 0 deletions
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/
\ No newline at end of file @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2016 Dharma Bellamkonda +Copyright (c) 2016 Stefan Joosten + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3d60063 --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +TeamSpeak 3 Server +================== + +Role that deploys a TeamSpeak 3 server. +Inspired by [dharmab/ansible-playbooks/roles/teamspeak](https://github.com/dharmab/ansible-playbooks/tree/master/roles/teamspeak). + +Requirements +------------ + +Tested on Ubuntu 16.04.1. + +Role Variables +-------------- + +defaults/main.yml: + +* teamspeak.user: User to run the teamspeak server. Defaults to "teamspeak". +* teamspeak.comment: User comment field. Defaults to "Teamspeak 3 user". +* teamspeak.home: Home directory for the teamspeak user. Will also be used to install the teamspeak server in. Defaults to "/opt/teamspeak". +* teamspeak.shell: Shell for the teamspeak user. Defaults to "/usr/sbin/nologin". +* teamspeak.version: Version of Teamspeak 3 Server to install. Defaults to "3.0.12.4". +* teamspeak.checksum: "sha256:6bb0e8c8974fa5739b90e1806687128342b3ab36510944f576942e67df7a1bd9" + +vars/{debian,redhat}.yml: + +* systemd_service_file_path: Path where Systemd service files are installed. + +Dependencies +------------ + +No other dependencies I am aware of. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: ts3servers + roles: + - teamspeak + +License +------- + +MIT + +Author Information +------------------ + +Stefan Joosten <stefan@sjoosten.nl> diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..3e1fe6b --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,10 @@ +--- +# defaults file for teamspeak + +teamspeak: + user: "teamspeak" + comment: "Teamspeak 3 user" + home: "/opt/teamspeak" + shell: "/usr/sbin/nologin" + version: "3.0.12.4" + checksum: "sha256:6bb0e8c8974fa5739b90e1806687128342b3ab36510944f576942e67df7a1bd9" diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..92da673 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for teamspeak diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..4ab83aa --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,48 @@ +galaxy_info: + author: your name + description: your description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Some suggested licenses: + # - BSD (default) + # - MIT + # - GPLv2 + # - GPLv3 + # - Apache + # - CC-BY + license: license (GPLv2, CC-BY, etc) + + min_ansible_version: 1.2 + + # Optionally specify the branch Galaxy will use when accessing the GitHub + # repo for this role. During role install, if no tags are available, + # Galaxy will use this branch. During import Galaxy will access files on + # this branch. If travis integration is cofigured, only notification for this + # branch will be accepted. Otherwise, in all cases, the repo's default branch + # (usually master) will be used. + #github_branch: + + # + # Below are all platforms currently available. Just uncomment + # the ones that apply to your role. If you don't see your + # platform on this list, let us know and we'll get it added! + # + #platforms: + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is + # a keyword that describes and categorizes the role. + # Users find roles by searching for tags. Be sure to + # remove the '[]' above if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of + # alphanumeric characters. Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. + # Be sure to remove the '[]' above if you add dependencies + # to this list.
\ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..557fe01 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,73 @@ +--- +# tasks file for teamspeak + +- 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" + - main.yml + paths: + - ../vars + tags: + - teamspeak + +- name: Create Teamspeak user + user: + name: "{{ teamspeak.user }}" + comment: "{{ teamspeak.comment }}" + home: "{{ teamspeak.home }}" + shell: "{{ teamspeak.shell }}" + system: yes + tags: + - teamspeak + +- name: Download TeamSpeak 3 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" + checksum: "{{ teamspeak.checksum }}" + owner: "{{ teamspeak.user }}" + group: "{{ teamspeak.user }}" + tags: + - teamspeak + +- name: Create TeamSpeak 3 server directory + file: + path: "{{ teamspeak.home}}/teamspeak3-server_linux_amd64-{{ teamspeak.version }}" + state: directory + owner: "{{ teamspeak.user }}" + group: "{{ teamspeak.user }}" + tags: + - teamspeak + +- name: Extract TeamSpeak 3 server files + unarchive: + copy: no + src: "{{ teamspeak.home }}/teamspeak3-server_linux_amd64-{{ teamspeak.version }}.tar.bz2" + dest: "{{ teamspeak.home }}/teamspeak3-server_linux_amd64-{{ teamspeak.version }}/" + creates: "{{ teamspeak.home }}/teamspeak3-server_linux_amd64-{{ teamspeak.version }}/teamspeak3-server_linux_amd64" + owner: "{{ teamspeak.user }}" + group: "{{ teamspeak.user }}" + tags: + - teamspeak + +- name: Add TeamSpeak 3 systemctl service file + template: + src: teamspeak3-server.service.j2 + dest: "{{ systemd_service_file_path }}/teamspeak3-server.service" + mode: 0644 + owner: root + group: root + tags: + - teamspeak + +- name: Enable and start TeamSpeak 3 server + service: + name: teamspeak3-server + state: started + enabled: yes + tags: + - teamspeak diff --git a/templates/teamspeak3-server.service.j2 b/templates/teamspeak3-server.service.j2 new file mode 100644 index 0000000..a5a1d42 --- /dev/null +++ b/templates/teamspeak3-server.service.j2 @@ -0,0 +1,14 @@ +[Unit] +Description=TeamSpeak3 Server +After=network.target + +[Service] +Type=simple +User={{ teamspeak.user }} +Group={{ teamspeak.user }} +WorkingDirectory={{ teamspeak.home }}/teamspeak3-server_linux_amd64-{{ teamspeak.version }}/teamspeak3-server_linux_amd64 +Environment='LD_LIBRARY_PATH="{{ teamspeak.home }}/teamspeak3-server_linux_amd64-{{ teamspeak.version }}/teamspeak3-server_linux_amd64/:$LD_LIBRARY_PATH"' +ExecStart={{ teamspeak.home }}/teamspeak3-server_linux_amd64-{{ teamspeak.version }}/teamspeak3-server_linux_amd64/ts3server_minimal_runscript.sh + +[Install] +WantedBy=multi-user.target diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..d18580b --- /dev/null +++ b/tests/inventory @@ -0,0 +1 @@ +localhost
\ No newline at end of file diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..c8286a1 --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - teamspeak diff --git a/vars/debian.yml b/vars/debian.yml new file mode 100644 index 0000000..7814ed4 --- /dev/null +++ b/vars/debian.yml @@ -0,0 +1 @@ +systemd_service_file_path: "/lib/systemd/system/" diff --git a/vars/redhat.yml b/vars/redhat.yml new file mode 100644 index 0000000..d5f56bc --- /dev/null +++ b/vars/redhat.yml @@ -0,0 +1 @@ +systemd_service_file_path: "/usr/lib/systemd/system/" |