Simple Playbook for Cowsay Galaxy Role Fails

I downloaded & installed the Galaxy role for cowsay as follows here:

ansible-galaxy install jsecchiero.cowsay --force
- downloading role 'cowsay', owned by jsecchiero
- downloading role from
- extracting jsecchiero.cowsay to /home/cloud-user/.ansible/roles/jsecchiero.cowsay
/usr/lib64/python3.6/ RuntimeWarning: The default behavior of tarfile extraction has been changed to disallow common exploits (including CVE-2007-4559). By default, absolute/parent paths are disallowed and some mode bits are cleared. See for more details.
- jsecchiero.cowsay (master) was installed successfully

Here is my playbook:

- hosts: localhost
  become: yes
    - name: cowsay_say
      prompt: "Enter message"
      private: no
    - role: jsecchiero.cowsay
        cowsay_say: "{{ cowsay_say }}"```

When I run the playbook, I get the following error:

```TASK [jsecchiero.cowsay : hello world] ***********************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": true, "cmd": "/usr/games/cowsay HELLO WORLD!", "delta": "0:00:00.002728", "end": "2024-06-20 13:49:54.354890", "msg": "non-zero return code", "rc": 127, "start": "2024-06-20 13:49:54.352162", "stderr": "/bin/sh: /usr/games/cowsay: No such file or directory", "stderr_lines": ["/bin/sh: /usr/games/cowsay: No such file or directory"], "stdout": "", "stdout_lines": []}

Am I not understanding this galaxy role module? I want to use it with a custom message in my playbook tasks but it’s failing for some odd reason.

Is the cowsay package installed on the Ansible controller?

Shouldn’t the message be quoted here:

  shell: "/usr/games/cowsay {{ roar }}"

For example:

  shell: "/usr/games/cowsay '{{ roar }}'"

Note that the GitHub project hasn’t been updated since it was created 5 years ago…

The error sounds like /usr/games/cowsay doesn’t exist, even though the previous step should make sure cowsay is installed. It uses the package module to install cowsay, so the role potentially works on any distro, but I think only Ubuntu and other debian based distros install anything to /usr/games/. Regardless of what distro you may be using, the cowsay binary probably installed somewhere else.

Like @chris said, the role is +5 years old, and you should probably make your own. The owner is fairly active on github though, so you could submit an issue or fork and fix it yourself and send a PR back if you’re feeling up to it.

1 Like

As RHEL 9 doesn’t have a native Cowsay package I have created a Cowsay lookup plugin and a Cowsay module.

Have a look at: GitHub - ansilabnl/demo_one: Demo repository for Ansible training