Cowsay and Ansible

03 May 2014 in TIL

One of the most common questions I get from colleagues who are running their first Ansible playbook is "why is there a cow on my screen?". Most of them didn't even know about cowsay, yet it ended up installed at some point. If you're wondering what I'm on about, it looks like this:

bash
____________
< PLAY [all] >
------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||

If you don't like the cows, you can disable them for the current play by setting ANSIBLE_NOCOWS.

bash
ANSIBLE_NOCOWS=1 ansible-playbook -i /path/to/hosts playbook.yml

Alternatively, you can disable it for all runs by adding the following to your ~/.bashrc (or equivalent) file.

bash
export ANSIBLE_NOCOWS=1

Once you're done, we should be back to normal, with your output looking like the following:

bash
GATHERING FACTS ***************************************************************
ok: [127.0.0.1]

But I do like the cows!

If you do like cowsay but want to mix it up a bit, try prepending your command with ANSIBLE_COW_SELECTION=random. This will choose a random ASCII drawing to use.

bash
ANSIBLE_COW_SELECTION=random ansible-playbook -i /path/to/hosts playbook.yml

To see all of the available "cows", run cowsay -l and it will give you a list. Here's what it shows on my system

Cow files in /usr/share/cowsay/cows: apt beavis.zen bong bud-frogs bunny calvin cheese cock cower daemon default dragon dragon-and-cow duck elephant elephant-in-snake eyes flaming-sheep ghostbusters gnu head-in hellokitty kiss kitty koala kosh luke-koala mech-and-cow meow milk moofasa moose mutilated pony pony-smaller ren sheep skeleton snowman sodomized-sheep stegosaurus stimpy suse three-eyes turkey turtle tux unipony unipony-smaller vader vader-koala www

Personally, I like to use tux:

bash
ANSIBLE_COW_SELECTION=tux ansible-playbook -i /path/to/hosts playbook.yml

Which results in:

bash
< GATHERING FACTS >
-----------------
\
\
.--.
|o_o |
|:_/ |
// \ \
(| | )
/'\_ _/`\
\___)=(___/

Why does this even exist?

Why not? cowsay is a bit of fun in an environment which is typically quite boring. Plain text in, plain text out. If you don't want to use them, set ANSIBLE_NOCOWS=1, but there's a lot of fun to be had setting ANSIBLE_COW_SELECTION=random on your system