automatic kamailio deployments with puppet

19
Automatic Kamailio Deployments with Puppet Giacomo Vacca Senior Network Applications Developer

Upload: giacomo-vacca

Post on 11-May-2015

449 views

Category:

Internet


3 download

DESCRIPTION

Description: Kamailio is a robust, powerful application; virtualization and cloud computing make it extremely easy and quick to setup Kamailio-based solutions. Scaling, geographic distribution and multiple environments (e.g. development, staging/QA, production), though, present some deployment challenges. Puppet provides a solution that dramatically cuts deployment time, reduces occurrences of errors, while at the same time documenting the configuration status. This presentation describes what we did in Truphone Labs to move from a freshly created virtual machine to a running Kamailio instance, automatically and in minutes. Firewall, nagios, syslog, monit, sec, and other related services are also automatically configured.

TRANSCRIPT

Page 1: Automatic Kamailio Deployments With Puppet

Automatic Kamailio Deployments with Puppet

Giacomo VaccaSenior Network Applications Developer

Page 2: Automatic Kamailio Deployments With Puppet

© 2013 Truphone Limited. All Rights Reserved. 03 April 2014

“He’s seen more SIP transactions than some SBCs in the market” (cit.)

- Leads Network Dev Team at Truphone Labs

- Hacking Kamailio, Asterisk, FreeSWITCH for 10+ ys

- Hacking ejabberd, more recently

@giavac

Page 3: Automatic Kamailio Deployments With Puppet

© 2013 Truphone Limited. All Rights Reserved. 03 April 2014

Truphone

Page 4: Automatic Kamailio Deployments With Puppet

© 2013 Truphone Limited. All Rights Reserved. 03 April 2014

labs.truphone.com

Page 5: Automatic Kamailio Deployments With Puppet

© 2013 Truphone Limited. All Rights Reserved. 03 April 2014

“You know you’re in trouble when...

you realize you’ve become good at 3-way diffs”

The Problem

Page 6: Automatic Kamailio Deployments With Puppet

© 2013 Truphone Limited. All Rights Reserved. 03 April 2014

• Deploy and customize in-place

• Extract variables into included defines file

• A debian package with config per host

No (automatic) documentation!

The Problem – in the past

Page 7: Automatic Kamailio Deployments With Puppet

© 2013 Truphone Limited. All Rights Reserved. 03 April 2014

• Open Source configuration management tool

• Defines the final status (‘what’, not ‘how’)

• Idempotent (i.e. safely run multiple times)

puppetlabs.com

The Solution - Puppet

Page 8: Automatic Kamailio Deployments With Puppet

© 2013 Truphone Limited. All Rights Reserved. 03 April 2014

• Puppet code is contained in MANIFESTS

• Puppet functionalities are organized in MODULES

• “Compiled” manifests are CATALOGUES

The Solution - Puppet

Page 9: Automatic Kamailio Deployments With Puppet

© 2013 Truphone Limited. All Rights Reserved. 03 April 2014

Master/Slave vs Standalone

Page 10: Automatic Kamailio Deployments With Puppet

© 2013 Truphone Limited. All Rights Reserved. 03 April 2014

# nodes.pp

node ‘k01.domain.com’ {

include ‘kamailio’

}

• As many environments as you want

–Each environment defines a Site

•A Site defines a group of Nodes

– Every host is a Node

PuppetEnvironments, Sites, Nodes

Page 11: Automatic Kamailio Deployments With Puppet

© 2013 Truphone Limited. All Rights Reserved. 03 April 2014

• Simple manifests

• Independent from data

• Extract data into nodes definition

PuppetSeparate logic from data

Page 12: Automatic Kamailio Deployments With Puppet

© 2013 Truphone Limited. All Rights Reserved. 03 April 2014

https://github.com/trulabs/puppet-kamailio

1. Deploy pre-requisites

2. Install packages (deb, rpm)

3. Set configuration files (kamailio.cfg, tls.cfg)

4. Define ‘service’ (“should be running”)

Kamailio with Puppet

Page 13: Automatic Kamailio Deployments With Puppet

© 2013 Truphone Limited. All Rights Reserved. 03 April 2014

Kamailio with PuppetThe system around Kamailio

Other areas (see 3rd party modules at PuppetForge):

• apt/yum

• TCP keepalives

• Firewall (iptables)

• monit

• nagios

• fail2ban

• logrotate

• sec

• SSL certificates

• Swappiness» What else? Tell me at the Q&A session.

Useful tools:

Check your modules against Best

Practices with ‘puppet-lint’.

http://puppet-lint.com/

Page 14: Automatic Kamailio Deployments With Puppet

© 2013 Truphone Limited. All Rights Reserved. 03 April 2014

Video: http://vimeo.com/giavac/akdp

1. Build VM

2. SSH into VM

3. git clone Puppet repo

4. Run Puppet NOOP mode

5. Run Puppet

Build and deploy a new instance

Page 15: Automatic Kamailio Deployments With Puppet

© 2013 Truphone Limited. All Rights Reserved. 03 April 2014

Summary

Automation is easy

Deployments MUST be automated

Deployments SHOULD be boring

Deployments MAY be fun

Puppet does the job

(Diagram source: http://info.puppetlabs.com/2013-state-of-devops-report.html)

Page 16: Automatic Kamailio Deployments With Puppet

© 2013 Truphone Limited. All Rights Reserved. 03 April 2014

Q&A

@giavac

[email protected] *

https://labs.truphone.com/about/

Page 17: Automatic Kamailio Deployments With Puppet

© 2013 Truphone Limited. All Rights Reserved. 03 April 2014

ADDITIONAL SLIDES

Page 18: Automatic Kamailio Deployments With Puppet

© 2013 Truphone Limited. All Rights Reserved. 03 April 2014

Kamailio with PuppetKamailio module – repo/apt.pp

class kamailio::repo::apt inherits kamailio::repo {

include '::apt'

# Note the 40!

apt::source { 'kamailio40_wheezy':

location => 'http://deb.kamailio.org/kamailio40',

release => 'wheezy',

repos => 'main',

required_packages => 'debian-keyring debian-archive-keyring',

key => '07D5C01D',

key_server => 'http://deb.kamailio.org/kamailiodebkey.gpg',

include_src => true,

}

Apt::Source['kamailio40_wheezy'] -> Package<|tag == 'kamailio'|>

}

Page 19: Automatic Kamailio Deployments With Puppet

© 2013 Truphone Limited. All Rights Reserved. 03 April 2014

Kamailio with PuppetKamailio module – config.pp

• Manages configuration files

• Can install from files or templates

Example: templatize a kamailio.cfg define

<% if with_tls %>#!define WITH_TLS<% end %>