Skip to content

Commit

Permalink
Upgrade st2.conf to add new services: timersengine, workflowengine
Browse files Browse the repository at this point in the history
This makes sure that new services (timersengine, workflowengine) get
added to st2.conf on upgrade.

Also makes the list of st2_services version dependent.
As there is no good way to tell 'present' from 'latest', a service
restart may fail when st2_version='present' and the actual version is
not 2.9 or greater. But, if a user has pinned a version, then this
safely only starts/restarts the services that are valid for that
version.

Resolves StackStorm#196
  • Loading branch information
cognifloyd committed Sep 22, 2018
1 parent 7a1b20e commit ac87d08
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 2 deletions.
10 changes: 10 additions & 0 deletions roles/st2/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@
when: (st2_config.auth|default({})).enable|default(st2_auth_enable)
tags: st2, auth

- name: Configure st2workflowengine (2.8+)
when: "(st2_version in ['latest', 'present']) or (st2_version is version_compare('2.8', '>='))"
include: workflowengine.yml
tags: st2, config

- name: Configure st2timersengine (2.9+)
when: "(st2_version in ['latest', 'present']) or (st2_version is version_compare('2.9', '>='))"
include: timersengine.yml
tags: st2, config

- name: Configure StackStorm st2.conf settings
# Ansible nested loop to iterate through a hash of hashes
include: config.yml _conf_section_name={{ _conf_section.key }} _conf_options={{ _conf_section.value }}
Expand Down
35 changes: 35 additions & 0 deletions roles/st2/tasks/timersengine.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
- name: timer config deprecation notice
when: "'timer' in st2_config"
debug:
msg: |
The 'timer' section in st2_config is deprecated.
We recommend renaming 'timer' to 'timersengine'.
See https://docs.stackstorm.com/upgrade_notes.html#st2-v2-9
- name: Ensure timersengine section is present in st2.conf on upgrade
when: "'timersengine' not in st2_config"
include: config.yml _conf_section_name={{ _conf_section.key }} _conf_options={{ _conf_section.value }}
with_dict:
timersengine:
enable: "{{ (st2_config.timer|default({})).enable|default(true) }}"
local_timezone: "{{ (st2_config.timer|default({})).local_timezone|default('America/Los_Angeles') }}"
logging: conf/logging.timersengine.conf
loop_control:
loop_var: _conf_section

- name: Update timer.logging in st2.conf on upgrade
when: "('timer' in st2_config) and ('logging' not in st2_config.timer)"
include: config.yml _conf_section_name={{ _conf_section.key }} _conf_options={{ _conf_section.value }}
with_dict:
timer:
logging: conf/logging.timersengine.conf
loop_control:
loop_var: _conf_section

- name: Remove timer section
when: "('timersengine' in st2_config) and ('timer' not in st2_config)"
ini_file:
dest: /etc/st2/st2.conf
section: "timer"
state: absent
9 changes: 9 additions & 0 deletions roles/st2/tasks/workflowengine.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Ensure workflow_engine section is present in st2.conf on upgrade
when: "('workflow_engine' not in st2_config) or ('logging' not in st2_config.workflow_engine)"
include: config.yml _conf_section_name={{ _conf_section.key }} _conf_options={{ _conf_section.value }}
with_dict:
workflow_engine:
logging: conf/logging.workflowengine.conf
loop_control:
loop_var: _conf_section
13 changes: 11 additions & 2 deletions roles/st2/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# Default st2 immutable vars
---
# List of available `st2` services:
# https://github.com/StackStorm/st2/blob/master/st2common/bin/st2ctl#L5
st2_services:
# https://github.com/StackStorm/st2/blob/master/st2common/bin/st2ctl#L17
st2_services: "\
{% if st2_version in ['latest', 'present'] %}{{ st2_services_2_7 + st2_services_2_8 + st2_services_2_9 }}\
{% elif st2_version is version_compare('2_8', '<') %}{{ st2_services_2_7 }}\
{% elif st2_version is version_compare('2_9', '<') %}{{ st2_services_2_7 + st2_services_2_8 }}\
{% else %}{{ st2_services_2_7 + st2_services_2_8 + st2_services_2_9 }}\
{% endif %}"
st2_services_2_7:
- st2actionrunner
- st2garbagecollector
- st2notifier
Expand All @@ -12,7 +18,10 @@ st2_services:
- st2api
- st2stream
- st2auth
st2_services_2_8:
- st2workflowengine
st2_services_2_9:
- st2timersengine

# Where to store the ST2 datastore encryption key (automatically generated during install)
st2_datastore_key_file: /etc/st2/keys/datastore_key.json
Expand Down

0 comments on commit ac87d08

Please sign in to comment.