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",

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

Regards,

JYL


Le 19/05/2018 à 19:25, Karl Auer a écrit :
> This runs your command on localhost:
>
> ---
> # Test where vars are located
> - hosts: localhost
>
>   tasks:
>     - name: run hostname command
>       command: hostname -s
>
> If you substitute the appropriate "hosts:" value , it will run it on
> another machine.
>
> Regards, K.
>
>
> On Sun, May 20, 2018 at 3:10 AM, Carlton Patterson
> <cpatte7...@gmail.com <mailto:cpatte7...@gmail.com>> wrote:
>
>     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/s1600/anscommand.png>
>
>
>     -- 
>     You received this message because you are subscribed to the Google
>     Groups "Ansible Project" group.
>     To unsubscribe from this group and stop receiving emails from it,
>     send an email to ansible-project+unsubscr...@googlegroups.com
>     <mailto:ansible-project+unsubscr...@googlegroups.com>.
>     To post to this group, send email to
>     ansible-project@googlegroups.com
>     <mailto:ansible-project@googlegroups.com>.
>     To view this discussion on the web visit
>     
> https://groups.google.com/d/msgid/ansible-project/4bb2a137-fbf3-4721-8531-d00835929b4f%40googlegroups.com
>     
> <https://groups.google.com/d/msgid/ansible-project/4bb2a137-fbf3-4721-8531-d00835929b4f%40googlegroups.com?utm_medium=email&utm_source=footer>.
>     For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>.
>
>
>
>
> -- 
> Karl Auer
>
> Email  : ka...@2pisoftware.com <mailto:ka...@2pisoftware.com>
> Website: http://2pisoftware.com <http://2pisoftware.com/>
>
> GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
> Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA
> -- 
> You received this message because you are subscribed to the Google
> Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ansible-project+unsubscr...@googlegroups.com
> <mailto:ansible-project+unsubscr...@googlegroups.com>.
> To post to this group, send email to ansible-project@googlegroups.com
> <mailto:ansible-project@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08TtTdwSmU8HohXz6RYBCpWXG1U%2BhBQm%3D_ZiUti%3DrHr%3DqQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08TtTdwSmU8HohXz6RYBCpWXG1U%2BhBQm%3D_ZiUti%3DrHr%3DqQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7b382839-4139-1775-275b-d44dea1197a6%40lenhof.eu.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to