Salt cmd.script

Source: Internet
Author: User

Salt ' * ' cmd.script



Cmd.run said this before.


Cmd.script

This is a powerful command , which means that a script can be downloaded from a remote to execute on the client


Cliexample:

Salt ' * ' Cmd.script salt://scripts/runme.sh

Salt ' * ' cmd.script salt://scripts/runme.sh ' arg1 arg2 ' arg 3 '



Help documentation says Thescript can is located on the Salt Master file server or in an HTTP/FTP server.


so configure the Salt server and put the script on the server



edit /etc/salt/master, Open the following comment, save and restart the server

File_roots:

Base

-/srv/salt


If you do not have a/srv/salt/script directory, create a


Cd/srv/salt/scripts


Write a shell script saved as 1.sh

    1. #!/bin/bash

    2. echo "Test Salt" >/tmp/testsalt.txt

Copy Code




Execute remote command

    1. Salt ' cn-gd-gz-0001 ' cmd.script salt://scripts/1.sh

Copy Code


650) this.width=650; "Width=" 550 "src=" http://bbs.linuxtone.org/data/attachment/forum/201312/21/ 160228ci66ws6xt1o8zf96.jpg "border=" 0 "/>




The information displayed is still very intuitive, stdout no information is displayed because the script statement does not display text, you can add more than one echo "OK" and then do more than once to see the output.


See Help It seems you can also add command-line arguments when executing a script, try

Modify the script to

    1. #!/bin/bash

    2. echo "Test Salt" >/tmp/testsalt.txt

    3. echo $

    4. Echo

    5. echo $


    6. If ["$ $" x = "yy" x]

    7. Then

    8. echo "OK???????????????"

    9. Fi

Copy Code

Execute the remote command again

    1. Salt ' cn-gd-gz-0001 ' cmd.script salt://scripts/1.sh "AA bb cc"

    2. Salt ' cn-gd-gz-0001 ' cmd.script salt://scripts/1.sh "AA bb yy"

Copy Code

The arguments that appear to be passed are valid


650) this.width=650; "width=" 551 "src=" http://bbs.linuxtone.org/data/attachment/forum/201312/21/ 160229gr9gx0gzevz7u4g4.jpg "border=" 0 "/>


This article is from the "Intelligent Future _XFICC" blog, please be sure to keep this source http://xficc.blog.51cto.com/1189288/1674925

Salt cmd.script

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.