From c74b5981999a604c8e5500914091c5b86f87daaa Mon Sep 17 00:00:00 2001 From: juwi Date: Sun, 15 Nov 2020 17:03:13 +0100 Subject: [PATCH] initial draft for adding stun server deployment --- roles/stunserver/defaults/main.yml | 9 ++++ roles/stunserver/handlers/main.yml | 2 + roles/stunserver/meta/main.yml | 53 +++++++++++++++++++ .../tasks/install-stunserver-debian.yml | 11 ++++ .../tasks/install-stunserver-redhat.yml | 16 ++++++ .../tasks/install-stunserver-ubuntu.yml | 11 ++++ roles/stunserver/tasks/main.yml | 11 ++++ roles/stunserver/templates/stun.j2 | 21 ++++++++ roles/stunserver/tests/inventory | 2 + roles/stunserver/tests/test.yml | 5 ++ roles/stunserver/vars/main.yml | 2 + 11 files changed, 143 insertions(+) create mode 100644 roles/stunserver/defaults/main.yml create mode 100644 roles/stunserver/handlers/main.yml create mode 100644 roles/stunserver/meta/main.yml create mode 100644 roles/stunserver/tasks/install-stunserver-debian.yml create mode 100644 roles/stunserver/tasks/install-stunserver-redhat.yml create mode 100644 roles/stunserver/tasks/install-stunserver-ubuntu.yml create mode 100644 roles/stunserver/tasks/main.yml create mode 100644 roles/stunserver/templates/stun.j2 create mode 100644 roles/stunserver/tests/inventory create mode 100644 roles/stunserver/tests/test.yml create mode 100644 roles/stunserver/vars/main.yml diff --git a/roles/stunserver/defaults/main.yml b/roles/stunserver/defaults/main.yml new file mode 100644 index 0000000..888b9f5 --- /dev/null +++ b/roles/stunserver/defaults/main.yml @@ -0,0 +1,9 @@ +--- +# defaults file for stunserver +stun_start_daemon: true +stun_daemon_opts: "" +stun_primary_ip: "" +stun_secondary_ip: "" +stun_primary_port: 3478 +stun_secondary_port: 3479 +stun_daemon_user: nobody diff --git a/roles/stunserver/handlers/main.yml b/roles/stunserver/handlers/main.yml new file mode 100644 index 0000000..34870d7 --- /dev/null +++ b/roles/stunserver/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for stunserver \ No newline at end of file diff --git a/roles/stunserver/meta/main.yml b/roles/stunserver/meta/main.yml new file mode 100644 index 0000000..227ad9c --- /dev/null +++ b/roles/stunserver/meta/main.yml @@ -0,0 +1,53 @@ +galaxy_info: + author: your name + description: your role 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 + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.9 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + 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/roles/stunserver/tasks/install-stunserver-debian.yml b/roles/stunserver/tasks/install-stunserver-debian.yml new file mode 100644 index 0000000..5024cdc --- /dev/null +++ b/roles/stunserver/tasks/install-stunserver-debian.yml @@ -0,0 +1,11 @@ +--- + +- name: Install STUN server package + package: + name: stunserver + state: present + +- name: Configure STUN Server + template: + src: stun.j2 + dest: /etc/defaults/stun diff --git a/roles/stunserver/tasks/install-stunserver-redhat.yml b/roles/stunserver/tasks/install-stunserver-redhat.yml new file mode 100644 index 0000000..42b1a30 --- /dev/null +++ b/roles/stunserver/tasks/install-stunserver-redhat.yml @@ -0,0 +1,16 @@ +--- + +- name: Install EPEL + package: + name: epel-release + state: present + +- name: Install STUN Server + package: + name: stun-server + state: present + +- name: Configure STUN Server + template: + src: stun.j2 + dest: /etc/sysconfig/stun diff --git a/roles/stunserver/tasks/install-stunserver-ubuntu.yml b/roles/stunserver/tasks/install-stunserver-ubuntu.yml new file mode 100644 index 0000000..5024cdc --- /dev/null +++ b/roles/stunserver/tasks/install-stunserver-ubuntu.yml @@ -0,0 +1,11 @@ +--- + +- name: Install STUN server package + package: + name: stunserver + state: present + +- name: Configure STUN Server + template: + src: stun.j2 + dest: /etc/defaults/stun diff --git a/roles/stunserver/tasks/main.yml b/roles/stunserver/tasks/main.yml new file mode 100644 index 0000000..dc27cf9 --- /dev/null +++ b/roles/stunserver/tasks/main.yml @@ -0,0 +1,11 @@ +--- + + +- name: Install Stun Server + include_tasks: "install-stunserver-{{ ansible_os_family | lower }}.yml" + +- name: Start STUN Server + systemd: + name: stun + enabled: true + state: started \ No newline at end of file diff --git a/roles/stunserver/templates/stun.j2 b/roles/stunserver/templates/stun.j2 new file mode 100644 index 0000000..064db90 --- /dev/null +++ b/roles/stunserver/templates/stun.j2 @@ -0,0 +1,21 @@ +# Defaults for stun initscript +# sourced by /etc/init.d/stun +# installed at /etc/default/stun by the maintainer scripts + +# +# This is a POSIX shell fragment +# + +#uncommment the next line to allow the init.d script to start the stun daemon +START_DAEMON={{ stun_start_daemon }} + +# Additional options that are passed to the Daemon. +DAEMON_OPTS="{{ stun_daemon_opts }}" + +PRIMARY_IP="{{ stun_primary_ip }}" +SECONDARY_IP="{{ stun_secondary_ip }}" +PRIMARY_PORT={{ stun_primary_port }} +SECONDARY_PORT={{ stun_seconday_port }} + +# whom the daemons should run as +DAEMON_USER={{ stun_daemon_user }} \ No newline at end of file diff --git a/roles/stunserver/tests/inventory b/roles/stunserver/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/stunserver/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/stunserver/tests/test.yml b/roles/stunserver/tests/test.yml new file mode 100644 index 0000000..97fe9d0 --- /dev/null +++ b/roles/stunserver/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - stunserver \ No newline at end of file diff --git a/roles/stunserver/vars/main.yml b/roles/stunserver/vars/main.yml new file mode 100644 index 0000000..46d48ad --- /dev/null +++ b/roles/stunserver/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for stunserver \ No newline at end of file