Post-Apocalyptic Cowsay

Pre-apocalyptic cow says moo

While tidying up my mac-ansible repository in preparation for a talk I’m giving on it at the London Ansible Meetup tonight, I found my two-headed cow. It’s a bit of ASCII fan-art I made for the Fallout game series, whose post-apocalyptic setting has all the cows mutated this way.

(They’re pretty ugly creatures, so rather than post an image, here’s a link to the Fallout Wikia on them, for those curious enough to click.)

I made it to add a pinch of mutant fun to every Ansible run, which automatically uses cowsay for output if it’s installed. For example:

< TASK [Update the server] >
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Ansible can be configured to use a different ‘cow’ with ANSIBLE_COW_SELECTION. cowsay comes with many by default, for example small, or dragon (see previously). You can list all the options with cowsay -l.

How to Get Yourself a Two-Headed Cow

cowsay is written in Perl, and if you check out man cowsay you’ll find you can configure the cow graphic in a so-called cowfile with templated Perl code. Below is my two-headed cowfile. To use it, copy it into a file called two-heads.cow saved in the default COWPATH directory, which you can also find from man cowsay.

For me, using cowsay from homebrew on macOS, that path is /usr/local/Cellar/cowsay/3.04/share/cows/. Yes, the path includes the version, but don’t worry you won’t need to update it much - I haven’t seen a new version of cowsay in three years, it’s very stable software!

# Two heads
$the_cow = <<"EOC";
         ($eyes)($eyes)    )\\/\\
          $tongue  ||    ||

You can them immediately use it with cowsay:

$ cowsay -f two-heads 'Hello reader!'
< Hello reader! >
         (oo)(oo)    )\/\
              ||    ||

Or with Ansible:

$ ANSIBLE_COW_SELECTION=two-heads ansible-playbook playbook.yml
< PLAY [] >
         (oo)(oo)    )\/\
              ||    ||

< TASK [Gathering Facts] >
         (oo)(oo)    )\/\
              ||    ||

ok: []


You can export that environment variable in your shell configuration file to permanently use the cow of your choice.

The astute will have noted that the cowfile templates more than just the cow’s “thoughts,” but also the eyes and tongue. This is so you can use various flags that affect the cow’s state, for example -d for dead:

$ cowsay -d -f two-heads 'The radiation got to me'
< The radiation got to me >
         (xx)(xx)    )\/\
          U   ||    ||

Unfortunately Ansible has no way of passing these flags through.

For Special Occasions

I must admit though, the cows do sometimes get in the way, especially when trying to paste Ansible output to others. I changed some time ago to normally running Ansible with ANSIBLE_NOCOWS=1 set, as per the FAQ about getting rid of the cows. I reserve my two-headed cow for special occasions. (And that is a sentence I never thought I’d write.)



Learn how to make your tests run quickly in my book Speed Up Your Django Tests.

Subscribe via RSS, Twitter, or email:

One summary email a week, no spam, I pinky promise.