Here’s a long overdue post about my work environment.
Let’s start from the very beginning. In the same way that you should treat servers like cattle, I try to make it so that my personal work environment is also easily replaceable/recreateable on the fly. So let’s say that your laptop gets hit by a bus. Oh no! Whatever will you do?
Well- if everything you did was on the cloud (eg: on PythonAnywhere), it wouldn’t matter, because you wouldn’t have lost anything. However, let’s say you did do some development locally, or you are a freelancer and you are setting up a new PythonAnywhere account to develop in for a new customer project. How do you automate this setup? (Continuing on the theme of me being lazy)
Look ma- no hands
The process that I’m using right now to setup a new work environment is this:
git clonemy public repo from bitbucket
- this includes stuff like my config files, some useful scripts etc
- notice that since it’s a public repo, you don’t need to authenticate yet, so it’s really just a one line command
- for those poor souls who are setting up their own machine, and may not have git installed (my laptop just broke and I might try using a windows laptop for fun) it is possible to wget or just download the repo…
- run a single script from the repo and watch the magic happen! In less than a minute, it will automatically:
- generate ssh keys for me
- print out the public key for me to add to github/bitbucket
- convert the repo remote url to use ssh so that later on you want to push to the remote you don’t have to type in your password
- I actually put passphrases on ssh keys, but I use ssh-agent so I still don’t have to type in my password :D
- symlink all my dotfiles
- put my scripts into the path
- generate environment variable files for me to load easily later
- setup automatic backup
No manual setup needed to get all up and running.
Wait, there’s more!
One cool thing that I have been doing is to move all the things that this script does into Ansible playbooks. So now when I make changes to my work environment configuration, and I want to make sure the various machines I work on have the correct configs, it’s much easier! Instead of having to login to various machines and pulling from the remote repo, I can just use ansible to send out all my changes! Yay!
Yes, you could setup a git hook, but that’s so lame (we can talk about that in the next post. pfft…). Just imagine the irony of using Ansible to deploy your configs to a single machine (localhost)- how can you not do it? Also by the way, for all you pythonanywhere users out there with ssh access, you can actually deploy on your local machine AND all of your pythonanywhere accounts at the same time. WOOOO- MUCH SCALE!
And for those of you who read my older blog post- yes, I have come a long way from using a bash script that bootstraps itself to setup my configs…
Now, I did promise to talk about tmux and all sorts of stuff, but it seems I am approaching the acceptable limit of how long a blog post should be again. So next time, I hope to continue to show you what my TDD work flow is like, as well as THE EPIC USES I have for PythonAnywhere consoles, which are rumored to include killing multiple cows simultaneously as well as conducting super secret covert missions to send outgoing mail when the conference wifi is blocking outgoing SMTP traffic.