Ansible the module parameters (b)

The previous article we said, if you do not increase the -m parameter, the default is to use the command module, but you're going to -a This parameter is the Linux commands and parameters, then what should be the format it?

An online search, give chestnut:
[root @ the Controller ~] # ansible webservers -a 'LS the -l / tmp /'

FIG results are as follows:
Ansible the module parameters (b)

For the format command, simply look:
ansible: the tool name to your work, you must have
webservers: a bunch of servers defined in the hosts ansible warehouse group name, host name and (or) IP address contains multiple servers
- a: the parameters that you want to use the module to be in quotes, this is very important, without quotes will complain. As for single or double quotation marks, by default you use single quotes, double quotes error pulls try.

'Ls -l / tmp /': single quotes, is the Linux shell command, ls is the command list

From the results, ansible is in accordance with the basic linux commands output the results to you, nothing to speak of.

so, the above command = ansible webservers -m shell -a 'ls -l / tmp /'
to run a look at the results:
Ansible the module parameters (b)

Exactly the same, there is wood there.

So, review the module parameters:

  1. -m This is a must have, if not, the default shell is made of this module, this time with the -a parameter must be behind the shell commands, otherwise it will go wrong.
  2. -a this is a must have, regardless of the -m there is no reference to Article 1. This format -a following the argument, is to be written in accordance with -m module name you used.

That Next, we will introduce how to view module -a instructions for use.

Guess you like

Origin blog.51cto.com/jiaszwx/2412129