# shell vs command with uuidgen

**URL:** <https://forum.ansible.com/t/shell-vs-command-with-uuidgen/22741>\
**Category:** Ansible Developer\
**Tags:** aws\
**Created:** [October 7, 2016, 2:47pm UTC](https://forum.ansible.com/t/shell-vs-command-with-uuidgen/22741 "2016-10-07T14:47:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Francisco\_Javier\_Rom](https://avatars.discourse-cdn.com/v4/letter/f/848f3c/32.png) [@Francisco\_Javier\_Rom](https://forum.ansible.com/u/Francisco_Javier_Rom)\
**Post date:** [October 7, 2016, 2:47pm UTC](https://forum.ansible.com/t/shell-vs-command-with-uuidgen/22741/1 "2016-10-07T14:47:24Z")

</div>

I have written next task:

`

- name: Generate uuidgen  
local\_action: command uuidgen -r \> {{ consul\_files\_dir }}/{{ datacenter }}/consul.uuidgen  
become: False  
run\_once: True  
when: consul\_uuidgen\_file.stat.exists == False  
register: consul\_uuidgen  
`

And I got the following error:

`TASK [consul : Generate uuidgen] *********************************************** task path: /home/francisco/git/ansible/roles/consul/tasks/consul_keys.yml:13 fatal: [10.200.220.38 -> localhost]: FAILED! => {"changed": true, "cmd": "\"uuidgen -r > /home/francisco/git/ansible/roles/consul/files/eu-irl-aws/consul.uuidgen\"", "delta": "0:00:00.001540", "end": "2016-10-07 16:39:30.809033", "failed": true, "rc": 127, "start": "2016-10-07 16:39:30.807493", "stderr": "/bin/sh: 1: uuidgen -r > /home/francisco/git/ansible/roles/consul/files/eu-irl-aws/consul.uuidgen: not found", "stdout": "", "stdout_lines": [], "warnings": []}`

Finally, I changed command module to shell module and it worked.

What is the reason?

Regards.  
Francisco

---

<div class="post-metadata">

**Author:** ![Ricardo\_Carrillo\_Cru](https://avatars.discourse-cdn.com/v4/letter/r/87869e/32.png) [@Ricardo\_Carrillo\_Cru](https://forum.ansible.com/u/Ricardo_Carrillo_Cru)\
**Post date:** [October 7, 2016, 2:48pm UTC](https://forum.ansible.com/t/shell-vs-command-with-uuidgen/22741/2 "2016-10-07T14:48:58Z")

</div>

If you use redirections or pipes, you use the shell module.  
If it’s a plain command without shell constructs, then you use command.

HTH

Regards

---

<div class="post-metadata">

**Author:** ![Francisco\_Javier\_Rom](https://avatars.discourse-cdn.com/v4/letter/f/848f3c/32.png) [@Francisco\_Javier\_Rom](https://forum.ansible.com/u/Francisco_Javier_Rom)\
**Post date:** [October 7, 2016, 2:50pm UTC](https://forum.ansible.com/t/shell-vs-command-with-uuidgen/22741/3 "2016-10-07T14:50:55Z")

</div>

You are right Ricardo!

Thanks.  
Francisco
