cancel
Showing results for 
Search instead for 
Did you mean: 
Trevor
Starfighter Starfighter
Starfighter
  • 1,973 Views

Ansible ad-hoc command syntax

Jump to solution

Hello all,

Got a question regarding the following 3 ad-hoc syntax:

1)   ansible  hostname   -m  command  -a  uptime

2)   ansible  hostname   -m  shell  -a uptime

3)   ansible  hostname   -a  uptime


Okay, I get the same outupt - same results from running either command.  My question
is, other than saving some keystrokes with the 3rd format, is there any other benefit to
using this (3rd item) syntax vs. the first two?

Thanks all.

 

Trevor "Red Hat Evangelist" Chandler
Labels (2)
0 Kudos
1 Solution

Accepted Solutions
Alexandre
Starfighter Starfighter
Starfighter
  • 1,957 Views

Hello, @Trevor 

There is no difference between ansible hostname -m command -a uptime and ansible hostname -a uptime. The command module is used by default for the -m option. But the big difference between them both and ansible hostname -m shell -a uptime The shell is not used to execute the command for the command module, but the shell is run for the shell module. Compare: ansible hostname -a set and ansible hostname -m shell -a set

View solution in original post

2 Replies
Alexandre
Starfighter Starfighter
Starfighter
  • 1,958 Views

Hello, @Trevor 

There is no difference between ansible hostname -m command -a uptime and ansible hostname -a uptime. The command module is used by default for the -m option. But the big difference between them both and ansible hostname -m shell -a uptime The shell is not used to execute the command for the command module, but the shell is run for the shell module. Compare: ansible hostname -a set and ansible hostname -m shell -a set

Trevor
Starfighter Starfighter
Starfighter
  • 1,780 Views

Hello Alexandre

Thank you for the very nice explanation.  

Hope you're safe and well.

 

Trevor "Red Hat Evangelist" Chandler
0 Kudos
Join the discussion
You must log in to join this conversation.