ansible-st2
ansible-st2 copied to clipboard
Pack Install
Implement a convenient ansible-friendly way (as Ansible module) to install st2 packs, as well as provide configurations/settings for them.
Decide:
- define config settings in
yaml
plays inline - use
/opt/stackstorm/configs/<pack>.yaml
https://docs.stackstorm.com/pack_configs.html
Alternative example from
puppet-st2
: https://github.com/stackstorm/puppet-st2#installing-and-configuring-packs
In short, it should work like similar pip or gem Ansible module, but for installing st2 packs.
One of the possible syntaxes for the new interface to install & configure stackstorm packs:
st2_packs:
# `st2 pack install ansible`
- name: ansible
# `st2 pack install https://github.com/emedvedev/chatops_tutorial`
- name: https://github.com/emedvedev/chatops_tutorial
# full example with all params and config
- name: aws
state: present
version: 1.2.3
config:
setup:
region: "us-west-2"
aws_access_key_id: ""
aws_secret_access_key: ""
# uninstall pack
- name: consul
state: absent
# additional way to use already prepared file which will be
# transferred to /opt/stackstorm/configs/servicenow.yml
- name: servicenow
config: files/configs/servicenow.yml
inspiration from the http://docs.ansible.com/ansible/pip_module.html
This will require us to write custom Ansible module similar to apt
, yum
, pip
which will work with st2client
lib.
FWIW, this is the method that I use currently which actually works pretty well for installing/uninstalling packs. I do agree, however, that there should be a better way. I was also recently looking at ways to leverage the JSON/YAML output in different ways.
https://github.com/mrlesmithjr/ansible-stackstorm/blob/master/tasks/packs.yml
Hi @mrlesmithjr, thanks for sharing! Glad to see you here! I remember your StackStorm roles, which are great :+1:
BTW we recently reworked our entire pack installation + discovery story and introduced versioning: https://stackstorm.com/2017/01/31/stackstorm-exchange-new-pack-management/ with https://exchange.stackstorm.org/ and many other features.
I tried to play with just simple Ansible functionality to achive described above Ansible syntax, - but yaml logic is definitely not enough. Some of the problems we want to fix in a long term:
- Pack install Idempotence, see: https://github.com/StackStorm/st2/issues/3052 (st2 core changes)
- Pack install version
- if pack version unchanged, - we shouldn't try to re-install same pack again
- if different version provided, - it should trigger reinstall in Ansible
- Variety of pack install methods/syntaxes (from the example above and https://docs.stackstorm.com/packs.html#installing-a-pack)
- Different sets of pack configurations
And yeah, simple command: st2 pack install pack_name
is what we do currently with some workarounds similar to your example to make the command somehow idempotent, but we look forward for a better approach like writing Ansible module on top of st2client
which could handle more complex cases, in Ansible-friendly way.
@armab Absolutely. Not that it provided much value but it does help me understand more of where you are trying to take this. And thanks for sharing the additional info above as well. I will be spending some time going through some of the open issues and etc. I will definitely try to contribute where I can and definitely let me know if there is anything else I can possibly help out with.
@mrlesmithjr Awesome! :+1: While you're exploring existing roles/functionality, don't hesitate to create an Issue if you found we missed something. Your feedback and contributions are very welcome, especially as a st2 user. Additionally, as big Ansible practioner, another pair of :eyes: in Pull Requests might help to make sure we do the right thing. For example currently: https://github.com/StackStorm/ansible-st2/pull/125 and https://github.com/StackStorm/ansible-st2/pull/126.
The initial simplistic implementation (wrapper around st2 pack install
) is implemented in https://github.com/StackStorm/ansible-st2/pull/250, thanks to @punkrokk and @guymatz for the contribution.