Archives 2019

Ansible As Scripting Language

Ansible is billed as a configuration manager similar to Puppet or cfengine. But it occurred to me recently that it’s really (at least) two things:

  1. A configuration manager.
  2. A scripting language for the machine room.

Mode 1 is the normal, expected one: here’s a description; now make the machine(s) look like the description. Same as Puppet.

Mode 2 is, I think, far more difficult to achieve in Puppet than it is in Ansible. This is where you make things happen in a particular order, not just on one machine (you’d use /bin/sh for that), but on multiple hosts.

For instance, adding a new user might involve:

  1. Generate a random password on localhost.
  2. Add a user on the Active Directory server.
  3. Create and populate a home directory on the home directory server.
  4. Add a stub web page on the web server.

This is something I’d rather write as an ansible play, than as a Puppet manifest or module.

Which brings me to my next point: it seems that for Mode 1, you want to think mainly in terms of roles, while for Mode 2, you’ll want to focus on playbooks. A role is designed to encapsulate the notion of “here’s a description of what a machine should look like, and the steps to take, if any, to make it match that description”, while a playbook is naturally organized as “step 1; step 2; step 3; …”.

These are, of course, just guidelines. And Mode 2 suffers from the fact that YAML is not a good way to express programming concepts.  But I find this to be a useful way of thinking about what I’m doing in Ansible.

Buying Lunch with Bitcoin?

This weekend, I had occasion to eat at a food truck that had this intriguing sign in the window:

Sign reading "Crypto accepted here, with the icons of various cryptocurrencies" in the window of a food truck.

This intrigued me, because the way I understand it, it takes 10-20 minutes for Bitcoin transactions to go through. That’s why it doesn’t work everyday purchases like, for instance, lunch at a food truck.

I asked the vendor about this, and he told me that “Oh, no. If you have $APP, it goes through right away!” There was a line, so I wasn’t able to ask more questions, but when I read the reviews for the app, a lot of the complaints involved how long it took for transactions to be processed: up to an hour, in some cases.

So I suspect that the food truck guy is confused: yes, you can instantly get a hash that says to transfer X amount of Bitcoin from address A to address B. But the real question is, will that transaction actually get recorded in the consensus ledger? This is similar to the way it only takes a few seconds to write someone a check; but you can’t really spend that money until the check clears, which can take a week. But if I went around to two or three food trucks in the same ten-minute window, I think I could “spend” the same money, and only one of the transactions would clear, in the end.

In short, I think this guy is lucky that he’s only dealt with honest people. Either that, or he figures that there’ll be some amount of theft, and that’s just the price of doing business.