futel / asteriskserver

SIP server for Futel
Creative Commons Zero v1.0 Universal
25 stars 7 forks source link

Deploy an asterisk server to Digital Ocean

Meta-requirements

The setup of README-aws and README-twilio should be completed. Voip.ms should be set up, there is no README for that. These should only have to be done once.

Steps

Requirements and test

Create deployment virtualenv

Update local lua environment for testing

Run unit tests locally

  python3 -m venv venv
  pushd src/var/lib/asterisk/agi-bin
  python3 -m unittest discover test
  popd
  pushd src/opt/futel/src
  python3 -m unittest discover test
  popd
  pushd src/etc/asterisk/test
  lua test.lua

Run integration tests on virtualbox

  cd /opt/futel/itest
  sudo -u asterisk ./itest.sh

Validate requirements and configuration locally

  python3 -m venv venv
  ansible-playbook -i deploy/hosts deploy/requirements_conf_prod_playbook.yml
  ansible-playbook -K -i deploy/hosts deploy/requirements_packages_generic_playbook.yml

Deploy stage droplet

deploy_playbook may fail if DNS takes a long time to propagate. Run it again if it does.

deploy_playbook and baseinstall_playbook may fail with DNS or SSH issues, it should work when 'ssh root@futel-stage.phu73l.net' fails with 'permission denied'.

update_asterisk_conf_sync_playbook may fail with file transfer issues. Run it again if it does.

Test droplet

If testplan has changed since last release branch, update google sheet testplan, keeping dates of nonupdated completed tests. Test stage against google sheet testplan.

Promote stage to prod

rename futel-prod.phu73l.net droplet to futel-prod-back rename futel-stage.phu73l.net droplet to futel-prod.phu73l.net

point all voip.ms DID forwarding rules to subaccounts corresponding to new conf_version on futel-prod.phu73l.net 185060_prod-foo|bar subaccount

  ansible-playbook -i deploy/hosts deploy/promote_playbook.yml --vault-id=digitalocean@conf/vault_pass_digitalocean.txt
  ansible-playbook -i deploy/hosts deploy/post_promote_playbook.yml --vault-id=digitalocean@conf/vault_pass_digitalocean.txt

Delete the assets* volume which was attached to futel-prod-back.

Remove snapshots of futel-prod-back except for most recent.

Update iptables

This is done after a new vpnbox is deployed.

  ansible-playbook -i deploy/hosts deploy/update_iptables_playbook.yml

Create droplets from images

A droplet can be created from any image with the stage_from_snapshot playbook. This will create the stage droplet and assign a DNS name, so there should be no futel-stage.phu73l.net droplet or domain.

  ansible-playbook -i deploy/hosts deploy/stage_from_snapshot_playbook.yml --vault-password-file=conf/vault_pass_digitalocean.txt --extra-vars snapshot=<image>