-
I’m new to StackStorm, I need to understand how the mistral-workflow is getting called from Rule. I am trying to do small POC. Could you please provide me the working sample examples to understand and execute in our end?
-
I have used below samples and tried to run. But it is not working and correct me if the below examples are correct or not.
Step 1:
sample_rule_with_webhook.yaml
name: "sample_rule_with_webhook.yaml"
pack:"examples"
description: "sample rule dumping webhook payload to a file"
enabled: true
trigger:
type: "core.st2.webhook"
parameters:
url: "sample"
criteria: {}
action:
ref:"examples.mistral-basic"
parameters:
cmd: "echo {{date}} "
timeout:20
step 2:
st2 rule create sample_rule_with_webhook.yaml
(Rule got registered successfully) checked using the below command
st2 rule list
Step 3:
execute the below for getting token which is passed to the curl command
export ST2_AUTH_TOKEN=`st2 auth -t -p 'Ch@ngeMe' st2admin`
echo $ST2_AUTH_TOKEN
execute the above rule using the below command
curl -k https://localhost/api/v1/webhooks/sample -H 'Content-Type: application/json' -H
'X-Auth-Token: put_token_here'
(No error)
The same we can execute thru postman by passing this rest url along with token which will work
Step 4:
Created mistral-basic.yaml action under action folder
description: Run a local linux command
enabled: true
runner_type: mistral-v2
entry_point: workflows/mistral-basic.yaml
name: mistral-basic
pack: examples
parameters:
cmd:
required: true
type: string
timeout:
type: integer
default: 60
Step 5:
Created mistral-basic.yaml
workflow under workflow folder
version: '2.0'
examples.mistral-basic:
description: A basic workflow that runs an arbitrary linux command.
type: direct
input:
- cmd
- timeout
output:
stdout: <% $.stdout %>
tasks:
task1:
action: core.local cmd=<% $.cmd %> timeout=<% $.timeout %>
publish:
stdout: <% task(task1).result.stdout %>
stderr: <% task(task1).result.stderr %>
step 6:
execute the action using the below command
st2 action create mistral-basic.yaml
I’m seeing registered workflow examples.mistral-basic
in StackStorm when I execute st2
action list
step 7:
execute the workflow using the below command
st2 run examples.mistral-basic cmd=date timeout=20 -a
Step: 8
When I execute the below command, I am able to see the workflow status
st2 execution get <execution id>
Question;
-
please let know how to execute this workflow from rule using curl or using rest api. please check the above code
-
please provide any sample examples (atleast hello work program) - end to end (calling from postman >>> webhook rule >>>> action >>>> workflow >>> return result postman
-
Please let know how to debug this flow?
Thanks all and waiting for quick reply.