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
#!/bin/bash
echo "Test Salt" >/tmp/testsalt.txt
Copy Code
Execute remote command
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
#!/bin/bash
echo "Test Salt" >/tmp/testsalt.txt
echo $
Echo
echo $
If ["$ $" x = "yy" x]
Then
echo "OK???????????????"
Fi
Copy Code
Execute the remote command again
Salt ' cn-gd-gz-0001 ' cmd.script salt://scripts/1.sh "AA bb cc"
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