Automation - fabric, django and more

17

Click here to load reader

description

Presentation about automation and slight look at Fabric and Django

Transcript of Automation - fabric, django and more

Page 1: Automation - fabric, django and more

Automation, Fabric and Django...

...or how to make our lives better

Page 2: Automation - fabric, django and more

About meeng. Ilian Iliev

● Web Developer for 8 years● Python/Django fan for 3 years● Ubuntu user for 2 years● Part of Cybert Arts Web Team● [email protected]● http://ilian.i-n-i.org● https://github.com/IlianIliev/

Page 3: Automation - fabric, django and more

Repetition

"Repetition leads to boredom, boredom to horrifying mistakes, horrifying mistakes to God-I-wish-I-was-still-bored" Will Larson

Page 4: Automation - fabric, django and more

Automation

● Daily tasks● Server setup● System update/maintenance tasks● New project creation● Deployment procedures

All of the above on multiple stations all around the world cloud

Page 5: Automation - fabric, django and more

Show me the Money or

What we Gain

Developers QAs Admins● easy deployment● less mistakes● no more begging the

admins

● new build here and now● automate smoke test

process

● less work● move server setup in the

hands of the developers● no more "make me a

new build" requests● focus only on specific

problems

Page 6: Automation - fabric, django and more

Fabric

Fabric is a Python (2.5 or higher) library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks.

Page 7: Automation - fabric, django and more

Why Fabric

● It is Python(Python is awesome)● It is simple● It is light● It is quick● It is useful

Page 8: Automation - fabric, django and more

Simple Example ...

from fabric.api import run

def host_type(): run('uname -s')

#fab -H localhost, linuxbox host_type

Page 9: Automation - fabric, django and more

... and Advanced One

from fabric.api import sudo

def add_user(user, make_sudoer = False): with settings(warn_only=True): result = sudo('useradd -m %s' % (user)) if not result.failed: if make_sudoer: sudo('echo "%s ALL=(ALL) ALL" >> /etc/sudoers' % user) password = generate_password() sudo('echo "%s:%s" | chpasswd' % (user, password)) return password return False

Page 10: Automation - fabric, django and more

PHP Web Applications

Web Server PHP Files DB

Page 11: Automation - fabric, django and more

Python Web Applications

Web Server uWSGI Python App DB

Page 12: Automation - fabric, django and more

The Tools

● Ubuntu● Python● Fabric● Virtual environment● Django● Nginx● uWSGI● MySQL● GIT

Page 13: Automation - fabric, django and more

Starting New Project

1. Isolation - virtualenv2. Install required packages3. Custom settings - project template4. Database setup5. Nginx/uwsgi files creation

Page 14: Automation - fabric, django and more

Your Box(in the Cloud)

● VPS● OS Image● SSH

Page 15: Automation - fabric, django and more

From pure box to working server

1. Install required packages2. Setup database server3. Deploy application4. Run application5. Go to celebrate

Page 16: Automation - fabric, django and more

Demo

fab -H <host> -f <fabfile location> startproject:<project_name>

fab -H <host> -f <fabfile location> setup_server

fab -H <host> -f <fabfile location> deploy_project:<project_name>,<repo_url>

Page 17: Automation - fabric, django and more

Links & Copyrights

Fabric: http://docs.fabfile.org/en/1.4.3/index.html

Fabric scripts used during presentation: https://github.com/IlianIliev/ubuntu-fabric-and-django

Icons copyrights belongs to:● http://www.heartinternet.co.uk/● http://www.iconshock.com/● http://barrymieny.deviantart.com/