Skip to content

Saltexecexamples cluster&singlecommand

Real-time examples of Zero Trust Host Access (Salt Exec) are provided below

Tagret Type Cluster and passing Single/Multiple command(s)

Step 1: Post Command

curl --location --request POST 'https://app.phani-ptnr-1219.dev.rafay-edge.net/cmdexec/v1/projects/j2q4j5k/edges/3mxg7ek/execute/' \
--header 'X-RAFAY-API-KEYID: g5439debbd24b1c876aa79b4d2997bdca7009f3g' \
--header 'Content-Type: application/json' \
--data-raw '{
    "target_type" : "cluster",
    "command": "cGluZyAtYyAxIGdvb2dsZS5jb20KaWYgWyAkPyA9PSAwIF07IHRoZW4KICAgIGVjaG8gJ0Nvbm5lY3Rpb24gd29ya2luZycKZWxzZQogICAgZWNobyAnRXJyb3IgaW4gY29ubmVjdGlvbiB0byBVUkwnCmZpCg==",
    "content_type": "base64",
    "timeout": 120
}'

***Output of Post Operation**

{
    "Id": "dpkv0mn",
    "SubmittedAt": "2021-10-11T07:44:01.09573Z",
    "ClusterId": "3mxg7ek",
    "ClusterName": "madhunew-ubuntu201-arm",
    "ProjectId": "j2q4j5k",
    "OrganizationId": "dk69nqk",
    "PartnerId": "9d2wyk8",
    "Command": "cGluZyAtYyAxIGdvb2dsZS5jb20KaWYgWyAkPyA9PSAwIF07IHRoZW4KICAgIGVjaG8gJ0Nvbm5lY3Rpb24gd29ya2luZycKZWxzZQogICAgZWNobyAnRXJyb3IgaW4gY29ubmVjdGlvbiB0byBVUkwnCmZpCg==",
    "Target": [],
    "TargetType": "cluster",
    "TargetNodes": [
        "madhuamd-ubuntu201"
    ],
    "ContentType": "base64",
    "Timeout": 120,
    "Username": "[email protected]",
    "UnreachableNodes": [
        "madhuarm-ubuntu201"
    ],
    "UnapprovedNodes": []
}

---

### Step 2: Get command

Enter the below Get command with the generated key **g5439debbd24b1c876aa79b4d2997bdca7009f3g**
curl --location --request GET 'https://app.phani-ptnr-1219.dev.rafay-edge.net/cmdexec/v1/projects/j2q4j5k/edges/3mxg7ek/execution/dpkv0mn/' \ --header 'X-RAFAY-API-KEYID: g5439debbd24b1c876aa79b4d2997bdca7009f3g'
***Output of Get Operation***
{ "NodeResponses": [ { "Name": "madhuamd-ubuntu201", "Resp": { "Return": "PING google.com (172.217.5.206) 56(84) bytes of data.\n64 bytes from lax28s10-in-f14.1e100.net (172.217.5.206): icmp_seq=1 ttl=118 time=9.98 ms\n\n--- google.com ping statistics ---\n1 packets transmitted, 1 received, 0% packet loss, time 0ms\nrtt min/avg/max/mdev = 9.979/9.979/9.979/0.000 ms\nConnection working", "Retcode": 0, "Success": true } } ], "Responded": [ "madhuamd-ubuntu201" ], "Unreachable": [ "madhuarm-ubuntu201" ], "Unapproved": [], "Pending": [] } ```