2017-05-30 52 views
1
curl -skS "https://xx.xxx.xxx.xxx:8080/run"  -H 'Accept: application/x-yaml'  -H 'Content-type: application/json'  -d '[{ 
     "client": "local", 
     "tgt": "*", 
     "fun": "cmd.run", 
     "name": "df -h", 
     "username": "ravi", 
     "password": "teledna", 
     "eauth": "pam" }]' 

我想通過salt-api運行命令。但我得到一個錯誤。其中test.ping工作正常。我想我錯過了身體中的參數。任何人都可以在這裏指出文檔或調整curl命令。謝謝。如何在salt-api中使用cmd.run

回答

1

你將要使用cmd

curl -skS https://xxx.xxx.xxx.xxx:8080/run \ 
    -H 'Accept: application/x-yaml' \ 
    -H 'Content-type: application/json' \ 
    -d '[{ 
     "client": "local", 
     "tgt": "*", 
     "fun": "cmd.run", 
     "kwarg": { 
      "cmd": "df -h" 
     }, 
     "username": "ravi", 
     "password": "teledna", 
     "eauth": "auto" 
    }]' 

你需要從模塊的功能,而不是國家使用的名稱。

https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.cmdmod.html#salt.modules.cmdmod.run

+0

謝謝工作正常 –