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’?
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’?
This runs your command on localhost:
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
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.