Saltexecexamples node&multiplecommand
Real-time examples of Zero Trust Host Access (Salt Exec) are provided below
Tagret Type Node and passing Multiple commands¶
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" : ["madhuarm-ubuntu201","madhuamd-ubuntu201"],
"target_type" : "node",
"command": "free -h ;lsblk",
"content_type": "string",
"timeout": 360
}'
***Output of Post Operation**
{
"Id": "q6kn4ml",
"SubmittedAt": "2021-10-11T07:34:27.283246Z",
"ClusterId": "3mxg7ek",
"ClusterName": "madhunew-ubuntu201-arm",
"ProjectId": "j2q4j5k",
"OrganizationId": "dk69nqk",
"PartnerId": "9d2wyk8",
"Command": "free -h ;lsblk",
"Target": [
"madhuarm-ubuntu201",
"madhuamd-ubuntu201"
],
"TargetType": "node",
"TargetNodes": [
"madhuamd-ubuntu201"
],
"ContentType": "string",
"Timeout": 360,
"Username": "[email protected]",
"UnreachableNodes": [
"madhuarm-ubuntu201"
],
"UnapprovedNodes": []
}
¶
{
"Id": "q6kn4ml",
"SubmittedAt": "2021-10-11T07:34:27.283246Z",
"ClusterId": "3mxg7ek",
"ClusterName": "madhunew-ubuntu201-arm",
"ProjectId": "j2q4j5k",
"OrganizationId": "dk69nqk",
"PartnerId": "9d2wyk8",
"Command": "free -h ;lsblk",
"Target": [
"madhuarm-ubuntu201",
"madhuamd-ubuntu201"
],
"TargetType": "node",
"TargetNodes": [
"madhuamd-ubuntu201"
],
"ContentType": "string",
"Timeout": 360,
"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/q6kn4ml/' \
--header 'X-RAFAY-API-KEYID: fg5439debbd24b1c876aa79b4d2997bdca7009f3g'
Output of Get Operation
{
"NodeResponses": [
{
"Name": "madhuamd-ubuntu201",
"Resp": {
"Return": " total used free shared buff/cache available\nMem: 7.5Gi 2.7Gi 1.7Gi 7.0Mi 3.2Gi 4.8Gi\nSwap: 0B 0B 0B\nNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT\nloop0 7:0 0 55.4M 1 loop /snap/core18/2128\nloop1 7:1 0 55.4M 1 loop /snap/core18/2066\nloop2 7:2 0 61.8M 1 loop /snap/core20/1081\nloop3 7:3 0 67.6M 1 loop /snap/lxd/20326\nloop4 7:4 0 67.3M 1 loop /snap/lxd/21545\nloop5 7:5 0 66.8M 1 loop /snap/oracle-cloud-agent/18\nloop6 7:6 0 32.1M 1 loop /snap/snapd/12057\nloop7 7:7 0 58.3M 1 loop /snap/oracle-cloud-agent/22\nloop8 7:8 0 32.3M 1 loop /snap/snapd/13170\nloop9 7:9 0 61.9M 1 loop /snap/core20/1169\nsda 8:0 0 46.6G 0 disk \n|-sda1 8:1 0 46.5G 0 part /\n|-sda14 8:14 0 4M 0 part \n`-sda15 8:15 0 106M 0 part /boot/efi\nsdb 8:16 0 50G 0 disk \n`-heketi-vol 253:0 0 50G 0 crypt \n |-vg_64925849821aa380935843c7d35f3220-tp_fc9b8fcc4ee00788a5c7081563ce08c8_tmeta 253:1 0 12M 0 lvm \n | `-vg_64925849821aa380935843c7d35f3220-tp_fc9b8fcc4ee00788a5c7081563ce08c8-tpool 253:3 0 2G 0 lvm \n | `-vg_64925849821aa380935843c7d35f3220-brick_cebecc9c7368267a1e561f7cc3606764 253:5 0 2G 0 lvm \n `-vg_64925849821aa380935843c7d35f3220-tp_fc9b8fcc4ee00788a5c7081563ce08c8_tdata 253:2 0 2G 0 lvm \n `-vg_64925849821aa380935843c7d35f3220-tp_fc9b8fcc4ee00788a5c7081563ce08c8-tpool 253:3 0 2G 0 lvm \n `-vg_64925849821aa380935843c7d35f3220-brick_cebecc9c7368267a1e561f7cc3606764 253:5 0 2G 0 lvm",
"Retcode": 0,
"Success": true
}
}
],
"Responded": [
"madhuamd-ubuntu201"
],
"Unreachable": [
"madhuarm-ubuntu201"
],
"Unapproved": [],
"Pending": []
}