Getting Ansible to work with DigitalOcean API v2

Today I finally decided to solve something I’ve been putting off for a while. I recently migrated to reasonably-priced cloud hosting solution DigitalOcean. Version 1 of their API will stop working on November 9. The tool I use to automate my servers and developer installs is Ansible currently uses version 1 will not support version 2 of the DigitalOcean API until Version 2.0, which was supposed to have been released by now. My guess is that since it is almost November, the ansible team decided to wait until AnsibleFest to release 2.0. Unfortunately, that’s on November 19th.

So there’s a 10 day window + developer time where any playbooks I’m using will no longer work on the live site. Not cool.

So I decided to start up a project to test a working fix for this.

The first thing I needed to do was install Ansible 2.0 from source using the instructions on the website.

$ git clone git://github.com/ansible/ansible.git --recursive
$ cd ansible
$ source ./hacking/env-setup
$ sudo pip install paramiko PyYAML Jinja2 httplib2 six
$ make
$ sudo make install

This installed Ansible into my /usr/local/bin which I verified was correct by typing ansible --version

Next I installed the python DigitalOcean API, dopy:

$ sudo pip install dopy
view raw 2_install_dopy hosted with ❤ by GitHub

Log in to DigitalOcean and get a v2 token (there is no client_id in v2) and add the below to your .profile replacing the api_token with the one you generated.

$ export DO_API_VERSION='2'
$ export DO_API_TOKEN='api_token'

Generate a RSA key pair and upload it to DigitalOcean if you haven’t already done so and copy the following provision script into provision.yml (example modified from Jeff Geerling’s Ansible for DevOps chapter 7.) remembering to modify the ssh key signature.
https://gist.github.com/e86245d7652a755552ec#file-4_provision-yml

Then run the script with the command:

$ ansible-playbook provision.yml
view raw 5_run_playbook hosted with ❤ by GitHub

This will create an ubuntu droplet and log in and run a install on it all automated like. You’ll notice that unlike Jeff’s script, you can refer to regions, images, sizes, and keys by name instead of looking up esoteric numbers for them.

Good luck and have fun!

Join Kiva for a Developer Drink-up

Image:Kiva.org logo.svg

Halle is interning at Kiva, which, given her personality, I figure is her dream internship.

Kiva is a microfinance site for the poor that allows anyone to give flat-rate microloans via PayPal. As a coincidence of the “I seem to have a lot of cash” and my New Year’s resolution to be a more responsible person, I’ve recently started to put a tiny fraction of my income into Kiva. You can view my lender page here to see that I currently participate in 17 microloans.

I mention all this because Kiva will be sponsoring a Developers Happy Hour this Thursday at their headquarters in San Francisco. Considering I give 5% of my money lent back to Kiva, I’m going for the drinks. 🙂

(Find out more about the concept from Muhammad Yunus’s Nobel lecture, the FrontLine program on social entrepreurship, conservative columnist Nicholas Kristof’s editorial in the New York Times, and the books Banker To the Poor, and Creating a World Without Poverty.)

Continue reading about Moneywatch.com after the jump

How much is your millisecond?

At Tagged, I’ve been working on the project for the last month. Basically it allows us to cache dynamic parts of throughout the site and keep the caches from having stale data. Since we call the APIs both externally and internally—over 20 calls to generate a user’s profile page alone—the caching is turned on at the API level.

The initial hit to the system was severe.

Basically, I was causing the profile page to take 30 extra milliseconds to render. The profile page accounts for 17% of all page views on the site where we do about 220 million “views” a day. This 30 milliseconds, believe it or not, was dropping profile page views by 5%. And it took about 20 hours of back and forth before I finally resolved to rewrite the whole thing so that it can be rolled out gradually without any performance hit.

That means I cost the company one and a half million ad impressions. 🙁

The second day’s cached piece is actually measurable on the live site with tools I wrote. I am saving between 17 and 900 milliseconds depending on the state of the backend and load on the server.

Since I can’t measure how much actual page views I’m adding back into the system, I was curious about how much extra server capacity these changes are getting me.

In other words, how much is a millisecond?

Continue reading about Measuring milliseconds after the jump.

The Dutch

“Please tell me you guys aren’t getting in bed with Google. I actually find myself rooting for annoying-ass Fuckerberg because of this Open Syphilis shit.”
—e-mail from a friend

I’ve had a number of people who know what I do as a day job ask me what I think about Google’s OpenSocial initiative. Maybe it’s because they know I’m so opinionated and they just want to hear me go off.

What’s strange is how few of those actually involved with the project have asked me what I thought (Answer: none of them). They know that I’m not a photographer, or a socialite, or “they guy who does Lunch 2.0” and yet they’ve been strangely silent before, during, and after the announcement. It turned out I only found out about this at all, because of people who know me only as a photographer, socialite (laugh!), and “the guy who does Lunch 2.0.”

Now I won’t go out to state my opinion about OpenSocial beyond the question: You parlayed my friendship for this? I guess you can guess what I think about OpenSocial from that.

Chalk this up to another incessant reminder of why I hate the high school antics of the Valley. Had any of them bothered to ask me about this, here is a tip I could have given them: when you make a list, there are much bigger companies in the Valley than Facebook that are going to be disappointed they weren’t invited to the party.

Slick move, ace!

I alluded to this bitterly in a previous post, but to further highlight the absurdity of the who was and wasn’t invited to the “Open”(laugh!)Social, I was talking to another friend:

“They leaked this well in advance to the ‘largest social network in Holland.’ In Holland??? Can you believe?”

D—: “Haha. I sort of like the Dutch. They sort of sound like Germans but act nicer.”

“The only thing I know about the Dutch is that they’re awfully tall.”

D—: “Maybe it’s to keep their heads above sea level.”

Ahh, trust my friends to put everything in perspective.

(After that conversation he sent me this to cheer me up.)