Skip to content

Commit 2f906db

Browse files
authored
Merge pull request #333 from EncoreTechnologies/feature/service-scale-out
Process scale out and coordination
2 parents b744ee6 + cb2618e commit 2f906db

File tree

22 files changed

+340
-52
lines changed

22 files changed

+340
-52
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
## Development
44

5+
- Added the ability to scale out workflowengine, scheduler, rulesengine, and notifier services
6+
so that they run in an active-active configuration
7+
Contributed by @bishopbm1
8+
- Added the Redis configuration for a Coordination backend
9+
Contributed by @bishopbm1
10+
- Added neccessary erlang package required for RHEL 8 rabbitmq
11+
Contributed by @bishopbm1
12+
513
## 2.1.0 (Mar 6, 2021)
614
Note: This version only supports the 'integrated' LDAP plugin.
715

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ classes for use and configuration.
157157
* `st2::profile::nodejs` - st2 configured NodeJS installation
158158
* `st2::profile::python` - Python installed and configured for st2
159159
* `st2::profile::rabbitmq` - st2 configured RabbitMQ installation
160+
* `st2::profile::redis` - st2 configured Redis installation
160161
* `st2::proflle::server` - st2 server components
161162
* `st2::profile::web` - st2 web components
162163
* `st2::profile::chatops` - st2 chatops components
@@ -318,6 +319,33 @@ Configuration via Hiera:
318319
RESPOND_TO_DM: true
319320
```
320321

322+
#### Scaling out services
323+
324+
This module supports scaling out workflowengine, scheduler, rulesengine, and notifier services
325+
per the [ST2 Documentation](https://docs.stackstorm.com/reference/ha.html).
326+
327+
This would be something that you might consider doing if you have alot of rules running or if you
328+
have alot of workflows running in parrallel and/or you have alot of nested workflows and have a server
329+
that can be higher on CPU and Memory to allow more processes to run at the same time.
330+
331+
Configuration all services:
332+
```ruby
333+
class { 'st2':
334+
python_version => '3.6',
335+
workflowengine_num => 4,
336+
scheduler_num => 2,
337+
rulesengine_num => 1,
338+
notifier_num => 1,
339+
}
340+
```
341+
342+
Or configure individual:
343+
```ruby
344+
class { 'st2::workflowengine':
345+
workflowengine_num => 4,
346+
}
347+
```
348+
321349
### Tasks
322350

323351
This module provides several tasks for interacting with StackStorm. These tasks
@@ -484,6 +512,8 @@ please submit a [Pull Request](https://github.com/StackStorm/puppet-st2/pulls).
484512
* StackStorm <[email protected]>
485513
* James Fryman
486514
* Patrick Hoolboom
515+
* Bradley Bishop
516+
* GitHub - [@nmaludy](https://github.com/bishopbm1)
487517

488518
### Help
489519

build/centos7-puppet6/Puppetfile

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# │ └── puppetlabs-concat (v6.2.0)
3232
# ├── puppet-nodejs (v7.0.1)
3333
# ├── puppet-python (v4.1.1)
34+
# ├── puppet-redis (v7.0.0)
3435
# ├─┬ puppet-rabbitmq (v10.1.1)
3536
# │ ├── camptocamp-systemd (v2.9.0)
3637
# │ └── puppet-archive (v4.5.0)
@@ -64,3 +65,4 @@ mod 'puppetlabs-inifile'
6465
mod 'puppetlabs-stdlib'
6566
mod 'puppetlabs-yumrepo_core'
6667
mod 'saz-sudo'
68+
mod 'puppet/redis'

build/centos7-puppet7/Puppetfile

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# │ └── puppetlabs-concat (v6.2.0)
3232
# ├── puppet-nodejs (v7.0.1)
3333
# ├── puppet-python (v4.1.1)
34+
# ├── puppet-redis (v7.0.0)
3435
# ├─┬ puppet-rabbitmq (v10.1.1)
3536
# │ ├── camptocamp-systemd (v2.9.0)
3637
# │ └── puppet-archive (v4.5.0)
@@ -64,3 +65,4 @@ mod 'puppetlabs-inifile'
6465
mod 'puppetlabs-stdlib'
6566
mod 'puppetlabs-yumrepo_core'
6667
mod 'saz-sudo'
68+
mod 'puppet/redis'

build/ubuntu16-puppet6/Puppetfile

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# │ └── puppetlabs-concat (v6.2.0)
3232
# ├── puppet-nodejs (v7.0.1)
3333
# ├── puppet-python (v4.1.1)
34+
# ├── puppet-redis (v7.0.0)
3435
# ├─┬ puppet-rabbitmq (v10.1.1)
3536
# │ ├── camptocamp-systemd (v2.9.0)
3637
# │ └── puppet-archive (v4.5.0)
@@ -64,3 +65,4 @@ mod 'puppetlabs-inifile'
6465
mod 'puppetlabs-stdlib'
6566
mod 'puppetlabs-yumrepo_core'
6667
mod 'saz-sudo'
68+
mod 'puppet/redis'

build/ubuntu16-puppet7/Puppetfile

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# │ └── puppetlabs-concat (v6.2.0)
3232
# ├── puppet-nodejs (v7.0.1)
3333
# ├── puppet-python (v4.1.1)
34+
# ├── puppet-redis (v7.0.0)
3435
# ├─┬ puppet-rabbitmq (v10.1.1)
3536
# │ ├── camptocamp-systemd (v2.9.0)
3637
# │ └── puppet-archive (v4.5.0)
@@ -64,3 +65,4 @@ mod 'puppetlabs-inifile'
6465
mod 'puppetlabs-stdlib'
6566
mod 'puppetlabs-yumrepo_core'
6667
mod 'saz-sudo'
68+
mod 'puppet/redis'

build/ubuntu18-puppet6/Puppetfile

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# │ └── puppetlabs-concat (v6.2.0)
3232
# ├── puppet-nodejs (v7.0.1)
3333
# ├── puppet-python (v4.1.1)
34+
# ├── puppet-redis (v7.0.0)
3435
# ├─┬ puppet-rabbitmq (v10.1.1)
3536
# │ ├── camptocamp-systemd (v2.9.0)
3637
# │ └── puppet-archive (v4.5.0)
@@ -64,3 +65,4 @@ mod 'puppetlabs-inifile'
6465
mod 'puppetlabs-stdlib'
6566
mod 'puppetlabs-yumrepo_core'
6667
mod 'saz-sudo'
68+
mod 'puppet/redis'

build/ubuntu18-puppet7/Puppetfile

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# │ └── puppetlabs-concat (v6.2.0)
3232
# ├── puppet-nodejs (v7.0.1)
3333
# ├── puppet-python (v4.1.1)
34+
# ├── puppet-redis (v7.0.0)
3435
# ├─┬ puppet-rabbitmq (v10.1.1)
3536
# │ ├── camptocamp-systemd (v2.9.0)
3637
# │ └── puppet-archive (v4.5.0)
@@ -64,3 +65,4 @@ mod 'puppetlabs-inifile'
6465
mod 'puppetlabs-stdlib'
6566
mod 'puppetlabs-yumrepo_core'
6667
mod 'saz-sudo'
68+
mod 'puppet/redis'

files/st2_task_base.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,21 @@ def login(self, args):
3939
elif self.username and self.password:
4040
# auth on the command line with username/password
4141
cmd = ['st2', 'auth', '--only-token', '-p', self.password, self.username]
42-
stdout = subprocess.check_output(cmd)
42+
stdout = self.bytes_to_string(subprocess.check_output(cmd))
4343
self.env['ST2_AUTH_TOKEN'] = stdout.rstrip()
4444
# else
4545
# assume auth token is written in client config for this user.
4646
# don't worry, if there is no auth we'll get an error
4747

48+
def bytes_to_string(self, string):
49+
if isinstance(string, bytes):
50+
string = string.decode("utf-8")
51+
52+
return string
53+
4854
def parse_output(self, stdout):
4955
try:
56+
stdout = self.bytes_to_string(stdout)
5057
# try to parse stdout as JSON and return the parse result
5158
return {'result': json.loads(stdout)}
5259
except ValueError:

manifests/init.pp

+21
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,20 @@
212212
# @param nodejs_manage_repo
213213
# Set this to false when you have your own repositories
214214
# for NodeJS (default: true)
215+
# @param redis_bind_ip
216+
# Bind IP of the Redis server. Default is 127.0.0.1
217+
# @param workflowengine_num
218+
# The number of workflowengines to have in an active active state (default: 1)
219+
# @param scheduler_num
220+
# The number of schedulers to have in an active active state (default: 1)
221+
# @param rulesengine_num
222+
# The number of rulesengines to have in an active active state (default: 1)
223+
# @param notifier_num
224+
# The number of notifiers to have in an active active state (default: 1)
225+
# @param erlang_url
226+
# The url for the erlang repositiory to be used for rabbitmq
227+
# @param erlang_key
228+
# The gpg key for the erlang repositiory to be used for rabbitmq
215229
#
216230
#
217231
# @example Basic Usage
@@ -314,6 +328,9 @@
314328
$rabbitmq_port = $::st2::params::rabbitmq_port,
315329
$rabbitmq_bind_ip = $::st2::params::rabbitmq_bind_ip,
316330
$rabbitmq_vhost = $::st2::params::rabbitmq_vhost,
331+
$erlang_url = $::st2::params::erlang_url,
332+
$erlang_key = $::st2::params::erlang_key,
333+
$redis_bind_ip = $::st2::params::redis_bind_ip,
317334
$timersengine_enabled = $::st2::params::timersengine_enabled,
318335
$timersengine_timezone = $::st2::params::timersengine_timezone,
319336
$scheduler_sleep_interval = $::st2::params::scheduler_sleep_interval,
@@ -333,6 +350,10 @@
333350
$chatops_web_url = undef,
334351
$nodejs_version = undef,
335352
$nodejs_manage_repo = true,
353+
$workflowengine_num = $::st2::params::workflowengine_num,
354+
$scheduler_num = $::st2::params::scheduler_num,
355+
$rulesengine_num = $::st2::params::rulesengine_num,
356+
$notifier_num = $::st2::params::notifier_num,
336357
) inherits st2::params {
337358

338359
########################################

manifests/notifier.pp

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# @summary Manages the <code>st2notifier</code> service (Orquesta)
2+
#
3+
# Normally this class is instantiated by +st2::profile::fullinstall+.
4+
# However, advanced users can instantiate this class directly to configure
5+
# and manage just the <code>st2notifier</code> service on a single node.
6+
# Parameters for this class mirror the parameters in the st2 config.
7+
#
8+
# @see https://github.com/StackStorm/st2/blob/master/conf/st2.conf.sample
9+
#
10+
# @example Basic usage
11+
# include st2::notifier
12+
#
13+
# @param notifier_num
14+
# The number of notifiers to have in an active active state
15+
# @param notifier_services
16+
# Name of all the notifier services
17+
#
18+
class st2::notifier (
19+
$notifier_num = $st2::notifier_num,
20+
$notifier_services = $st2::params::notifier_services,
21+
) inherits st2 {
22+
23+
$_logger_config = $::st2::syslog ? {
24+
true => 'syslog',
25+
default => 'logging',
26+
}
27+
28+
########################################
29+
## Config
30+
ini_setting { 'notifier_logging':
31+
ensure => present,
32+
path => '/etc/st2/st2.conf',
33+
section => 'notifier',
34+
setting => 'logging',
35+
value => "/etc/st2/${_logger_config}.notifier.conf",
36+
tag => 'st2::config',
37+
}
38+
39+
st2::service { 'st2notifier':
40+
service_name => 'st2notifier',
41+
service_num => $notifier_num,
42+
existing_services => $notifier_services,
43+
}
44+
}

manifests/params.pp

+25-2
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,20 @@
8787
'st2api',
8888
'st2auth',
8989
'st2garbagecollector',
90-
'st2notifier',
91-
'st2rulesengine',
9290
'st2sensorcontainer',
9391
'st2stream',
9492
]
9593

94+
## StackStorm Workflow Engine (Orchestra)
95+
$rulesengine_services = [
96+
'st2rulesengine',
97+
]
98+
99+
## StackStorm Workflow Engine (Orchestra)
100+
$notifier_services = [
101+
'st2notifier',
102+
]
103+
96104
## StackStorm ChatOps services
97105
$st2_chatops_services = [
98106
'st2chatops',
@@ -144,6 +152,18 @@
144152
# no max on the body size for large workflow support
145153
$nginx_client_max_body_size = '0'
146154

155+
# Number of workflow engines to run
156+
$workflowengine_num = 1
157+
158+
# Number of schedulers to run
159+
$scheduler_num = 1
160+
161+
# Number of rules engines to run
162+
$rulesengine_num = 1
163+
164+
# Number of notifiers to run
165+
$notifier_num = 1
166+
147167
# st2web
148168
$web_root = '/opt/stackstorm/static/webui/'
149169

@@ -164,6 +184,9 @@
164184
$rabbitmq_port = 5672
165185
$rabbitmq_bind_ip = '127.0.0.1'
166186
$rabbitmq_vhost = '/'
187+
$erlang_url = "https://packagecloud.io/rabbitmq/erlang/el/${facts['os'][release][major]}/\$basearch"
188+
$erlang_key = 'https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey'
189+
$redis_bind_ip = '127.0.0.1'
167190

168191
## actionrunner config
169192
$actionrunner_workers = 10

manifests/profile/fullinstall.pp

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
-> class { 'st2::repo': }
3333
-> class { 'st2::profile::selinux': }
3434
-> Anchor['st2::pre_reqs']
35+
-> class { 'st2::profile::redis': }
3536
-> class { 'st2::profile::python': }
3637
-> class { 'st2::profile::nodejs': }
3738
-> class { 'st2::profile::rabbitmq': }

manifests/profile/python.pp

+3-4
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@
4949

5050
# intall python and python-devel / python-dev
5151
class { 'python':
52-
version => $version,
53-
dev => present,
54-
manage_pip_package => false,
55-
manage_virtualenv_package => false,
52+
version => $version,
53+
dev => present,
54+
manage_pip_package => false,
5655
}
5756
}
5857
}

manifests/profile/rabbitmq.pp

+19-5
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,30 @@
2222
# include st2::profile::rabbitmq
2323
#
2424
class st2::profile::rabbitmq (
25-
$username = $::st2::rabbitmq_username,
26-
$password = $::st2::rabbitmq_password,
27-
$port = $::st2::rabbitmq_port,
28-
$bind_ip = $::st2::rabbitmq_bind_ip,
29-
$vhost = $::st2::rabbitmq_vhost,
25+
$username = $::st2::rabbitmq_username,
26+
$password = $::st2::rabbitmq_password,
27+
$port = $::st2::rabbitmq_port,
28+
$bind_ip = $::st2::rabbitmq_bind_ip,
29+
$vhost = $::st2::rabbitmq_vhost,
30+
$erlang_url = $::st2::erlang_url,
31+
$erlang_key = $::st2::erlang_key
3032
) inherits st2 {
3133

3234
# RHEL 8 Requires another repo in addition to epel to be installed
3335
if ($::osfamily == 'RedHat') and ($facts['os']['release']['major'] == '8') {
3436
$repos_ensure = true
37+
38+
# This is required because when using the latest version of rabbitmq because the latest version in EPEL
39+
# for Erlang is 22.0.7 which is not compatible: https://www.rabbitmq.com/which-erlang.html
40+
yumrepo { 'erlang':
41+
ensure => present,
42+
name => 'rabbitmq_erlang',
43+
baseurl => $erlang_url,
44+
gpgkey => $erlang_key,
45+
enabled => 1,
46+
gpgcheck => 1,
47+
before => Class['rabbitmq::repo::rhel'],
48+
}
3549
}
3650
else {
3751
$repos_ensure = false

manifests/profile/redis.pp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# @summary StackStorm compatable installation of Redis.
2+
#
3+
# @param [String] String
4+
# Bind IP of the Redis server. Default is 127.0.0.1
5+
#
6+
# @example Basic Usage
7+
# include st2::profile::redis
8+
#
9+
# @example Install with redis
10+
# class { '::redis':
11+
# bind => '127.0.0.1',
12+
# }
13+
#
14+
class st2::profile::redis (
15+
String $bind_ip = $st2::redis_bind_ip,
16+
) inherits st2 {
17+
18+
class { 'redis':
19+
bind => $bind_ip,
20+
}
21+
22+
contain redis
23+
}

0 commit comments

Comments
 (0)