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.1k stars 746 forks source link

Array config not serialised properly using chatops #4036

Open juanwolf opened 6 years ago

juanwolf commented 6 years ago

Hi,

I created a pack where actions load their default value from the configuration file. It was working fine executing the action with the st2 cli but not when using chatops aliases for the actions. Suddenly the "arrays" of my configuration were not parsed as such.

Here's the config schema:

hosts:
  description: "List of hosts to access"
  type: "array"
  required: true

Here's my action definition:

---
description: Display the config context of this pack
enabled: True
runner_type: "local-shell-cmd"
name: show_config
pack: mypack
parameters:
  cmd:
    type: "string"
    description: "The Command to execute"
    required: true
    default: "echo '{{ config_context.hosts }}'"
  test:
    type: "array"
    description: "Just a test"
    required: true
    default: "{{ config_context.hosts }}"

The alias:

---
name: "show_config"
pack: "mypack"
action_ref: "mypack.show_config"
description: "Display the current configuration of mypack"
formats:
  - "show config mypack"
ack:
  format: "Retrieving that for you!"
result:
  format: |
    {% if execution.status == "succeeded" %}
      Here's the config:
        {{ execution.result.stdout }}
    {% else %}
      {% if execution.result.stderr %}*Stderr:* ```{{ execution.result.stderr }}```{% endif %}
    {% endif %}

And the chatops result:

juanwolf 10:36 AM
! show config mypack

Stanley 10:43 AM
@juanwolf: I'm sorry, Dave. I'm afraid I can't do that.
u'{{ config_context.hosts }}' is not of type u'array'

Failed validating u'type' in schema['properties'][u'test']:
{u'default': u'{{ config_context.hosts }}',
u'description': u'Just a test',
u'required': True,
u'type': u'array'}

On instance[u'test']:
u'{{ config_context.hosts }}'

Am I doing something wrong here?

bigmstone commented 6 years ago

What does the config look like?

juanwolf commented 6 years ago

Sorry forgot that important part, here's the config:

hosts:
- myhost1.com
- myhost2.com
- myhost3.com

To add even more details, this file has been created running:

st2 pack config mypack and I used a string like myhost1.com,myhost2.com,myhost3.com to generate this array.

stale[bot] commented 5 years ago

Thanks for contributing to this issue. As it has been 90 days since the last activity, we are automatically marking is as stale. If this issue is not relevant or applicable anymore (problem has been fixed in a new version or similar), please close the issue or let us know so we can close it. On the contrary, if the issue is still relevant, there is nothing you need to do, but if you have any additional details or context which would help us when working on this issue, please include it as a comment to this issue.