FreePBX / issue-tracker

The unified FreePBX issue tracker.
https://www.freepbx.org
GNU General Public License v3.0
7 stars 1 forks source link

[improvement]: Ansible-ize the bash installer #24

Open chrsmj opened 6 months ago

chrsmj commented 6 months ago

FreePBX Version

FreePBX 17

Improvement Description

PR 1 filed against freepbx/sng_freepbx_debian_install sub-project, should make maintenance easier and provide a framework to potentially help avoid some security issues during initial FreePBX installation in the future.

jcolp commented 6 months ago

What is the over all goal of this addition? To have both an Ansible based installer, as well as a script based installer? To encourage the project to move to just the Ansible based installer?

chrsmj commented 6 months ago

Initially, side-by-side installers; but ideally/eventually, Ansible-only installer.

EDIT: the "new" script installer to run on the TARGET could be a simple wrapper around Ansible...

su -
apt-get install ansible sshpass git
git clone https://github.com/chrsmj/sng_freepbx_debian_install.git
cd sng_freepbx_debian_install/
git checkout ansible-ize
cd ansible-role/sng_freepbx_debian/
ansible-playbook -i localhost, --connection=local playbook.yml
blazestudios97 commented 6 months ago

Going Ansible only may be a bit too much. Why would a single instance install require the need for Ansible to be used? Having both options is a pretty good idea for those that might do more than a single install or already run Ansible for their infrastructure. The average user, however, a normal install script should do the job just fine.

chrsmj commented 6 months ago

Running apt-get install ansible on a (fairly) fresh Debian 12 system adds 30.9 MB of additional downloads that take up 291 MB of additional disk space in 47 deb packages (mostly python libraries and not any thing drastic like new server processes - see below.) This is a fraction of the FreePBX appx. 8 GB install size. With the appropriate bootstrap/wrapper shell "installer.sh", the average user probably won't notice much difference; while the power user operating remotely could benefit significantly.

The install.sh could even clean itself up afterwards with an apt-get remove ansible and apt autoremove.

root@deb12:~# apt-get install ansible
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  ansible-core ieee-data libyaml-0-2 python-babel-localedata python3-anyio python3-argcomplete python3-babel python3-cffi-backend python3-click python3-colorama python3-cryptography
  python3-distutils python3-dnspython python3-h11 python3-h2 python3-hpack python3-httpcore python3-httpx python3-hyperframe python3-jinja2 python3-jmespath python3-kerberos python3-lib2to3
  python3-libcloud python3-lockfile python3-markdown-it python3-markupsafe python3-mdurl python3-netaddr python3-ntlm-auth python3-packaging python3-pycryptodome python3-pygments
  python3-requests-kerberos python3-requests-ntlm python3-requests-toolbelt python3-resolvelib python3-rfc3986 python3-rich python3-selinux python3-simplejson python3-sniffio python3-tz
  python3-winrm python3-xmltodict python3-yaml
Suggested packages:
  cowsay sshpass python-cryptography-doc python3-cryptography-vectors python3-trio python3-aioquic python-jinja2-doc python-lockfile-doc ipython3 python-netaddr-docs python-pygments-doc
  ttf-bitstream-vera
The following NEW packages will be installed:
  ansible ansible-core ieee-data libyaml-0-2 python-babel-localedata python3-anyio python3-argcomplete python3-babel python3-cffi-backend python3-click python3-colorama python3-cryptography
  python3-distutils python3-dnspython python3-h11 python3-h2 python3-hpack python3-httpcore python3-httpx python3-hyperframe python3-jinja2 python3-jmespath python3-kerberos python3-lib2to3
  python3-libcloud python3-lockfile python3-markdown-it python3-markupsafe python3-mdurl python3-netaddr python3-ntlm-auth python3-packaging python3-pycryptodome python3-pygments
  python3-requests-kerberos python3-requests-ntlm python3-requests-toolbelt python3-resolvelib python3-rfc3986 python3-rich python3-selinux python3-simplejson python3-sniffio python3-tz
  python3-winrm python3-xmltodict python3-yaml
0 upgraded, 47 newly installed, 0 to remove and 0 not upgraded.
Need to get 30.9 MB of archives.
After this operation, 291 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
chrsmj commented 6 months ago

New bash script to bootstrap the ansible-ized installer is available:

https://raw.githubusercontent.com/chrsmj/sng_freepbx_debian_install/ansible-ize/alt_sng_freepbx_debian_install.sh

...a nearly drop-in replacement for the current sng_freepbx_debian_install.sh, running on the TARGET directly, with log output to /var/log/pbx/freepbx17-install-alt.log, and a clean-up process to remove ansible when done installing; while preserving the ability to still utilize the role from CONTROL machine and thereby reap all the benefits of Ansible eg. concurrent multi-target install, easier path to idempotency, finer automated linting ability, etc.

chrsmj commented 5 months ago

This Ansible Role continues to be a superset of most of the current shell script installer functionality (apart from vimrc and screenrc modifications in the installer.)

It is good to see that the current Bash installer is moving closer to Ansible ways of doing things, for example, the recent addition of "setCurrentStep" function in commit 6669eef3fcc2aea4810c65cb65f6c762342966b2 by @tdltdl is very similar to the Ansible "name" keyword https://docs.ansible.com/ansible/latest/reference_appendices/playbooks_keywords.html