Skip to content

Commit

Permalink
Merge pull request mitogen-hq#57 from spearlineltd/germany-ec2-3
Browse files Browse the repository at this point in the history
Germany ec2 3
  • Loading branch information
cyara-devops authored Mar 5, 2021
2 parents 9312b72 + 2259e8f commit 56a1061
Show file tree
Hide file tree
Showing 24 changed files with 472 additions and 226 deletions.
39 changes: 22 additions & 17 deletions group_vars/all/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,21 @@ base_sip_trunks:
- 85.204.226.190/32
- 85.204.226.178/32
- 85.204.226.179/32
germany-ec2-3:
- 185.125.180.0/22
- 85.93.219.224/27
- 85.93.215.136/29
- 212.71.129.36/32
- 185.193.220.130/32
- 185.193.222.130/32
- 185.193.220.156/32
- 185.193.220.157/32
- 185.193.222.156/32
- 185.193.222.157/32
- 185.190.125.3/32
- 95.128.80.3/24
- 95.128.80.5/32
- 193.84.65.81/24

allow_sip_trunk:
singapore-singtel:
Expand Down Expand Up @@ -349,28 +364,18 @@ allow_sip_trunk:
switzerland-gcp-1:
- 5.148.166.200/32
- 5.148.166.201/24
germany-ec2-1:
- 185.125.180.0/22
- 85.93.219.224/27
- 85.93.215.136/29
- 212.71.129.36/32
- 185.193.220.130/32
- 185.193.222.130/32
- 185.193.220.156/32
- 185.193.220.157/32
- 185.193.222.156/32
- 185.193.222.157/32
- 185.190.125.3/32
- 95.128.80.3/24
- 95.128.80.5/32
- 193.84.65.81/24
ireland-test-callserver: []
germany-ec2-1 []:
ireland-test-callserver:
- 79.125.21.140/32
ireland-ec2-2: "{{ blueface_ireland_sip_ips + tollfree_forwarding_sip_ips }}"
china-nuc:
- 192.168.5.150/32
germany-ec2-2: "{{ tollfree_forwarding_sip_ips + base_sip_trunks['germany-ec2-2'] }}"
germany-ec2-3: "{{ tollfree_forwarding_sip_ips + base_sip_trunks['germany-ec2-3'] }}"
india-vodafone:
- 10.229.34.85/24
- 10.229.34.85/24
call-receiver-test: []

callserver_cert:
public_cert: |
-----BEGIN CERTIFICATE-----
Expand Down
5 changes: 5 additions & 0 deletions group_vars/callreceiver/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Callreceiver group variables
---

rtp_start: 10000
rtp_end: 20000
4 changes: 4 additions & 0 deletions group_vars/devel/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
---
devel: true

allow_ami_from: []
allow_sip_from:
- 63.35.150.109/32

api_server: https://apidev.spearline.com

db:
Expand Down
5 changes: 5 additions & 0 deletions hosts.ini
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ ireland-ec2-2 ansible_host=ireland-ec2-2.spearline.com
china-nuc ansible_host=china-nuc.spearline.com
germany-ec2-2 ansible_host=germany-ec2-2.spearline.com
india-vodafone ansible_host=india-vodafone.spearline.com
germany-ec2-3 ansible_host=germany-ec2-3.spearline.com

[callserverstest]
ireland-test-callserver ansible_host=ireland-test-callserver.spearline.com
Expand Down Expand Up @@ -100,6 +101,7 @@ devhosts
callserverstest
devhosts
manualdialdevel
callreceiver

[webex_callservers_staging]
spearline-test-1 ansible_host=spearline-test-1.spearline.dev external_ip=54.195.93.152 localnet=172.30.1.121/32
Expand All @@ -113,3 +115,6 @@ manual-dial-germany ansible_host=manual-dial-germany.spearline.com external_
[manualdial:children]
manualdialdevel
manualdialprod

[callreceiver]
call-receiver-test ansible_host=call-receiver-test.spearline.com external_ip=54.75.228.19 internal_ip=172.30.0.135
28 changes: 28 additions & 0 deletions roles/callreceiver/files/extensions_additional.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[globals]

[from-pstn]
exten => _X.,1,NoOp( Incoming call )
same => n,Goto(from-pstn,poc,1)

exten => poc,1,NoOp(Executing POC Prompt)
same => n,Progress()
same => n,Answer()
same => n,Wait(1)
same => n,SendDTMF(1)
same => n,Wait(1)
same => n,SendDTMF(2)
same => n,Wait(1)
same => n,SendDTMF(3)
same => n,Wait(1)
same => n,SendDTMF(9)
same => n,Wait(1)
same => n,SendDTMF(#)
same => n,Wait(1)
same => n,Wait(5)
same => n,Playback(ref_poc)
same => n,Wait(5)
same => n,Hangup(16)

exten => echo,1,Answer()
same => n,Echo()
same => n,hangup(16)
Empty file.
8 changes: 8 additions & 0 deletions roles/callreceiver/files/sip_provider.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[ireland-test-call-server]
allow=ulaw,alaw
host=172.16.0.114
port=5060
nat=force_rport,comedia
type=peer
dtmfmode=rfc2833
context=from-pstn
15 changes: 15 additions & 0 deletions roles/callreceiver/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
# Callserver handlers

- name: Reload callreceiver server
shell: ~/.local/bin/c reload
become: yes
become_user: backend

- name: Restart callreceiver server
systemd:
name: callreceiver
daemon_reload: yes
state: restarted
become: yes
become_user: root
58 changes: 58 additions & 0 deletions roles/callreceiver/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
# Callreceiver server tasks

- tags:
- callreceiver
become: yes
become_user: backend
block:
- name: Deploy callreceiver asterisk config
copy:
src: '{{ item }}'
dest: ~/asterisk_conf
with_fileglob:
- '*'
notify: Reload callreceiver server

- name: Deploy callreceiver asterisk templates
template:
src: '{{ item }}'
dest: ~/asterisk_conf
with_items:
- rtp.conf
- sip_general.conf
no_log: false
notify: Reload callreceiver server

- name: Setup environmental variable file for callreceiver server
template:
src: callreceiver-env.conf
dest: /etc/
mode: 0600
owner: backend
group: backend
no_log: false
become_user: root
register: env_file
tags:
- add_environment
- callreceiver-service

- name: Install callreceiver service
template:
src: callreceiver.service
dest: /etc/systemd/system
mode: 0644
become_user: root
register: callreceiver_service
notify: Restart callreceiver server
tags:
- callreceiver-service

- name: Run callreceiver server
systemd:
name: callreceiver
daemon-reload: yes
state: started
enabled: yes
become_user: root
1 change: 1 addition & 0 deletions roles/callreceiver/templates/callreceiver-env.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEVEL={{ "True" if devel else "False" }}
29 changes: 29 additions & 0 deletions roles/callreceiver/templates/callreceiver.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[Unit]
Description=Callreceiver container
Wants=network-online.target NetworkManager.service
After=network-online.target sshd.service NetworkManager.service multi-user.target

[Service]
Restart=always
User=backend
Group=backend
Environment=XDG_RUNTIME_DIR=/run/backend
ExecStartPre=-/usr/bin/podman rm -f callserver
ExecStartPre=-/usr/local/bin/upgrade_podman.sh
ExecStart=/usr/bin/podman run \
--name=callserver \
--hostname={{ ansible_hostname }}-container \
--conmon-pidfile=/run/backend/callreceiver.pid \
--net=host \
--env-file=/etc/callreceiver-env.conf \
-v /home/backend/asterisk_conf:/external_conf:z,ro \
-v /home/backend/callserver_sounds/sounds:/var/lib/asterisk/sounds:z,ro \
containers.spearline.com/callserver
ExecStartPost=+/usr/local/bin/asterisk_high_priority.sh
ExecStop=/usr/local/bin/nicely_kill_asterisk.sh
ExecStopPost=-/usr/bin/podman rm -f callserver
TimeoutStopSec=1500
PIDFile=/run/backend/callreceiver.pid

[Install]
WantedBy=multi-user.target
6 changes: 6 additions & 0 deletions roles/callreceiver/templates/rtp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[general]
rtpstart = {{ rtp_start }}
rtpend = {{ rtp_end }}
icesupport = no

[ice_host_candidates]
22 changes: 22 additions & 0 deletions roles/callreceiver/templates/sip_general.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[general]
context=from-pstn
externip={{ external_ip }}
localnet=172.30.0.0/16
localnet=10.0.0.0/8
localnet=192.168.142.0/24
externrefresh=10
directmedia=no
nat=force_rport,comedia
disallow=all
allow=ulaw,alaw
useragent=Spearline Labs
alwaysauthreject = yes
use_q850_reason = yes
sdpsession=Spearline Labs
allowoverlap=no
allowguest=yes
dtmfmode=auto
transport=udp,tcp,tls,wss,ws
udpbindaddr=0.0.0.0:5060
tcpenable=yes
tcpbindaddr=0.0.0.0:5060
Original file line number Diff line number Diff line change
@@ -1,75 +1,9 @@
[globals]
SERVER_ID=125
GOOGLE_OUTBOUND_NUMBER=910100909
GOOGLE_OUTBOUND_NUMBER=

;-- This section is for testing provider calls locally through server --;

[test-dialout]
exten => _X!,1,NoOp(Local Channel - Slovakia Leg-A)
same => n,Wait(1)
same => n,Set(CALLERID(all)="696850127" <696850127>)
same => n,Dial(SIP/peoplefonesk/${EXTEN})

[test-dialout1]
exten => _X!,1,NoOp(Local Channel - Slovakia ETO Leg-A)
same => n,Wait(1)
same => n,Set(CALLERID(all)="90575922975" <90575922975>)
same => n,Dial(SIP/peoplefonesk2/${EXTEN})

[test-dialout2]
exten => _X!,1,NoOp(Local Channel - Slovakia ETO Leg-A)
same => n,Wait(1)
same => n,Set(CALLERID(all)="52077921" <52077921>)
same => n,Dial(SIP/peoplefonelt/${EXTEN})

[test-dialout3]
exten => _X!,1,NoOp(Local Channel - Luxembourg Leg-A)
same => n,Wait(1)
same => n,Set(CALLERID(all)="20211431" <20211431>)
same => n,Dial(SIP/mixvoip/${EXTEN})

[test-dialout4]
exten => _X!,1,NoOp(Local Channel - Hungary Leg-A)
same => n,Wait(1)
same => n,Set(CALLERID(all)="12550179" <12550179>)
same => n,Dial(SIP/uhusystems/${EXTEN})

[test-dialout5]
exten => _X!,1,NoOp(Local Channel - Hungary ETO Leg-A)
same => n,Wait(1)
same => n,Set(CALLERID(all)="Anonymous" <Anonymous>)
same => n,Dial(SIP/uhusystems2/${EXTEN})

[test-dialout6]
exten => _X!,1,NoOp(Local Channel - Austria Leg-A)
same => n,Wait(1)
same => n,Set(CALLERID(all)="0043720620170" <0043720620170>)
same => n,Dial(SIP/neotel/${EXTEN})

[test-dialout7]
exten => _X!,1,NoOp(Local Channel - Austria ETO Leg-A)
same => n,Wait(1)
same => n,Set(CALLERID(all)="0043720620171" <0043720620171>)
same => n,Dial(SIP/neotel/${EXTEN})

[test-dialout8]
exten => _X!,1,NoOp(Local Channel - Czech Republic Leg-A)
same => n,Wait(1)
same => n,Set(CALLERID(all)="910100900" <910100900>)
same => n,Dial(SIP/itprofik/${EXTEN})

[test-dialout9]
exten => _X!,1,NoOp(Local Channel - Czech Republic ETO Leg-A)
same => n,Wait(1)
same => n,Set(CALLERID(all)="910100901" <910100901>)
same => n,Dial(SIP/itprofik2/${EXTEN})

[recordc]
exten => s,1,NoOP(SIP/ISDN Channel - Leg-B)
same => n,Answer()
same => n,MixMonitor(/tmp/${UNIQUEID}.wav)
same => n,Wait(60)

;-- Provider test section end --;

;-- Enable this section if your firewall is wide open and accepting any connection from anywhere on port 5060 --;
Expand All @@ -79,7 +13,6 @@ same => n,Wait(60)
;same => n,Log(NOTICE,"Rejecting unknown SIP connection from ${CHANNEL(recvip)}")
;same => n,Congestion()


[from-pstn]
exten => _[+*#0-9s].,1,NoOp(Incoming call received on DID::${EXTEN}, CLI::${CALLERID(num)}, IP::${CHANNEL(recvip)})
same => n,Set(CALL_START_EPOCH=${EPOCH})
Expand All @@ -102,7 +35,6 @@ same => n,Set(DB_QUERY_TIME=${MATH(${EPOCH} - ${CALL_START_EPOCH},int)})
same => n(poc),Answer()
same => n,Wait(1)
same => n,SendDTMF(1)
same => n,SendDTMF(1)
same => n,Wait(1)
same => n,SendDTMF(2)
same => n,Wait(1)
Expand All @@ -124,11 +56,3 @@ same => n,Wait(5)
same => n,Playback(ref_polqa_speakeasy)
same => n,Wait(5)
same => n,HangUp()

[itprofik_incoming]
exten => _X.,1,NoOp(=============================${SIP_HEADER(From)}======================================================== ${EXTEN})
same => n,Set(CID=${SIP_HEADER(From)})
same => n,Set(cut1=${CUT(CID,:,2)})
same => n,Set(CLI=${CUT(cut1,>,1)})
same => n,Set(CALLERID(all)=${CUT(CLI,@,1)})
same => n,ExecIf($["${EXTEN:0:1}" == "+"]?Goto(from-pstn,${EXTEN:1},1):Goto(from-pstn,${EXTEN},1))
5 changes: 1 addition & 4 deletions roles/callserver/files/host/germany-ec2-1/sip_general.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[general]
context=from-pstn
externip=18.195.116.29
externip=3.65.145.76
localnet=172.16.0.176/24
localnet=10.52.1.69/32
externrefresh=10
Expand All @@ -27,9 +27,6 @@ tlscipher=ALL
tlsclientmethod=sslv23
tlsdisablev1=yes
tlsdontverifyserver=yes
register= 90516917166:2jX36VdVz7uc@sips.peoplefone.sk/421696850127~600
register= 90819121982:E96L2hS4sGbj@sips.peoplefone.lt/370852077921~600
register= r91hmww4d433wa83nfpho@blizzweb.at:12Zj49p512@p02.neotel.at

register => tls://20035085966206452187@7005403556.zoom.us:vVlalMlf:566120258507@us01sip0h.fr.zoom.us:5091/20035085966206452187~600
register => tls://69131104763943336413@7005403556.zoom.us:RfcRRHzF:541314481905@us01sip0h.fr.zoom.us:5091/69131104763943336413~600
Expand Down
Loading

0 comments on commit 56a1061

Please sign in to comment.