Skip to content

Commit

Permalink
Merge pull request #250 from punkrokk/master
Browse files Browse the repository at this point in the history
Support Pack Install as a variable in stackstorm.st2 (py2)
  • Loading branch information
armab authored Sep 4, 2019
2 parents 684d0c3 + dba664a commit ac9a57b
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Below is the list of variables you can redefine in your playbook to customize st
| `st2_auth_username` | `testu` | Username used by StackStorm standalone authentication.
| `st2_auth_password` | `testp` | Password used by StackStorm standalone authentication.
| `st2_save_credentials` | `yes` | Save credentials for local CLI in `/root/.st2/config` file.
| `st2_packs` | `[ st2 ]` | List of packs to install. This flag does not work on CentOS6 or with a `--python3` only pack.
| **st2mistral**
| `st2mistral_version` | `latest` | st2mistral version to install. `present` to install available package, `latest` to get automatic updates, or pin it to numeric version like `2.2.0`.
| `st2mistral_db` | `mistral` | PostgreSQL DB name that will be created for Mistral.
Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Vagrant.configure(2) do |config|

vm_config.vm.provider :virtualbox do |vb|
vb.name = "#{cfg[:hostname]}"
vb.customize ['modifyvm', :id, '--memory', '2048']
vb.customize ['modifyvm', :id, '--memory', '4096']
end

if Vagrant.has_plugin?('vagrant-cachier')
Expand Down
3 changes: 3 additions & 0 deletions roles/StackStorm.st2/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ st2_auth_username: testu
st2_auth_password: testp
# Save credentials in ~/.st2/config file
st2_save_credentials: yes
# ST2 packs to be installed (list)
st2_packs:
- st2
3 changes: 3 additions & 0 deletions roles/StackStorm.st2/tasks/flush_handlers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- meta: flush_handlers
tags: st2, st2_packs
21 changes: 21 additions & 0 deletions roles/StackStorm.st2/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,24 @@
state: started
loop: "{{ st2_services }}"
tags: st2

# Since flush handlers does not support conditionals, we need to have a dedicated playbook
# https://github.com/ansible/ansible/issues/41313#issuecomment-520891625
- name: Flush handlers to prepare StackStorm if there are packs to install
include_tasks: flush_handlers.yml
when: st2_packs|length > 0 and not (ansible_facts.os_family == "RedHat" and ansible_distribution_major_version == "6")
ignore_errors: yes
tags: st2, st2_packs, skip_centos_6

- name: Install StackStorm integration Packs
import_tasks: packs.yml
when: st2_packs|length > 0 and not (ansible_facts.os_family == "RedHat" and ansible_distribution_major_version == "6")
ignore_errors: yes
tags: st2, st2_packs, skip_centos_6

- name: Report warning when 'st2_packs' is used in EL6
fail:
msg: CentOS/RHEL 6 support not provided for 'st2_packs', skipped st2 pack install
failed_when: st2_packs|length > 0 and ansible_facts.os_family == "RedHat" and ansible_distribution_major_version == "6"
ignore_errors: yes
tags: st2, st2_packs, skip_centos_6
29 changes: 29 additions & 0 deletions roles/StackStorm.st2/tasks/packs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---

- name: Get list of installed st2 packs
command: st2 pack list -j
changed_when: no
check_mode: no
register: _st2_packs_installed
become: yes
become_user: root
# Fix privilege escalation ENV in Dockerized environment
environment:
HOME: /root
tags: st2, st2_packs

# This gets the names of the currently installed st2 packs from a json list of dicts
- set_fact:
st2_packs_installed: "{{ _st2_packs_installed.stdout|from_json|map(attribute='name')|list() }}"
tags: st2, st2_packs,

- name: Install st2 packs
command: st2 pack install "{{ item }}"
loop: "{{ st2_packs }}"
when: item not in st2_packs_installed
become: yes
become_user: root
# Fix privilege escalation ENV in Dockerized environment
environment:
HOME: /root
tags: st2, st2_packs
10 changes: 10 additions & 0 deletions roles/StackStorm.st2smoketests/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@
ST2_AUTH_TOKEN: "{{ st2_token.stdout }}"
command: "st2 pack install st2"
changed_when: no
when: ansible_facts.os_family == "RedHat" and ansible_distribution_major_version == "6"
tags:
- smoke-tests

- name: Verify if st2 pack was installed
environment:
ST2_AUTH_TOKEN: "{{ st2_token.stdout }}"
command: st2 pack get st2
changed_when: no
check_mode: no
tags:
- smoke-tests

Expand Down

0 comments on commit ac9a57b

Please sign in to comment.