ansible Command and Raw module

Source: Internet
Author: User
Tags glob

Command Module

The command module is the ansible default module, the command module is used when the-m parameter is not specified;
Comand modules are simple, common commands can be used, but the execution of their commands is not performed through the shell, so, such as "<", ">", "|", and "&" operation can not, the running command does not support variable use and does not support the pipeline;
Example: displaying the current user

[[email protected] ~]# ansible all-a ' whoami ' db | SUCCESS | Rc=0 >>rootweb | SUCCESS | Rc=0 >>root192.168.33.132 | SUCCESS | Rc=0 >>root

Command usage

[[email protected] ~]# ansible-doc -s commandless 436copyright  (C)   1984-2009 mark nudelmanless comes with no warranty, to the extent  permitted by law. for information about the terms of redistribution,see the file  Named readme in the less distribution. Homepage: http://www.greenwoodsoftware.com/less- name: executes a command on  a remote node  action: command      chdir                   #  cd into this directory before running the command       creates                 # a filename or&nbSP; (since 2.0)  glob pattern, when it already exists, this step  will *not* be run.      executable              # change the shell used to  execute the command. should be an absolute path to the  executable.      free_form=              # the command module takes a free form  command to run.  There is no parameter actually named  ' free                                form '.  See the  examples!      removes                 # a filename or  (since 2.0)  glob pattern, when it  does not exist, this step will *not* be run.       warn                    # if command warnings are on in ansible.cfg,  do not warn about this particular line if set to                                 no/false.


-Name: Execute command on remote node
Action:command
chdir # Switch to the directory before executing the command
creates # A filename, when the file exists, the command does not execute
executable # switch Shell to execute command, need to use absolute path of command
free_form= #要执行的Linux指令, generally use the-a parameter of ansible instead.
removes #一个文件名, this file does not exist, then the command does not execute

Raw, similar to command, but can pass pipelines

Usage

[[email protected] ~]# ansible-doc -s rawless 436copyright  (C)   1984-2009 mark nudelmanless comes with no warranty, to the extent  permitted by law. for information about the terms of redistribution,see the file  Named readme in the less distribution. Homepage: http://www.greenwoodsoftware.com/less- name: executes a low-down and  dirty ssh command  action: raw      executable              # change the  shell used to execute the command. should be an absolute  path to the executable.      free_form=               # the raw module takes a free form command to run 


example, view the swap status on the Web server

[[email protected] ~]# ansible web-m raw-a ' free-m|grep Swap ' web | SUCCESS | Rc=0 >>swap:2047 0 2047



This article is from the "Village Boys" blog, please make sure to keep this source http://noodle.blog.51cto.com/2925423/1769448

ansible Command and Raw module

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.