StackStorm / ansible-st2

Ansible Roles and Playbooks to deploy StackStorm
https://galaxy.ansible.com/StackStorm/stackstorm/
Apache License 2.0
100 stars 74 forks source link

Pack Install #74

Open arm4b opened 7 years ago

arm4b commented 7 years ago

Implement a convenient ansible-friendly way (as Ansible module) to install st2 packs, as well as provide configurations/settings for them.

Decide:

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 commented 7 years ago

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.

mrlesmithjr commented 7 years ago

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

arm4b commented 7 years ago

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:


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.

mrlesmithjr commented 7 years ago

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

arm4b commented 7 years ago

@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 commented 5 years ago

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.