From 2ead55047077e0dfea128322bafeb03172df85d4 Mon Sep 17 00:00:00 2001 From: Richard Chen Zheng <58443436+rchenzheng@users.noreply.github.com> Date: Sat, 11 Dec 2021 19:26:45 -0500 Subject: [PATCH] Refactor into a Single Release - multi OS support - initialize web configuration tool - upgrade devsec.hardening to 7.13.2 --- 3cx_install.yaml | 5 ++--- Makefile | 8 +++++--- README.md | 4 ++-- Vagrantfile | 5 +++-- requirements.yaml | 2 +- roles/3cx-setup/handlers/main.yaml | 4 ++++ roles/3cx-setup/tasks/main.yaml | 5 ++++- roles/ssh-access/tasks/main.yml | 1 + 8 files changed, 22 insertions(+), 12 deletions(-) diff --git a/3cx_install.yaml b/3cx_install.yaml index b3895ea..9f5d12c 100644 --- a/3cx_install.yaml +++ b/3cx_install.yaml @@ -10,7 +10,6 @@ tasks: - # It is required to install while in the terminal as it's an interactive installation - - name: HOW TO INSTALL & SETUP? + - name: HOW TO CONFIGURE & SETUP? debug: - msg: "TO INSTALL and SETUP run `sudo apt install 3cxpbx`" + msg: "Access configuration wizard through a browser http://{{ ansible_default_ipv4.address }}:5015" diff --git a/Makefile b/Makefile index fff55ea..2791ddd 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,21 @@ REMOTE_IP=10.1.1.254 +VAGRANT_HOST_IP=192.168.56.254 USER=root +OS=debian/buster64 build: ansible-galaxy - vagrant up + OS=${OS} IP=${VAGRANT_HOST_IP} vagrant up ansible-galaxy: ansible-galaxy collection install -r requirements.yaml test: build - ansible-playbook -i "10.1.1.254", 3cx_install.yaml + ansible-playbook -i "${VAGRANT_HOST_IP}", 3cx_install.yaml install: ansible-galaxy ansible-playbook -i "${REMOTE_IP}", 3cx_install.yaml -e ansible_ssh_user=${USER} clean: - vagrant destroy -f && rm -rf .vagrant + OS=${OS} IP=${VAGRANT_HOST_IP} vagrant destroy -f && rm -rf .vagrant .PHONY: clean test ansible-galaxy diff --git a/README.md b/README.md index 849345d..c445988 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ ## Requirements - Ansible 2.9+ -- Debian Buster (3CX) -- Vagrant 2.2.7 (testing) +- Debian Stretch `debian/stretch64` `V16` or Buster `debian/buster64` `V18` +- Vagrant 2.2.7+ (testing) ## Deployment ## diff --git a/Vagrantfile b/Vagrantfile index 4f16b5c..ca30760 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -10,7 +10,7 @@ def define_vm(config, hostname, ip) public_key = IO.read(public_key_path) config.vm.define hostname do |vm| - vm.vm.box = "debian/buster64" + vm.vm.box = "#{ENV['OS']}" vm.vm.hostname = hostname vm.vm.network 'private_network', ip: ip @@ -19,5 +19,6 @@ def define_vm(config, hostname, ip) end Vagrant.configure("2") do |config| - define_vm(config, "3cx-pbx", "10.1.1.254") + define_vm(config, "3cx-pbx", "#{ENV['IP']}") + config.vm.synced_folder ".", "/vagrant", disabled: true end diff --git a/requirements.yaml b/requirements.yaml index 43f931b..607bfb5 100644 --- a/requirements.yaml +++ b/requirements.yaml @@ -1,5 +1,5 @@ --- collections: - name: devsec.hardening - version: 7.10.0 + version: 7.13.2 source: https://galaxy.ansible.com diff --git a/roles/3cx-setup/handlers/main.yaml b/roles/3cx-setup/handlers/main.yaml index c891603..d62bcb0 100644 --- a/roles/3cx-setup/handlers/main.yaml +++ b/roles/3cx-setup/handlers/main.yaml @@ -3,3 +3,7 @@ systemd: name: fail2ban state: restarted + +- name: start 3cx + command: + cmd: /usr/sbin/3CXLaunchWebConfigTool diff --git a/roles/3cx-setup/tasks/main.yaml b/roles/3cx-setup/tasks/main.yaml index 64a42e1..139e101 100644 --- a/roles/3cx-setup/tasks/main.yaml +++ b/roles/3cx-setup/tasks/main.yaml @@ -46,6 +46,9 @@ repo: deb http://downloads-global.3cx.com/downloads/debian {{ ansible_lsb.codename }} main state: present -- name: update cache +- name: install 3cx apt: + name: 3cxpbx update_cache: yes + state: latest + notify: start 3cx diff --git a/roles/ssh-access/tasks/main.yml b/roles/ssh-access/tasks/main.yml index b3de271..ee1a819 100644 --- a/roles/ssh-access/tasks/main.yml +++ b/roles/ssh-access/tasks/main.yml @@ -1,3 +1,4 @@ +--- - name: add {{ user }} user to sudoers user: name: "{{ user }}"