From 559039768e0b85e530261a46109d51d6dc1b53c4 Mon Sep 17 00:00:00 2001 From: silverwizard Date: Sun, 8 Nov 2020 12:43:53 -0500 Subject: [PATCH] First commit --- .gitignore | 3 ++ .travis.yml | 29 ++++++++++++++ LICENSE | 14 +++++++ README.md | 3 ++ defaults/main.yml | 2 + handlers/main.yml | 2 + meta/main.yml | 60 ++++++++++++++++++++++++++++ tasks/install-asterisk.sh.j2 | 45 +++++++++++++++++++++ tasks/main.yml | 77 ++++++++++++++++++++++++++++++++++++ templates/selinux.j2 | 11 ++++++ tests/inventory | 2 + tests/test.yml | 5 +++ vars/main.yml | 2 + 13 files changed, 255 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 defaults/main.yml create mode 100644 handlers/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/install-asterisk.sh.j2 create mode 100644 tasks/main.yml create mode 100644 templates/selinux.j2 create mode 100644 tests/inventory create mode 100644 tests/test.yml create mode 100644 vars/main.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5c199eb --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# ---> Ansible +*.retry + 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 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9c31dda --- /dev/null +++ b/LICENSE @@ -0,0 +1,14 @@ +DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + +Version 2, December 2004 + +Copyright (C) 2004 Sam Hocevar + +Everyone is permitted to copy and distribute verbatim or modified copies of +this license document, and changing it is allowed as long as the name is changed. + +DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/README.md b/README.md new file mode 100644 index 0000000..0cbc7d8 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# freepbx_ansible + +Ansible role for deploying Verdexus freepbx \ No newline at end of file diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..e58b92b --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for verdexus-asterisk \ No newline at end of file diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..028ea40 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for verdexus-asterisk \ No newline at end of file diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..5d50bf4 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,60 @@ +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: 2.4 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # 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 configured, only notifications for this + # branch will be accepted. Otherwise, in all cases, the repo's default branch + # (usually master) will be used. + #github_branch: + + # + # 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/tasks/install-asterisk.sh.j2 b/tasks/install-asterisk.sh.j2 new file mode 100644 index 0000000..7d0ac5f --- /dev/null +++ b/tasks/install-asterisk.sh.j2 @@ -0,0 +1,45 @@ +#Get stuff from the internet +cd /tmp +wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz +wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz +wget -O jansson.tar.gz https://github.com/akheron/jansson/archive/v2.10.tar.gz +wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz + +#Compile and Install DAHDI +cd /usr/src +tar xvfz /tmp/dahdi-linux-complete-current.tar.gz +tar xvfz /tmp/libpri-current.tar.gz +rm -f /tmp/dahdi-linux-complete-current.tar.gz /tmp/libpri-current.tar.gz +cd dahdi-linux-complete-* +make all +make install +make config +cd /usr/src/libpri-* +make +make install + +#Compile and Install jansson +cd /usr/src +tar vxfz /tmp/jansson.tar.gz +rm -f /tmp/jansson.tar.gz +cd jansson-* +autoreconf -i +./configure --libdir=/usr/lib64 +make +make install + +#Compile and install Asterisk +cd /usr/src +tar xvfz /tmp/asterisk-16-current.tar.gz +rm -f /tmp/asterisk-16-current.tar.gz +cd asterisk-* +contrib/scripts/install_prereq install +./configure --libdir=/usr/lib64 --with-pjproject-bundled +contrib/scripts/get_mp3_source.sh +make full + +make +make install +make config +ldconfig +chkconfig asterisk off diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..09ed117 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,77 @@ +--- +- name: disable selinux :( + template: + src: selinux.j2 + dest: /etc/sysconfig/selinux + +- name: disable selinux :( + template: + src: selinux.j2 + dest: /etc/selinux/config + +- name: reboot if needed + reboot: + reboot_timeout: 3600 + when: ansible_selinux.status == "enabled" + +- name: upgrade stuff via dnf + dnf: + state: latest + name: "*" + +- name: Install development tools + dnf: + name: '@Development tools' + state: present + +- name: add asterisk user + user: + name: asterisk + shell: /sbin/nologin + system: yes + +- name: add epel + yum: + name: epel-release + state: latest + +- name: install a bunch of packages + dnf: + state: latest + name: lynx, tftp-server, unixODBC, mysql-connector-odbc, mariadb-server, mariadb, httpd, ncurses-devel, sendmail, sendmail-cf, sox, newtdevel, libxml2-devel, libtiff-devel, audiofile-devel, gtk2-devel, subversion, kernel-devel, git, crontabs, cronie, cronie-anacron, wget, vim, uuiddevel, sqlite-devel, net-tools, gnutl-sdevel, python-devel, info, libuuid-devel, npm, php, php-pdo, php-mysql, php-mbstring, php-pear, php-process, php-xml, php-opcache, php-ldap, php-intl, php-soap + +- name: Enable mariadb + service: + name: mariadb + enabled: yes + state: started + +- name: Enable httpd + service: + name: httpd + enabled: yes + state: started + +- name: install Console_Getopt via pear + shell: pear install Console_Getopt + ignore_errors: yes + +- name: Check that /etc/asterisk exists + stat: + path: /etc/asterisk + register: asterisk + +- name: debug + debug: + var: asterisk + +- name: Install Asterisk if needed + block: + - name: install install-asterisk.sh script + template: + src: install-asterisk.sh.j2 + dest: /tmp/install-asterisk.sh + + - name: install asterisk via install-asterisk.sh script + shell: sh /tmp/install-asterisk.sh + when: not asterisk.stat.exists diff --git a/templates/selinux.j2 b/templates/selinux.j2 new file mode 100644 index 0000000..08d563c --- /dev/null +++ b/templates/selinux.j2 @@ -0,0 +1,11 @@ +# This file controls the state of SELinux on the system. +# SELINUX= can take one of these three values: +# enforcing - SELinux security policy is enforced. +# permissive - SELinux prints warnings instead of enforcing. +# disabled - No SELinux policy is loaded. +SELINUX=permissive +# SELINUXTYPE= can take one of these three values: +# targeted - Targeted processes are protected, +# minimum - Modification of targeted policy. Only selected processes are protected. +# mls - Multi Level Security protection. +SELINUXTYPE=targeted diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..eda9437 --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - verdexus-asterisk \ No newline at end of file diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..95bb8d6 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for verdexus-asterisk \ No newline at end of file