St2.chatops Ansible Role fatal error leading to broken install

Ansible Version: 2.9.2
CentOS Linux release 7.7.1908 (Core) |


I have deployed StackStorm using your provided ansible playbook. However after deployment and configuring hubot to integrate with Slack I noticed the chatbot service wasnt online and I was unable to start it.

I ran your self-check script as per your troubleshooting guide and noticed that the API key was also not set “StackStorm client couldn’t connect to StackStorm.”. I solved this temporarily by manually “export ST2_API_KEY…”. However the check then fails on “Step 1 failed: Hubot is not running on this machine.”. This prompted me to rerun the ansible script and check for any failures. This is what I found.

TASK [StackStorm.st2chatops : Check if API key already exist in st2chatops.env] ******************************************************************
fatal: [localhost]: FAILED! => {“changed”: false, “cmd”: [“grep”, “-e”, “^export ST2_API_KEY=”\{ST2_API_KEY}\"", “/opt/stackstorm/chatops/st2chatops.env”], “delta”: “0:00:00.004789”, “end”: “2020-01-20 16:34:40.465620”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2020-01-20 16:34:40.460831”, “stderr”: “”, “stderr_lines”: [], “stdout”: “”, “stdout_lines”: []}

I am wondering if this is something that has been seen before and if you could help in diagnose the problem. I believe it is failing this task and it is having a knock on effect skipping subsequent tasks.

Much Appreciated

This could be a bug somewhere.
What Ansible variables did you set to install stackstorm?

How /opt/stackstorm/chatops/st2chatops.env looks like after Ansible run?
Did Ansible run succeeded at all?

Don’t forget to mask any secrets when posting logs.

I never set any ansible variables, is this required? The only configuration I did was to set the following in the playbook (stackstorm.yaml) so that it ran on localhost.

hosts: localhost
connection: local

The st2chatops.env file looks fine from the point of view that StackStorm API Key is there and uncommented.

The playbook did run and complete. If I was to rerun it I get the following.

PLAY RECAP ***************************************************************************************************************************************
localhost : ok=86 changed=0 unreachable=0 failed=0 skipped=69 rescued=0 ignored=1

Thanks for the heads up

In order to enable ChatOps you have to configure it.
See: What is ChatOps? — StackStorm 3.1.0 documentation from the general StackStorm documentation.

For Slack, you have to provide Hubot Slack Token via Ansible variables. See st2chatops.st2chatops_config GitHub - StackStorm/ansible-st2: Ansible Roles and Playbooks to deploy StackStorm
That will update st2chatops.env with Slack Token.

Once that’s done ChatOps service should work/start OK.

1 Like

Thanks for this @armab this has done the trick.
Must have made a type somewhere when I was manually configuring it before, just happy its working and automated :slight_smile: