ansible-st2 icon indicating copy to clipboard operation
ansible-st2 copied to clipboard

Pack Install

Open arm4b opened this issue 8 years ago • 6 comments

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.

arm4b avatar Jan 09 '17 13:01 arm4b

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.

arm4b avatar Feb 03 '17 20:02 arm4b

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

mrlesmithjr avatar Mar 12 '17 01:03 mrlesmithjr

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.

arm4b avatar Mar 13 '17 13:03 arm4b

@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 avatar Mar 14 '17 01:03 mrlesmithjr

@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.

arm4b avatar Mar 14 '17 16:03 arm4b

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.

arm4b avatar Sep 04 '19 16:09 arm4b