Ansible & Amazon EC2
Orchestrating NetBSD into the cloud
Hubert Feyrer
pkgsrcCon 2013, Berlin, March 2013
Abstract:
Introduce Ansible as system orchestration tool that supports the
Amazon EC2 cloud and NetBSD. Show how to get a basic NetBSD system
setup, an example database server, web application server and
example web application deployed with Ansible. Introduce tools to
use Amazon's Xen-based EC2 cloud from NetBSD and with Ansible. Show
the roadmap to combine all those tools and deploy NetBSD-based
database- and webservers with the example application.
Presentation
Milestone 1: Ansible with DB+Web on local VM
NetBSD 6.0 installation:
* sysinst
base, etc, manpages - no compiler, no x
pkg installation: get pkgin
* allow root logins from ssh:
/etc/ssh/sshd_config:
PermitRootLogin yes
sh /etc/rc.d/sshd restart
* install ansible and all its depends
scp feyrer@10.0.0.5:/usr/pkgsrc/packages/NetBSD/All/ansible-1.0.tgz /tmp
pkg_info -qn ansible-1.0.tgz | sed -e 's,\[[^]]*\],,' -e 's,[->][^->]*$,,' | xargs -n 1 pkgin -y install
pkg_add ansible-1.0.tgz
pkgin list
Run playbooks:
ansible-playbook -k -i hosts-HF config-netbsd-basic.yml (log)
ansible-playbook -i hosts-HF config-netbsd-dbserver.yml (log)
ansible-playbook -i hosts-HF config-netbsd-webserver.yml (log)
Access webapp:
links -dump http://10.0.0.181/phptest.php
links -dump http://10.0.0.181/webapp/ (log)
Auxilliary files:
db/dump-names.sql
webapp/phptest.php
webapp/webapp.php
Milestone 2: Basic setup for Amazon EC2
Setup Amazon EC2 & related settings (more, more)
Make sure SSH Agent knows key:
eval `ssh-agent`
ssh-add .../key-eucaHF.pem
Check security groups:
euca-describe-groups
Run playbooks:
ansible-playbook -i hosts-HF config-ec2-prepare1vm.yml (log)
env ANSIBLE_HOSTS=./ec2.py ansible-playbook config-ec2-basic.yml (log)
Milestone 3: One EC2 instance with both DB+Web
Setup Amazon EC2 & related settings (more, more)
Prepare:
sudo sh /etc/rc.d/ntpd stop
sudo sh /etc/rc.d/ntpdate restart
sudo sh /etc/rc.d/ntpd start
eval `ssh-agent`
ssh-add .../key-eucaHF.pem
euca-describe-groups
euca-describe-instances
Run:
ansible-playbook -i hosts-HF config-ec2-prepare1vm.yml (log)
env ANSIBLE_HOSTS=./ec2.py ansible-playbook config-ec2-basic.yml (log)
env ANSIBLE_HOSTS=./ec2.py ansible-playbook config-ec2-dbserver.yml (log)
env ANSIBLE_HOSTS=./ec2.py ansible-playbook config-ec2-webserver.yml (log)
Test:
links -dump http://ec2-XXX-XXX-XXX-XXX.compute-1.amazonaws.com/
links -dump http://ec2-XXX-XXX-XXX-XXX.compute-1.amazonaws.com/phptest.php
links -dump http://ec2-XXX-XXX-XXX-XXX.compute-1.amazonaws.com/webapp/
Milestone 4: Ansible+EC2 with different instances for DB and Web
Prepare:
sudo sh /etc/rc.d/ntpd stop
sudo sh /etc/rc.d/ntpdate restart
sudo sh /etc/rc.d/ntpd start
eval `ssh-agent`
ssh-add ../../euca2ools/key-eucaHF.pem
euca-describe-groups
euca-describe-instances
Run:
ansible-playbook -i hosts-HF config-ec2-prepare-db+web-vm.yml (log)
env ANSIBLE_HOSTS=./ec2.py ansible-playbook config-ec2-basic.yml (log)
env ANSIBLE_HOSTS=./ec2.py ansible-playbook config-ec2-dbserver.yml (log)
env ANSIBLE_HOSTS=./ec2.py ansible-playbook config-ec2-webserver.yml (log)
env ANSIBLE_HOSTS=./ec2.py ansible-playbook config-ec2-connections.yml (log)
Auxilliary files:
config-ec2-prepare1vm.yml (called from config-ec2-prepare-db+web-vm.yml)
files/do-connections.sh.j2
Test:
links -dump http://ec2-....amazonaws.com/
links -dump http://ec2-....amazonaws.com/phptest.php
links -dump http://ec2-....amazonaws.com/webapp/
More
This page has been accessed
11657
times.
Copyright 2013 Hubert Feyrer