diff --git a/README.md b/README.md index 3ba5a6cd..81dca75c 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/Vagrantfile b/Vagrantfile index 934dc014..9e21bb3f 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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') diff --git a/roles/StackStorm.st2/defaults/main.yml b/roles/StackStorm.st2/defaults/main.yml index 01593aba..971c5af8 100644 --- a/roles/StackStorm.st2/defaults/main.yml +++ b/roles/StackStorm.st2/defaults/main.yml @@ -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 diff --git a/roles/StackStorm.st2/tasks/flush_handlers.yml b/roles/StackStorm.st2/tasks/flush_handlers.yml new file mode 100644 index 00000000..dc4800ef --- /dev/null +++ b/roles/StackStorm.st2/tasks/flush_handlers.yml @@ -0,0 +1,3 @@ +--- +- meta: flush_handlers + tags: st2, st2_packs diff --git a/roles/StackStorm.st2/tasks/main.yml b/roles/StackStorm.st2/tasks/main.yml index 694db9aa..23ebb61f 100644 --- a/roles/StackStorm.st2/tasks/main.yml +++ b/roles/StackStorm.st2/tasks/main.yml @@ -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 diff --git a/roles/StackStorm.st2/tasks/packs.yml b/roles/StackStorm.st2/tasks/packs.yml new file mode 100644 index 00000000..86412aa4 --- /dev/null +++ b/roles/StackStorm.st2/tasks/packs.yml @@ -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 diff --git a/roles/StackStorm.st2smoketests/tasks/main.yml b/roles/StackStorm.st2smoketests/tasks/main.yml index ca3848ba..4331a091 100644 --- a/roles/StackStorm.st2smoketests/tasks/main.yml +++ b/roles/StackStorm.st2smoketests/tasks/main.yml @@ -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