StackStorm / st2

StackStorm (aka "IFTTT for Ops") is event-driven automation for auto-remediation, incident responses, troubleshooting, deployments, and more for DevOps and SREs. Includes rules engine, workflow, 160 integration packs with 6000+ actions (see https://exchange.stackstorm.org) and ChatOps. Installer at https://docs.stackstorm.com/install/index.html
https://stackstorm.com/
Apache License 2.0
6.07k stars 749 forks source link

Any detail docs describe how we can use result or stdout in workflow as reference #3517

Closed leoxhj closed 7 years ago

leoxhj commented 7 years ago

Dear support,

Not sure if this is correct or possible way (maybe the current action_execution_id is not known to workflow?), sometimes, the python script might want to know the action execution id as its input parameters. for instance, below action need current action_execution_id as its input parameter, can I know how to write the reference, like {{result.id}} or {{result.stdout.id}} or {{action_context.id}}?, I noticed the code part for each action from webui, but just don't know the exactly format to invoke in workflow definition file.

      t_observation:
          action: libery.manual_action
          input:
              execution_id: {{}}
              pool_id: <% $.pool_id %>
              pool_info: <% $.pool_info %>
              assigned_group: <% $.assigned_group %>
              assignee: <% $.assigne %>
              time_out: <% $.time_out %>
          publish:

BR, Leo

bigmstone commented 7 years ago

@leoxhj https://docs.stackstorm.com/mistral_yaql.html#other-yaql-functions

<% env().st2_execution_id %>

Please re-open issue if this isn't what you're looking for.

leoxhj commented 7 years ago

It will pass to external tool as reference id to find back in stackstorm if needed.

-------- 原始信息 -------- 由: Lindsay Hill notifications@github.com 日期: 2017/6/29 10:07 (GMT+08:00) 收件人: StackStorm/st2 st2@noreply.github.com 抄送: leoxhj leo_xhj@hotmail.com, Mention mention@noreply.github.com 主题: Re: [StackStorm/st2] Any detail docs describe how we can use result or stdout in workflow as reference (#3517)

I'm not quite sure why you want to access the execution id, but you can get it using st2_execution_id - go to https://docs.stackstorm.com/mistral_yaql.html and search for execution_id

I'm not quite sure what you need it for though. What are you trying to achieve here?

― You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/StackStorm/st2/issues/3517#issuecomment-311842083, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADHy2UdnpjQ-cq27C5FvMib2XhbsHwcWks5sIwb3gaJpZM4OE8NX.

sibirajal commented 7 years ago

I have an Ansible action in the st2 mistral workflow and would like to post the action output into chatop.post_result action. To post the action result in chatops_post_result it required execution id. Would there be possible to get the execution id for the ansible action and assign that execution id into chatops.post_result action?

I've tried to use <% env().st2_execution_id %> with chatops.post_message however it returns the workflow execution id rather than the particular action ID.

example: post_chat_fail:

[625, 536]

  action: chatops.post_message
  input:
    channel: <% $.channel %>
    message: "Auto-remediation failed for <% env().st2_execution_id %>" 
leoxhj commented 7 years ago

Have you tried <% env().st2_action_execution_id %>? Just my guess, docs mentioned less details about environment()

发送自我的三星盖乐世智能手机。

-------- 原始信息 -------- 由: sibirajal notifications@github.com 日期: 2017/7/5 19:52 (GMT+08:00) 收件人: StackStorm/st2 st2@noreply.github.com 抄送: leoxhj leo_xhj@hotmail.com, Mention mention@noreply.github.com 主题: Re: [StackStorm/st2] Any detail docs describe how we can use result or stdout in workflow as reference (#3517)

I have an Ansible action in the st2 mistral workflow and would like to post the action output into chatop.post_result action. To post the action result in chatops_post_result it required execution id. Would there be possible to get the execution id for the ansible action and assign that execution id into chatops.post_result action?

I've tried to use <% env().st2_execution_id %> with chatops.post_message however it returns the workflow execution id rather than the particular action ID.

example: post_chat_fail:

[625, 536]

action: chatops.post_message input: channel: <% $.channel %> message: "Auto-remediation failed for <% env().st2_execution_id %>"

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/StackStorm/st2/issues/3517#issuecomment-313081192, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADHy2d2DZynln9sRKAS4C6bRUHPOwy8hks5sK3kNgaJpZM4OE8NX.

sibirajal commented 7 years ago

That's right. I've tried <% env().st2_action_execution_id %> in my workflow and it failed with error. Basically I would like to get the execution id of the particular action and use that id for chatops.post_result action.

YaqlEvaluationException: Can not evaluate YAQL expression [expression=env().st2_action_execution_id, error=u'st2_action_execution_id', data={}] ] (execution_id=4768477e-b748-4f54-893a-47f2cd479317): YaqlEvaluationException: Can not evaluate YAQL expression [expression=env().st2_action_execution_id, error=u'st2_action_execution_id', data={}]