diff --git a/cloudpbx-freepbx.yaml b/cloudpbx-freepbx.yaml index 9154f87..9c8e25b 100644 --- a/cloudpbx-freepbx.yaml +++ b/cloudpbx-freepbx.yaml @@ -1,5 +1,4 @@ -## Deploy Cloud PBX Freepbx #### -## Updated to work on Ubuntu Server 20.04 and 22.04### +## Supports Ubuntu 24.x (minimal) --- - name: Depoying CloudPBX Freepbx @@ -7,8 +6,9 @@ become: true vars: db_root_pass: "{{ lookup('env','DB_ROOT_PASS') }}" - fpbx_ver: 16.0 - ast_ver: 20 + fpbx_ver: 17.0 + ast_ver: 21 + nodejs_ver: 18 roles: - sysprep - db_prep diff --git a/freepbx-hosts.txt b/freepbx-hosts.txt new file mode 100644 index 0000000..959f64b --- /dev/null +++ b/freepbx-hosts.txt @@ -0,0 +1,2 @@ +[fpbx] +fpbx01 ansible_connection=ssh ansible_host= ansible_ssh_pass= ansible_user=root diff --git a/roles/asterisk/tasks/main.yml b/roles/asterisk/tasks/main.yml index 85fab65..608f984 100644 --- a/roles/asterisk/tasks/main.yml +++ b/roles/asterisk/tasks/main.yml @@ -1,78 +1,58 @@ --- -- name: Download Asterisk {{ ast_ver }} - ansible.builtin.get_url: - url: http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-{{ ast_ver }}-current.tar.gz +- + name: Download Asterisk {{ast_ver}} + get_url: + url: http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-{{ast_ver}}-current.tar.gz dest: /usr/src - mode: '0664' - -- name: Untar Asterisk tarball - ansible.builtin.unarchive: - src: /usr/src/asterisk-{{ ast_ver }}-current.tar.gz +- + name: Untar Asterisk tarball + unarchive: + src: /usr/src/asterisk-{{ast_ver}}-current.tar.gz dest: /usr/src - remote_src: true - -- name: Remove Asterisk tarball - ansible.builtin.file: - path: /usr/src/asterisk-{{ ast_ver }}-current.tar.gz + remote_src: yes +- + name: Remove Asterisk tarball + file: + path: /usr/src/asterisk-{{ast_ver}}-current.tar.gz state: absent - -- name: Find extracted folder name for Asterisk {{ ast_ver }} - ansible.builtin.find: +- + name: "Find extracted Asterisk {{ast_ver}} folder name " + find: paths: /usr/src file_type: directory - recurse: false + recurse: no patterns: ^asterisk.*$ - use_regex: true + use_regex: yes register: 'ast_install_dir' - -- name: Make Libvpb1 install non-interactive - ansible.builtin.shell: - cmd: "{{ item }}" - creates: libvpb1.ok - executable: /bin/bash - with_items: - - set -o pipefail - - echo 'libvpb1 libvpb1/countrycode string 381' | sudo debconf-set-selections -v - - touch libvpb1.ok - -- name: Install Asterisk Prerequisites - ansible.builtin.shell: - cmd: "{{ item }}" - chdir: "{{ ast_install_dir.files[0].path }}/contrib/scripts" - creates: asterisk-prereq.ok - executable: /bin/bash +- + name: "Make Libvpb1 install non-interactive" + shell: set -o pipefail | echo 'libvpb1 libvpb1/countrycode string 381' | sudo debconf-set-selections -v +- + name: Install Asterisk Prereqisites + shell: + cmd: "{{item}}" + chdir: "{{ast_install_dir.files[0].path}}/contrib/scripts" with_items: - ./get_mp3_source.sh - ./install_prereq install - - touch asterisk-prereq.ok - -- name: Run configure asterisk scripts - ansible.builtin.shell: - cmd: "{{ item }}" - chdir: "{{ ast_install_dir.files[0].path }}" - creates: ast-scripts.ok - executable: /bin/bash - with_items: - - ./configure --with-pjproject-bundled --with-jansson-bundled - - touch ast-scripts.ok - -- name: Select make options - ansible.builtin.shell: - cmd: "{{ item }}" - chdir: "{{ ast_install_dir.files[0].path }}" - creates: ast-make-menu.ok - executable: /bin/bash +- + name: Run configure asterisk scripts + shell: + cmd: ./configure --with-pjproject-bundled --with-jansson-bundled + chdir: "{{ast_install_dir.files[0].path}}" +- + name: Select make options + shell: + cmd: "{{item}}" + chdir: "{{ast_install_dir.files[0].path}}" with_items: - make menuselect.makeopts - - menuselect/menuselect --enable app_macro --enable format_mp3 menuselect.makeopts - - touch ast-make-menu.ok - -- name: Compile and Install Asterisk - ansible.builtin.shell: - cmd: "{{ item }}" - chdir: "{{ ast_install_dir.files[0].path }}" - creates: compiled-asterisk.ok - executable: /bin/bash + - menuselect/menuselect --enable res_config_mysql --enable format_mp3 menuselect.makeopts +- + name: Compile and Install Asterisk + shell: + cmd: "{{item}}" + chdir: "{{ast_install_dir.files[0].path}}" with_items: - make - contrib/scripts/get_mp3_source.sh @@ -80,20 +60,19 @@ - make config - ldconfig - update-rc.d -f asterisk remove - - touch compiled-asterisk.ok - -- name: Add asterisk users - ansible.builtin.user: +- + name: Add asterisk users + user: name: asterisk comment: Asterisk user - -- name: Seting folder permitions for asterisk user - ansible.builtin.file: - path: "{{ item }}" +- + name: Seting folder permitions for asterisk user + file: + path: "{{item}}" owner: asterisk group: asterisk state: directory - recurse: true + recurse: yes with_items: - /var/run/asterisk - /etc/asterisk @@ -101,33 +80,33 @@ - /var/log/asterisk - /var/spool/asterisk - /usr/lib/asterisk - -- name: Remove default web folder - ansible.builtin.file: +- + name: Remove default web folder + file: path: /var/www/html state: absent - -- name: Find php version folder name - ansible.builtin.find: +- + name: "Find php version folder name " + find: paths: /etc/php file_type: directory - recurse: false - patterns: ^7.*$ - use_regex: true + recurse: no + patterns: ^8.*$ + use_regex: yes register: 'php_ver' - -- name: Making some Apache config changes - ansible.builtin.lineinfile: - path: "{{ item.path }}" - regexp: "{{ item.regexp }}" - line: "{{ item.line }}" +- + name: Making some Apache config changes + lineinfile: + path: "{{item.path}}" + regexp: "{{item.regexp}}" + line: "{{item.line}}" with_items: - - path: "{{ php_ver.files[0].path }}/apache2/php.ini" + path: "{{php_ver.files[0].path}}/apache2/php.ini" regexp: "upload_max_filesize =" line: "upload_max_filesize = 20M" - - path: "{{ php_ver.files[0].path }}/apache2/php.ini" + path: "{{php_ver.files[0].path}}/apache2/php.ini" regexp: "memory_limit =" line: "memory_limit = 256M" - @@ -138,34 +117,29 @@ path: /etc/apache2/envvars regexp: export APACHE_RUN_GROUP= line: export APACHE_RUN_GROUP=asterisk - -- name: Some more Apache changes - ansible.builtin.replace: +- + name: Some more Apache changes + replace: path: '/etc/apache2/apache2.conf' regexp: 'AllowOverride None' replace: 'AllowOverride All' - -- name: Enable Apache Rewrite Mod - ansible.builtin.shell: - cmd: "{{ item }}" - creates: apache-rewrite.ok - executable: /bin/bash - with_items: - - a2enmod rewrite - - touch apache-rewrite.ok - -- name: Restarting Apache Service - ansible.builtin.service: +- + name: Enable Apache Rewrite Mod + shell: a2enmod rewrite +- + name: Restarting Apache Service + service: name: apache2 state: restarted - -- name: Seting ODBC files - ansible.builtin.template: - src: "{{ item.src }}" - dest: "{{ item.dest }}" - mode: '0664' +- + name: Seting ODBC files + template: + src: "{{item.src}}" + dest: "{{item.dest}}" with_items: - - src: odbc.ini.j2 + - + src: odbc.ini.j2 dest: /etc/odbc.ini - - src: odbcinst.ini.j2 + - + src: odbcinst.ini.j2 dest: /etc/odbcinst.ini diff --git a/roles/freepbx/tasks/main.yml b/roles/freepbx/tasks/main.yml index f7bcc64..e37c9e4 100644 --- a/roles/freepbx/tasks/main.yml +++ b/roles/freepbx/tasks/main.yml @@ -1,47 +1,41 @@ --- -- name: Downloading FreePBX {{ fpbx_ver }} - ansible.builtin.get_url: - url: http://mirror.freepbx.org/modules/packages/freepbx/freepbx-{{ fpbx_ver }}-latest.tgz +- + name: Downloading FreePBX {{fpbx_ver}} + get_url: + url: http://mirror.freepbx.org/modules/packages/freepbx/freepbx-{{fpbx_ver}}-latest.tgz dest: /usr/src - mode: '0664' - -- name: Unpacking FreePBX tarball - ansible.builtin.unarchive: - src: /usr/src/freepbx-{{ fpbx_ver }}-latest.tgz +- + name: Unpacking FreePBX tarball + unarchive: + src: /usr/src/freepbx-{{fpbx_ver}}-latest.tgz dest: /usr/src - remote_src: true - -- name: Removing FreePBX tarball - ansible.builtin.file: - path: /usr/src/freepbx-{{ fpbx_ver }}-latest.tgz + remote_src: yes +- + name: Removing FreePBX tarball + file: + path: /usr/src/freepbx-{{fpbx_ver}}-latest.tgz state: absent - -- name: Creating some asterisk files - ansible.builtin.file: - path: /etc/asterisk/{{ item }}.conf +- + name: Creating some asterisk files + file: + path: /etc/asterisk/{{item}}.conf state: touch - mode: '0664' with_items: - modules - cdr - -- name: Starting FreePBX - ansible.builtin.shell: - cmd: "{{ item }}" +- + name: Starting FreePBX + shell: + cmd: "{{item}}" chdir: /usr/src/freepbx - creates: start-fpbx.ok - executable: /bin/bash - no_log: false with_items: - ./start_asterisk start - - ./install -n --dbuser root --dbpass {{ db_root_pass }} - - touch start-fpbx.ok - -- name: Install FreePBX Modules - ansible.builtin.shell: "{{ item }}" - args: - creates: fpbx-started.ok - executable: /bin/bash + - ./install -n --dbuser root --dbpass {{db_root_pass}} + # freepbx install script returns code 1 for successfull install + ignore_errors: true +- + name: Install FPBX Modules + shell: "{{item}}" with_items: - fwconsole ma enablerepo standard - fwconsole ma enablerepo extended @@ -60,25 +54,22 @@ - fwconsole ma downloadinstall outroutemsg - fwconsole ma downloadinstall timeconditions - fwconsole ma downloadinstall queues - - fwconsole ma upgradeall - fwconsole reload - fwconsole restart - - touch fpbx-started.ok - -- name: Create FreePBX Startup service - ansible.builtin.template: +- + name: Create FreePBX Startup service + template: src: freepbx.service.j2 dest: /etc/systemd/system/freepbx.service - mode: '0664' - -- name: Enable FreePBX Service - ansible.builtin.service: +- + name: Enable FreePBX Service + service: name: freepbx.service - enabled: true - -- name: Set hostname - ansible.builtin.hostname: + enabled: yes +- + name: Set hostname + hostname: name: fpbx.local - -- name: Reboot host - ansible.builtin.reboot: +- + name: Reboot host + reboot: diff --git a/roles/freepbx/templates/freepbx.service.j2 b/roles/freepbx/templates/freepbx.service.j2 index 50fa481..b7d2f9d 100644 --- a/roles/freepbx/templates/freepbx.service.j2 +++ b/roles/freepbx/templates/freepbx.service.j2 @@ -1,11 +1,11 @@ -[Unit] -Description=Start FreePBX - -[Service] -ExecStartPre=/bin/sleep 5 -ExecStart=/usr/sbin/fwconsole start -Type=oneshot -RemainAfterExit=yes - -[Install] +[Unit] +Description=Start FreePBX + +[Service] +ExecStartPre=/bin/sleep 5 +ExecStart=/usr/sbin/fwconsole start +Type=oneshot +RemainAfterExit=yes + +[Install] WantedBy=multi-user.target \ No newline at end of file diff --git a/roles/phpmyadmin/tasks/main.yml b/roles/phpmyadmin/tasks/main.yml index 3d36baa..ebd1e85 100644 --- a/roles/phpmyadmin/tasks/main.yml +++ b/roles/phpmyadmin/tasks/main.yml @@ -1,12 +1,11 @@ --- - name: Set some installation parameters - ansible.builtin.debconf: + debconf: name: phpmyadmin - question: "{{ item.question }}" - value: '{{ item.value }}' - vtype: "{{ item.vtype }}" - no_log: true + question: "{{item.question}}" + value: '{{item.value}}' + vtype: "{{item.vtype}}" with_items: - question: phpmyadmin/dbconfig-install @@ -14,15 +13,15 @@ vtype: 'boolean' - question: phpmyadmin/app-password-confirm - value: '{{ db_root_pass }}' + value: '{{db_root_pass}}' vtype: 'password' - question: phpmyadmin/mysql/admin-pass - value: '{{ db_root_pass }}' + value: '{{db_root_pass}}' vtype: 'password' - question: phpmyadmin/mysql/app-pass - value: '{{ db_root_pass }}' + value: '{{db_root_pass}}' vtype: 'password' - question: phpmyadmin/reconfigure-webserver @@ -34,21 +33,15 @@ vtype: 'boolean' - name: Installing packages - ansible.builtin.apt: - name: "{{ packages }}" - update_cache: true + apt: + name: "{{packages}}" + update_cache: yes state: present - name: Enable php mod - ansible.builtin.shell: - cmd: "{{ item }}" - creates: phpenmod.ok - executable: /bin/bash - with_items: - - phpenmod mbstring - - touch phpenmod.ok + shell: phpenmod mbstring - name: Restart Apache - ansible.builtin.service: + service: name: apache2 state: restarted diff --git a/roles/phpmyadmin/vars/main.yml b/roles/phpmyadmin/vars/main.yml index 414af55..7a5be42 100644 --- a/roles/phpmyadmin/vars/main.yml +++ b/roles/phpmyadmin/vars/main.yml @@ -1,5 +1,5 @@ ---- -packages: - - phpmyadmin - - php-mbstring - - gettext +--- +packages: + - phpmyadmin + - php8.2-mbstring + - php8.2-gettext diff --git a/roles/sysprep/tasks/main.yml b/roles/sysprep/tasks/main.yml index 708ae16..7268441 100644 --- a/roles/sysprep/tasks/main.yml +++ b/roles/sysprep/tasks/main.yml @@ -1,73 +1,38 @@ --- -- name: Initial system upgrade - ansible.builtin.apt: - upgrade: full - update_cache: true - -- name: Add NodeJS Repo - ansible.builtin.shell: | - set -o pipefail - curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - > /tmp/node.log +- + name: "Add NodeJS Repo" + shell: curl -sL https://deb.nodesource.com/setup_{{nodejs_ver}}.x | sudo -E bash - > /tmp/node.log args: creates: /tmp/node.log - warn: false - executable: /bin/bash - -- name: Install php7.4 install prerequisite - ansible.builtin.apt: - name: software-properties-common +- name: Add PHP repo + apt_repository: + validate_certs: no + repo: 'ppa:ondrej/php' state: present - -- name: Add php7.4 repo - ansible.builtin.apt_repository: - repo: ppa:ondrej/php - -- name: Updating System - ansible.builtin.apt: +- + name: "Updating System" + apt: upgrade: full - update_cache: true - -- name: Installing Packages - ansible.builtin.apt: - name: "{{ packages }}" - state: present - -- name: Install Ubuntu20.04 specific package - ansible.builtin.apt: - name: python-dev - state: present - when: ansible_distribution == 'Ubuntu' and ansible_distribution_major_version == '20' - -- name: Install Ubuntu22.04 specific package - ansible.builtin.apt: - name: python3-dev + update_cache: yes +- + name: Installing Packages + apt: + name: "{{packages}}" state: present - when: ansible_distribution == 'Ubuntu' and ansible_distribution_major_version == '22' - -- name: Install pymysql ansible modules - ansible.builtin.pip: - name: pymysql - state: present - -- name: Set defatult php7.4 as default - ansible.builtin.shell: update-alternatives --set php /usr/bin/php7.4 > php-default.ok - args: - creates: php-default.ok - executable: /bin/bash - -- name: Set swappiness - ansible.builtin.lineinfile: +- + name: Set swappiness + lineinfile: path: /etc/sysctl.conf line: vm.swappiness=10 - backup: true + backup: yes state: present - -- name: Install Legacy Pear Requirements - ansible.builtin.shell: - cmd: pear install Console_Getopt > /tmp/pear.log - creates: /tmp/pear.log - when: fpbx_ver == '15.0' - ignore_errors: true - -- name: Reboot host - ansible.builtin.reboot: +- + name: Set php8.2 version for cli + shell: "{{item}}" + with_items: + - update-alternatives --set php /usr/bin/php8.2 + - update-alternatives --set phar /usr/bin/phar8.2 + - update-alternatives --set phar.phar /usr/bin/phar.phar8.2 +- + name: Reboot host + reboot: diff --git a/roles/sysprep/vars/main.yml b/roles/sysprep/vars/main.yml index 066806f..89d94fe 100644 --- a/roles/sysprep/vars/main.yml +++ b/roles/sysprep/vars/main.yml @@ -1,61 +1,70 @@ ---- -packages: - - build-essential - - linux-headers-{{ ansible_kernel }} - - openssh-server - - apache2 - - mariadb-server - - mariadb-client - - bison - - flex - - php7.4 - - php7.4-curl - - php7.4-cli - - php7.4-pdo - - php7.4-mysql - - php-pear - - php7.4-gd - - php7.4-mbstring - - php7.4-intl - - php7.4-xml - - curl - - cron - - sox - - libncurses5-dev - - libssl-dev - - mpg123 - - libxml2-dev - - libnewt-dev - - sqlite3 - - libsqlite3-dev - - pkg-config - - automake - - libtool - - autoconf - - git - - unixodbc-dev - - uuid - - uuid-dev - - libasound2-dev - - libogg-dev - - libvorbis-dev - - libicu-dev - - libcurl4-openssl-dev - - libical-dev - - libneon27-dev - - libsrtp2-dev - - libspandsp-dev - - libedit-dev - - sudo - - subversion - - libtool-bin - - unixodbc - - dirmngr - - sendmail-bin - - sendmail - - nodejs - - xz-utils - - python3-pip - - net-tools - ## Needed for debconf-set-selections - - debconf-utils +--- +packages: + - build-essential + - linux-headers-{{ ansible_kernel }} + - openssh-server + - apache2 + - mariadb-server + - mariadb-client + - bison + - flex + - php8.2 + - php8.2-curl + - php8.2-cli + - php8.2-pdo + - php8.2-mysql + - php8.2-gd + - php8.2-mbstring + - php8.2-intl + - php8.2-common + - php8.2-xml + - php8.2-intl + - php-pear + - curl + - sox + - libncurses5-dev + - libssl-dev + - mpg123 + - libxml2-dev + - libnewt-dev + - sqlite3 + - libsqlite3-dev + - pkg-config + - automake + - libtool + - autoconf + - git + - unixodbc-dev + - uuid + - uuid-dev + - libasound2-dev + - libogg-dev + - libvorbis-dev + - libicu-dev + - libcurl4-openssl-dev + - libical-dev + - libneon27-dev + - libsrtp2-dev + - libspandsp-dev + - libjansson-dev + - sudo + - subversion + - libtool-bin + - python3-dev + - unixodbc + - dirmngr + - sendmail-bin + - sendmail + - nodejs + - xz-utils + - python3-pip + - python3-mysqldb + ## Needed for debconf-set-selections + - debconf-utils + - sngrep + - lame + - ffmpeg + - vim + - expect + - odbc-mariadb + - cron diff --git a/roles/webmin/tasks/main.yml b/roles/webmin/tasks/main.yml index 15d1671..72ba7a4 100644 --- a/roles/webmin/tasks/main.yml +++ b/roles/webmin/tasks/main.yml @@ -1,17 +1,17 @@ ---- -- - name: Add Apt Key - ansible.builtin.apt_key: - url: http://www.webmin.com/jcameron-key.asc - state: present -- - name: Add Webmin Repo - ansible.builtin.apt_repository: - repo: deb http://download.webmin.com/download/repository sarge contrib - state: present -- - name: Install webmin - ansible.builtin.apt: - name: webmin - update_cache: true - state: present +--- +- + name: Add Apt Key + apt_key: + url: http://www.webmin.com/jcameron-key.asc + state: present +- + name: Add Webmin Repo + apt_repository: + repo: deb http://download.webmin.com/download/repository sarge contrib + state: present +- + name: Install webmin + apt: + name: webmin + update_cache: yes + state: present