Today I'm using Ansible for this and other devops tasks. Along the way I've experimented with Chef, Puppet, Saltstack and Docker images, but I've found that for me, as a solo developer working in smaller projects, a lightweight tool like Ansible is a great fit.
I'm starting out as an independent web developer and I recently scared away a client by giving a quote for a rather simple site that was quite a bit higher than they expected. It was basically brochureware that they could have done themselves in a hosted solution like Wordpress.com or Google sites. Except for one critical feature, that made me think that Django would be a nice fit, and that some proper web development could be motivated.
When looking at the tasks I've listed in my rough estimate it's pretty obvious to me that most of the hours in there are stuff that is not specific to this clients website. This got me thinking that I should have a script to automate the process of setting up and deploying new Django projects.
A couple of things would still have to be done manually like:
Set up a new VPS (or in most cases just go with virtualhosts on an existing VPS).
Edit DNS settings to point clientsdomain.com and test.clientsdomain.com to the new VPS.
Set up SSH-keys
Edit a config file.
The script would then do stuff like:
Install some required packages on the new VPS
Install default a iptables firewall on the new VPS
Add nginx/apache config for clientsdomain.com and test.clientsdomain.com
Set up new up databases for production and test on the VPS and for development on my local machine.
Create a new Django project and put it on Bitbucket.
Set up settings.py and local_settings.py for production, test and development
Set up offsite backuproutines for production database and uploaded files directory.
Enable some default apps: flatpages, admin
Add some boilerplate templates, a couple of boilerplate flatpages and a navbar.
Add the 960.gs CSS-framework
Add jQuery
Set up djapian or Haystack (including cron job for automatic updating) for search.
Set up a new Google analytics profile.
Include possibility to replicate databases between production, test and development
Set up Pingdom monitoring
I've used Rake and Fabric for somewhat similar (but less ambitious) stuff in the past and I'm thinking that Fabric might be a pretty good fit for this task as well, but I'd still like your input. Are there other tools I should look into? I've heard good things about Puppet but just looking at their site (it contains the word Enterprise ) gives me the feeling that it might be overkill for a one man operation.
But we must admit that, when starting a new Django project, we need to run a lot of commands on the terminal, create some folders and files manually, and make recurrent changes on some other ones. And most of these initial tasks are repetitive, which make them a great opportunity for automation.
Gunicorn is the recommended HTTP server for use with Django on Heroku (as referenced in the Procfile above). It is a pure-Python HTTP server for WSGI applications that can run multiple Python concurrent processes within a single dyno (see Deploying Python applications with Gunicorn for more information).
Heroku. For hosting web applications built on Django, you will need to use a platform that lets you deploy the app. One of these platforms is Heroku. Heroku is a cloud platform on which users can build and deploy applications.
Puppet may seem daunting and overkill for small projects since it's so often used for huge deployments, but I use it to manage just one machine in standalone mode without a client server setup so that I don't have to deal with SSL certs and multiple machines, which keeps things a lot simpler, but still gives me the benefit that I can do really fast disaster recovery or move my hosting without a lot of effort. There's some great reasons (idempotency, cross platform support, full lifecycle management, abstraction, concise DSLs) for using modern configuration management systems over systems that are essentially scripts that do ssh in a loop or relying on platforms that lock you in.
Check out learning puppet for a quick ramp up including examples and a VM playground. You can get really useful things done with simple Puppet scripts (manifests) that run standalone, and then start learning all the advanced features once you need them.
Another nice thing is that a lot of Puppet manifests and modules have already been written by others, and they're shared on the Puppet Forge and by many other advanced Puppet users.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With