Cowsay and Ansible

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:

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

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

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.

export ANSIBLE_NOCOWS=1

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

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.

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:

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

Which results in:

< 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

Michael is a polyglot software engineer, committed to reducing complexity in systems and making them more predictable. Working with a variety of languages and tools, he shares his technical expertise to audiences all around the world at user groups and conferences. You can follow @mheap on Twitter

Thoughts on this post

JP Mens 2014-05-07

When I implemented ANSIBLE_NOCOWS, I also ensured you could set that globally in ansible.cfg; in the [defaults] section, just add “nocows = 1” somewhere. 🙂

Signed: TheCowKiller.

Leave a comment?

Leave a Reply