Freeradius docker container
Sometimes for testing purposes network engineer needs to deploy small RADIUS server with SQL backend and some sort of web management. It can take from one hour or up to a whole day, just because since last time network engineer had done it, technology moved forward and this time one will account for new cobweb. So spending time on IT management should be minimal as much as possible. This article is about how to deploy Freeradius application with MySQL as backend and PMA as web management in short order. Short, I mean, are several minutes.
Imagine you have a root access to Linux machine with Internet connection. It does not matter it's virtual or physical. I would prefer to manage box with deadly simple orcherstration tool - Ansible. So you've better to have it on the box.
Install packages.
apt-get -y update
apt-get install -y python-yaml python-jinja2 python-httplib2 python-keyczar python-paramiko python-setuptools python-pkg-resources git python-pip
Clone current ansible from Github.
git clone http://github.com/ansible/ansible.git
cd ansible
git submodule update --init
Source ansible environment.
. ./hacking/env-setup
Create global inventory file with localhost.
echo '[local]\nlocalhost\n' > /etc/ansible/hosts
Next step is to install fresh Docker ecosystem. If you do not already installed proceed with this recipe.
ansible-galaxy install angstwad.docker_ubuntu
Create simple playbook with your favorite text editor...
cat /tmp/docker.yml
---
- hosts:local
connection: local
roles:
- angstwad.docker_ubuntu
... and just execute it.
ansible-playbook /tmp/docker.yml
Now you should have fresh and up-to-date Docker.
So here where really magic begins. We create playbook with three simple tasks. These tasks actually will start MySQL, PMA and Freeradius. On the output you will get three running containers connected to each other and ready to serve.
Once again take your favorite editor and create following playbook:
cat fr_mysql_pma.yml
---
- hosts: local
connection: local
vars:
- mysql_root_pass: password123
tasks:
- name: Start MySQL
docker: image=mysql name=freeradius-mysql volumes="/var/lib/mysql:volumes/mysql" env="MYSQL_ROOT_PASSWORD={{ mysql_root_pass }}"
- name: Start PMA
docker: image=corbinu/docker-phpmyadmin name=pma env="MYSQL_USERNAME=root" links=freeradius-mysql:mysql ports=80:80
- name: Start Freeradius
docker: image=ramelito/docker-freeradius name=frv2 links=freeradius-mysql:mysql ports=1812:1812/udp,1813:1813/udp command="freeradius -f"
Run it:
ansible-playbook fr_mysql_pma.yml
Check it:
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fc250eae3986 ramelito/docker-freeradius:latest "./entrypoint.sh fre 7 minutes ago Up 7 minutes 0.0.0.0:1812->1812/udp, 0.0.0.0:1813->1813/udp frv2
5526ad668362 corbinu/docker-phpmyadmin:latest "/bin/sh -c phpmyadm About an hour ago Up About an hour 0.0.0.0:80->80/tcp pma
bdaf6aeaf452 mysql:latest "/entrypoint.sh mysq About an hour ago Up About an hour 3306/tcp freeradius-mysql
This relatively simple and timesaving scenario does not require much from user's experience and can be easily deployed either inside virtualbox image or physical lab machine. Have a nice BRASing.
http://www.ansible.com/2014/02/12/installing-and-building-docker-with-ansible https://docs.docker.com/userguide/dockerlinks/ http://wiki.freeradius.org/guide/FAQ