# Ansible Command Module Argument Entry

**URL:** <https://forum.ansible.com/t/ansible-command-module-argument-entry/27567>\
**Category:** Ansible Project\
**Created:** [May 19, 2018, 5:10pm UTC](https://forum.ansible.com/t/ansible-command-module-argument-entry/27567 "2018-05-19T17:10:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carlton\_Patterson1](https://avatars.discourse-cdn.com/v4/letter/c/ecccb3/32.png) [@Carlton\_Patterson1](https://forum.ansible.com/u/Carlton_Patterson1)\
**Post date:** [May 19, 2018, 5:10pm UTC](https://forum.ansible.com/t/ansible-command-module-argument-entry/27567/1 "2018-05-19T17:10:43Z")

</div>

I’m trying to use Ansible’s ‘command’ module to to issue the command ‘hostname -s’ on a machine.

Can someone please take a look at the module and its arguments and let me know where I would enter the argument ‘hostname -s’?

[![](https://lh3.googleusercontent.com/-_4bkhHO14Jk/WwBajdB-R3I/AAAAAAAALP0/p2eghSbv95Y-ZQa7CWuIr_C3FH9ygz2TACLcBGAs/s320/anscommand.png)](https://lh3.googleusercontent.com/-_4bkhHO14Jk/WwBajdB-R3I/AAAAAAAALP0/p2eghSbv95Y-ZQa7CWuIr_C3FH9ygz2TACLcBGAs/s1600/anscommand.png)

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [May 19, 2018, 5:25pm UTC](https://forum.ansible.com/t/ansible-command-module-argument-entry/27567/2 "2018-05-19T17:25:34Z")

</div>

This runs your command on localhost:

---

<div class="post-metadata">

**Author:** ![jean-yves](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jean-yves](https://forum.ansible.com/u/jean-yves)\
**Post date:** [May 19, 2018, 5:37pm UTC](https://forum.ansible.com/t/ansible-command-module-argument-entry/27567/3 "2018-05-19T17:37:10Z")

</div>

Hi,

Why using command to have the hostname ? (command and shell module should be avoided each time it is possible) Fact already have some variable you can use, no ?

Example on my personnal machine :

“ansible\_fqdn”: “DellJylenhof”,  
“ansible\_hostname”: “DellJylenhof”,  
“ansible\_nodename”: “DellJylenhof”,

```auto
As I have not parameter domain on my machine, regarding documentation what you want is "ansible_hostname"

Regards,

JYL

```

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [May 19, 2018, 10:40pm UTC](https://forum.ansible.com/t/ansible-command-module-argument-entry/27567/4 "2018-05-19T22:40:40Z")

</div>

While yes running hostname as a command seems redundant in this example (if you gather facts). If you do want to run a command anyway you want to put it in the free form box. The command/shell/script/raw are some of the only modules that use this form.
