Files
jambonz-infrastructure/packer/jambonz-sbc-sip-rtp/aws/template-rhel-8.json
2023-11-15 09:46:40 -05:00

164 lines
6.5 KiB
JSON

{
"variables": {
"region": "us-east-1",
"ssh_username": "ec2-user",
"ami_description": "jambonz SBC SIP+RTP",
"instance_type": "c6in.xlarge",
"drachtio_version": "v0.8.24",
"jambonz_version": "v0.8.5-2",
"ami_base_image_arch": "amd64",
"ami_base_image_owner": "309956199498",
"rtp_engine_version": "mr11.5.1.1",
"rtp_engine_min_port": "40000",
"rtp_engine_max_port": "60000",
"install_datadog": "no",
"datadog_key" : "",
"install_cloudwatch": "yes",
"install_telegraf": "yes",
"distro": "rhel-8",
"redhat_username": "your-redhat_username-here",
"redhat_password": "your-redhat_password-here",
"leave_source": "no"
},
"builders": [{
"type": "amazon-ebs",
"region": "{{user `region`}}",
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "RHEL-8.8*",
"root-device-type": "ebs",
"architecture": "x86_64"
},
"owners": ["{{user `ami_base_image_owner`}}"],
"most_recent": true
},
"instance_type": "{{user `instance_type`}}",
"ssh_username": "{{user `ssh_username`}}",
"ami_name": "jambonz-sbc-sip-rtp-{{user `jambonz_version`}}-{{user `distro`}}-{{user `ami_base_image_arch`}}-{{isotime |clean_resource_name }}",
"ami_description": "{{user `ami_description`}}",
"launch_block_device_mappings": [
{
"device_name": "/dev/sda1",
"volume_size": 60,
"volume_type": "gp3",
"delete_on_termination": true
}
],
"tags": {
"Name": "jambonz-sbc-sip-rtp"
},
"run_tags": {
"Name": "jambonz-sbc-sip-rtp-build"
}
}],
"provisioners": [
{
"type": "shell",
"inline": [
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done",
"export PATH=/usr/local/bin:$PATH",
"export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH",
"export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH",
"sudo setenforce 0",
"sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config",
"echo registering",
"sudo subscription-manager register --username={{user `redhat_username`}} --password={{user `redhat_password`}}",
"sudo dnf upgrade -y",
"sudo sed -i 's/manage_repos = 0/manage_repos = 1/' /etc/rhsm/rhsm.conf",
"cat /etc/rhsm/rhsm.conf",
"echo installing codeready repos",
"sudo subscription-manager repos --enable=codeready-builder-for-rhel-8-x86_64-rpms",
"echo installing epel repo",
"sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm",
"sudo dnf upgrade -y",
"echo running /usr/bin/crb",
"sudo /usr/bin/crb enable",
"echo installing rpmfusion repo",
"sudo dnf install -y https://download1.rpmfusion.org/free/el/rpmfusion-free-release-9.noarch.rpm",
"echo installing Development tools",
"sudo dnf groupinstall -y 'RPM Development Tools'",
"sudo dnf groupinstall -y 'Development Tools'",
"echo installing needed packages",
"sudo dnf install -y iptables-devel htop pandoc wget cmake ffmpeg ffmpeg-devel perl-IPC-Cmd pcre-devel iptables-devel \\",
"google-perftools-devel libcurl-devel jq telnet libevent-devel xmlrpc-c-devel gperf libpcap-devel \\",
"glib2-devel json-glib-devel hiredis-devel spandsp-devel mariadb-devel dnsutils speex libedit-devel opus-devel \\",
"glib2-devel json-glib-devel spandsp-devel hiredis-devel libevent-devel xmlrpc-c-devel perl-IPC-Cmd mariadb-devel snapd",
"sudo dnf debuginfo-install -y binutils",
"sudo chmod a+w /usr/local/src",
"ssh-keyscan github.com >> ~/.ssh/known_hosts",
"mkdir ~/apps",
"cd ~/apps",
"git config --global advice.detachedHead false",
"git clone https://github.com/jambonz/sbc-sip-sidecar.git -b {{user `jambonz_version`}}",
"git clone https://github.com/jambonz/sbc-rtpengine-sidecar.git -b {{user `jambonz_version`}}",
"git clone https://github.com/jambonz/sbc-outbound.git -b {{user `jambonz_version`}}",
"git clone https://github.com/jambonz/sbc-inbound.git -b {{user `jambonz_version`}}",
"git clone https://github.com/jambonz/jambonz-smpp-esme.git -b {{user `jambonz_version`}}",
"git clone https://github.com/jambonz/sbc-call-router.git -b {{user `jambonz_version`}}",
"sudo find / -name authorized_keys | sudo xargs -0 -r rm -Rf"
]
},
{
"type": "file",
"source": "files/",
"destination": "/tmp"
},
{
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `distro`}}",
"script": "scripts/install_os_tuning.sh"
},
{
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{build `ID`}}",
"script": "scripts/install_apiban.sh"
},
{
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `distro`}} {{user `install_cloudwatch`}}",
"script": "scripts/install_cloudwatch.sh"
},
{
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `distro`}}",
"script": "scripts/install_nodejs.sh"
},
{
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `distro`}} {{user `rtp_engine_version`}}",
"script": "scripts/install_rtpengine.sh"
},
{
"type": "shell",
"environment_vars": [
"DD_KEY={{user `datadog_key`}}",
"DD_INSTALL={{user `install_datadog`}}"
],
"execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}'",
"script": "scripts/install_datadog.sh"
},
{
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `distro`}} {{user `drachtio_version`}}",
"script": "scripts/install_drachtio.sh"
},
{
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `distro`}} {{user `jambonz_version`}}",
"script": "scripts/install_app.sh"
},
{
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `distro`}} {{user `install_telegraf`}}",
"script": "scripts/install_telegraf.sh"
},
{
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `distro`}} {{user `leave_source`}}",
"script": "scripts/cleanup.sh"
}
]
}