Skip to content

Commit 23f100c

Browse files
authored
Merge pull request #698 from StackStorm/setup-redis
Add redis to install scripts
2 parents 3edb527 + 90d7991 commit 23f100c

16 files changed

+105
-10
lines changed

.circle/docker-compose.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set -e
1111
# Source the build environment defintion (details in buildenv.sh)
1212
. ~/.buildenv
1313

14-
# Used for `RABBITMQHOST` `MONGODBHOST`, see docker-compose.override.yml
14+
# Used for `RABBITMQHOST`, `MONGODBHOST`, and `REDISHOST` see docker-compose.override.yml
1515
HOST_IP=$(ifconfig docker0 | grep 'inet addr' | awk -F: '{print $2}' | awk '{print $1}')
1616

1717
set -x
@@ -26,6 +26,7 @@ case "$1" in
2626
-e ST2PKG_RELEASE=${ST2PKG_RELEASE} \
2727
-e RABBITMQHOST=${HOST_IP} \
2828
-e MONGODBHOST=${HOST_IP} \
29+
-e REDISHOST=${HOST_IP} \
2930
-e ST2_CIRCLE_URL=${CIRCLE_BUILD_URL} \
3031
$2 /bin/true
3132
;;
@@ -38,6 +39,7 @@ case "$1" in
3839
-e ST2PKG_RELEASE=${ST2PKG_RELEASE} \
3940
-e RABBITMQHOST=${HOST_IP} \
4041
-e MONGODBHOST=${HOST_IP} \
42+
-e REDISHOST=${HOST_IP} \
4143
-e ST2_PACKAGES="${ST2_PACKAGES}" \
4244
-e ST2_CIRCLE_URL=${CIRCLE_BUILD_URL} \
4345
$2 build
@@ -52,6 +54,7 @@ case "$1" in
5254
-e ST2PKG_RELEASE=${ST2PKG_RELEASE} \
5355
-e RABBITMQHOST=${HOST_IP} \
5456
-e MONGODBHOST=${HOST_IP} \
57+
-e REDISHOST=${HOST_IP} \
5558
-e ST2_PACKAGES="${ST2_PACKAGES}" \
5659
-e ST2_CIRCLE_URL=${CIRCLE_BUILD_URL} \
5760
$2 test

docker-compose.circle.yml

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ bionic:
2424
- bionictest
2525
- rabbitmq
2626
- mongodb
27+
- redis
2728

2829
el8:
2930
image: quay.io/stackstorm/packagingrunner
@@ -39,6 +40,7 @@ el8:
3940
- centos8test
4041
- rabbitmq
4142
- mongodb
43+
- redis
4244

4345
el7:
4446
image: quay.io/stackstorm/packagingrunner

docker-compose.circle2.yml

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ xenial:
1111
- xenialtest
1212
- rabbitmq
1313
- mongodb
14+
- redis
1415

1516
bionic:
1617
image: quay.io/stackstorm/packagingrunner
@@ -26,6 +27,7 @@ bionic:
2627
- bionictest
2728
- rabbitmq
2829
- mongodb
30+
- redis
2931

3032
el8:
3133
image: quay.io/stackstorm/packagingrunner
@@ -40,6 +42,7 @@ el8:
4042
- centos8test
4143
- rabbitmq
4244
- mongodb
45+
- redis
4346

4447
el7:
4548
image: quay.io/stackstorm/packagingrunner
@@ -54,6 +57,7 @@ el7:
5457
- centos7test
5558
- rabbitmq
5659
- mongodb
60+
- redis
5761

5862
## Package build nodes
5963
#

docker-compose.override.yml

+5
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,8 @@ mongodb:
4848
image: mongo:4.0
4949
ports:
5050
- "27017:27017"
51+
52+
redis:
53+
image: redis:latest
54+
ports:
55+
- "6379:6379"

docker-compose.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ xenial:
1111
- xenialtest
1212
- rabbitmq
1313
- mongodb
14+
- redis
1415

1516
bionic:
1617
image: quay.io/stackstorm/packagingrunner
@@ -26,6 +27,7 @@ bionic:
2627
- bionictest
2728
- rabbitmq
2829
- mongodb
30+
- redis
2931

3032
el8:
3133
image: quay.io/stackstorm/packagingrunner
@@ -41,7 +43,7 @@ el8:
4143
- centos8test
4244
- rabbitmq
4345
- mongodb
44-
46+
- redis
4547

4648
el7:
4749
image: quay.io/stackstorm/packagingrunner
@@ -56,6 +58,7 @@ el7:
5658
- centos7test
5759
- rabbitmq
5860
- mongodb
61+
- redis
5962

6063
## Package build nodes
6164
#

rake/build/environment.rb

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
# Default hostnames of dependat services (the value can take an address also)
5959
envpass :rabbitmqhost, 'rabbitmq', proc: convert_to_ipaddr
6060
envpass :mongodbhost, 'mongodb', proc: convert_to_ipaddr
61+
envpass :redishost, 'redis', proc: convert_to_ipaddr
6162

6263
# upload_sources - a list of directories which should be propogated
6364
# to remote nodes.

rake/spec/default/60-st2_all-services-ok_spec.rb

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
it { is_expected.to be_reachable.with :port => 27017, :timeout => 1 }
1616
end
1717

18+
describe 'redis' do
19+
subject { host(spec[:redishost]) }
20+
it { is_expected.to be_reachable.with :port => 6379, :timeout => 1 }
21+
end
22+
1823
end
1924

2025
describe 'start st2 components and services' do

rake/spec/spec_helper.rb

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class ST2Spec
3131
package_list: pipeopts.packages,
3232
rabbitmqhost: pipeopts.rabbitmqhost,
3333
mongodbhost: pipeopts.mongodbhost,
34+
redishost: pipeopts.redishost,
3435
loglines_to_show: 100,
3536
logdest_pattern: {
3637
st2actionrunner: 'st2actionrunner.{pid}'

scripts/generate_st2_config.sh

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set -e
88
# --- Go!
99
MONGOHOST="${MONGODBHOST:-mongodb}"
1010
RABBITMQHOST="${RABBITMQHOST:-rabbitmq}"
11+
REDISHOST="${REDISHOST:-redis}"
1112

1213
CONF=/etc/st2/st2.conf
1314
AMQP="amqp://guest:guest@$RABBITMQHOST:5672/"
@@ -20,6 +21,7 @@ EHD
2021
# Don't join into one cmd with previous, otherwise it becomes
2122
# non-interactive waiting ^D.
2223
MONGO=$(echo "$MONGO" | sed -r 's/^\s+//')
24+
REDIS="redis://${REDISHOST}:6379"
2325

2426
# Specify rabbitmq host
2527
sed -i "/\[messaging\]/,/\[.*\]\|url/ {n; s#url.*=.*#url = $AMQP#}" $CONF
@@ -28,4 +30,7 @@ sed -i "/\[auth\]/,/\[.*\]\|enable/ {n; s#enable.*=.*#enable = False#}" $CONF
2830
# Create database section, st2.conf ships without it
2931
(grep "\[database\]" $CONF &>/dev/null) || echo "$MONGO" >> /etc/st2/st2.conf
3032

33+
# Specify redis host
34+
sed -i "/\[coordination\]/,/\[.*\]\|url/ {n; s#url.*=.*#url = $REDIS#}" $CONF
35+
3136
echo "Resulting $CONF >>>" "$(cat $CONF)"

scripts/includes/common.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ check_st2_host_dependencies() {
8383
# CHECK 1: Determine which, if any, of the required ports are used by an existing process.
8484

8585
# Abort the installation early if the following ports are being used by an existing process.
86-
# nginx (80, 443), mongodb (27017), rabbitmq (4369, 5672, 25672), and st2 (9100-9102).
86+
# nginx (80, 443), mongodb (27017), rabbitmq (4369, 5672, 25672), redis (6379)
87+
# and st2 (9100-9102).
8788

88-
declare -a ports=("80" "443" "4369" "5672" "9100" "9101" "9102" "25672" "27017")
89+
declare -a ports=("80" "443" "4369" "5672" "6379" "9100" "9101" "9102" "25672" "27017")
8990
declare -a used=()
9091

9192
for i in "${ports[@]}"

scripts/st2bootstrap-deb.sh

+12-2
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,10 @@ check_st2_host_dependencies() {
233233
# CHECK 1: Determine which, if any, of the required ports are used by an existing process.
234234

235235
# Abort the installation early if the following ports are being used by an existing process.
236-
# nginx (80, 443), mongodb (27017), rabbitmq (4369, 5672, 25672), and st2 (9100-9102).
236+
# nginx (80, 443), mongodb (27017), rabbitmq (4369, 5672, 25672), redis (6379)
237+
# and st2 (9100-9102).
237238

238-
declare -a ports=("80" "443" "4369" "5672" "9100" "9101" "9102" "25672" "27017")
239+
declare -a ports=("80" "443" "4369" "5672" "6379" "9100" "9101" "9102" "25672" "27017")
239240
declare -a used=()
240241

241242
for i in "${ports[@]}"
@@ -548,6 +549,11 @@ EOF
548549

549550
}
550551

552+
install_redis() {
553+
# Install Redis Server. By default, redis only listen on localhost only.
554+
sudo apt-get install -y redis-server
555+
}
556+
551557
get_full_pkg_versions() {
552558
if [[ "$VERSION" != '' ]];
553559
then
@@ -609,6 +615,9 @@ install_st2() {
609615
# Configure [messaging] section in st2.conf (username password for RabbitMQ access)
610616
AMQP="amqp://stackstorm:$ST2_RABBITMQ_PASSWORD@127.0.0.1:5672"
611617
sudo crudini --set /etc/st2/st2.conf messaging url "${AMQP}"
618+
619+
# Configure [coordination] section in st2.conf (url for Redis access)
620+
sudo crudini --set /etc/st2/st2.conf coordination url "redis://127.0.0.1:6379"
612621

613622
sudo st2ctl start
614623
sudo st2ctl reload --register-all
@@ -712,6 +721,7 @@ STEP="Configure Proxy" && configure_proxy
712721
STEP="Install st2 dependencies" && install_st2_dependencies
713722
STEP="Install st2 dependencies (RabbitMQ)" && install_rabbitmq
714723
STEP="Install st2 dependencies (MongoDB)" && install_mongodb
724+
STEP="Install st2 dependencies (Redis)" && install_redis
715725
STEP="Install st2" && install_st2
716726
STEP="Configure st2 user" && configure_st2_user
717727
STEP="Configure st2 auth" && configure_st2_authentication

scripts/st2bootstrap-deb.template.sh

+9
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@ EOF
235235

236236
}
237237

238+
install_redis() {
239+
# Install Redis Server. By default, redis only listen on localhost only.
240+
sudo apt-get install -y redis-server
241+
}
242+
238243
get_full_pkg_versions() {
239244
if [[ "$VERSION" != '' ]];
240245
then
@@ -296,6 +301,9 @@ install_st2() {
296301
# Configure [messaging] section in st2.conf (username password for RabbitMQ access)
297302
AMQP="amqp://stackstorm:$ST2_RABBITMQ_PASSWORD@127.0.0.1:5672"
298303
sudo crudini --set /etc/st2/st2.conf messaging url "${AMQP}"
304+
305+
# Configure [coordination] section in st2.conf (url for Redis access)
306+
sudo crudini --set /etc/st2/st2.conf coordination url "redis://127.0.0.1:6379"
299307

300308
sudo st2ctl start
301309
sudo st2ctl reload --register-all
@@ -399,6 +407,7 @@ STEP="Configure Proxy" && configure_proxy
399407
STEP="Install st2 dependencies" && install_st2_dependencies
400408
STEP="Install st2 dependencies (RabbitMQ)" && install_rabbitmq
401409
STEP="Install st2 dependencies (MongoDB)" && install_mongodb
410+
STEP="Install st2 dependencies (Redis)" && install_redis
402411
STEP="Install st2" && install_st2
403412
STEP="Configure st2 user" && configure_st2_user
404413
STEP="Configure st2 auth" && configure_st2_authentication

scripts/st2bootstrap-el7.sh

+14-2
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,10 @@ check_st2_host_dependencies() {
194194
# CHECK 1: Determine which, if any, of the required ports are used by an existing process.
195195

196196
# Abort the installation early if the following ports are being used by an existing process.
197-
# nginx (80, 443), mongodb (27017), rabbitmq (4369, 5672, 25672), and st2 (9100-9102).
197+
# nginx (80, 443), mongodb (27017), rabbitmq (4369, 5672, 25672), redis (6379)
198+
# and st2 (9100-9102).
198199

199-
declare -a ports=("80" "443" "4369" "5672" "9100" "9101" "9102" "25672" "27017")
200+
declare -a ports=("80" "443" "4369" "5672" "6379" "9100" "9101" "9102" "25672" "27017")
200201
declare -a used=()
201202

202203
for i in "${ports[@]}"
@@ -585,6 +586,13 @@ EOF
585586
sudo systemctl restart mongod
586587
}
587588

589+
install_redis() {
590+
# Install Redis Server. By default, redis only listen on localhost only.
591+
sudo yum install -y redis
592+
sudo systemctl start redis
593+
sudo systemctl enable redis
594+
}
595+
588596
install_st2() {
589597
curl -sL https://packagecloud.io/install/repositories/StackStorm/${REPO_PREFIX}${RELEASE}/script.rpm.sh | sudo bash
590598

@@ -606,6 +614,9 @@ install_st2() {
606614
AMQP="amqp://stackstorm:$ST2_RABBITMQ_PASSWORD@127.0.0.1:5672"
607615
sudo crudini --set /etc/st2/st2.conf messaging url "${AMQP}"
608616

617+
# Configure [coordination] section in st2.conf (url for Redis access)
618+
sudo crudini --set /etc/st2/st2.conf coordination url "redis://127.0.0.1:6379"
619+
609620
sudo st2ctl start
610621
sudo st2ctl reload --register-all
611622
}
@@ -725,6 +736,7 @@ STEP="Generate random password" && generate_random_passwords
725736
STEP="Install st2 dependencies" && install_st2_dependencies
726737
STEP="Install st2 dependencies (RabbitMQ)" && install_rabbitmq
727738
STEP="Install st2 dependencies (MongoDB)" && install_mongodb
739+
STEP="Install st2 dependencies (Redis)" && install_redis
728740
STEP="Install st2" && install_st2
729741
STEP="Configure st2 user" && configure_st2_user
730742
STEP="Configure st2 auth" && configure_st2_authentication

scripts/st2bootstrap-el7.template.sh

+11
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,13 @@ EOF
222222
sudo systemctl restart mongod
223223
}
224224

225+
install_redis() {
226+
# Install Redis Server. By default, redis only listen on localhost only.
227+
sudo yum install -y redis
228+
sudo systemctl start redis
229+
sudo systemctl enable redis
230+
}
231+
225232
install_st2() {
226233
curl -sL https://packagecloud.io/install/repositories/StackStorm/${REPO_PREFIX}${RELEASE}/script.rpm.sh | sudo bash
227234

@@ -243,6 +250,9 @@ install_st2() {
243250
AMQP="amqp://stackstorm:$ST2_RABBITMQ_PASSWORD@127.0.0.1:5672"
244251
sudo crudini --set /etc/st2/st2.conf messaging url "${AMQP}"
245252

253+
# Configure [coordination] section in st2.conf (url for Redis access)
254+
sudo crudini --set /etc/st2/st2.conf coordination url "redis://127.0.0.1:6379"
255+
246256
sudo st2ctl start
247257
sudo st2ctl reload --register-all
248258
}
@@ -362,6 +372,7 @@ STEP="Generate random password" && generate_random_passwords
362372
STEP="Install st2 dependencies" && install_st2_dependencies
363373
STEP="Install st2 dependencies (RabbitMQ)" && install_rabbitmq
364374
STEP="Install st2 dependencies (MongoDB)" && install_mongodb
375+
STEP="Install st2 dependencies (Redis)" && install_redis
365376
STEP="Install st2" && install_st2
366377
STEP="Configure st2 user" && configure_st2_user
367378
STEP="Configure st2 auth" && configure_st2_authentication

scripts/st2bootstrap-el8.sh

+14-2
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,10 @@ check_st2_host_dependencies() {
198198
# CHECK 1: Determine which, if any, of the required ports are used by an existing process.
199199

200200
# Abort the installation early if the following ports are being used by an existing process.
201-
# nginx (80, 443), mongodb (27017), rabbitmq (4369, 5672, 25672), and st2 (9100-9102).
201+
# nginx (80, 443), mongodb (27017), rabbitmq (4369, 5672, 25672), redis (6379)
202+
# and st2 (9100-9102).
202203

203-
declare -a ports=("80" "443" "4369" "5672" "9100" "9101" "9102" "25672" "27017")
204+
declare -a ports=("80" "443" "4369" "5672" "6379" "9100" "9101" "9102" "25672" "27017")
204205
declare -a used=()
205206

206207
for i in "${ports[@]}"
@@ -592,6 +593,13 @@ EOF
592593
sudo systemctl restart mongod
593594
}
594595

596+
install_redis() {
597+
# Install Redis Server. By default, redis only listen on localhost only.
598+
sudo yum install -y redis
599+
sudo systemctl start redis
600+
sudo systemctl enable redis
601+
}
602+
595603
install_st2() {
596604
curl -sL https://packagecloud.io/install/repositories/StackStorm/${REPO_PREFIX}${RELEASE}/script.rpm.sh | sudo bash
597605

@@ -613,6 +621,9 @@ install_st2() {
613621
AMQP="amqp://stackstorm:$ST2_RABBITMQ_PASSWORD@127.0.0.1:5672"
614622
sudo crudini --set /etc/st2/st2.conf messaging url "${AMQP}"
615623

624+
# Configure [coordination] section in st2.conf (url for Redis access)
625+
sudo crudini --set /etc/st2/st2.conf coordination url "redis://127.0.0.1:6379"
626+
616627
sudo st2ctl start
617628
sudo st2ctl reload --register-all
618629
}
@@ -748,6 +759,7 @@ STEP="Generate random password" && generate_random_passwords
748759
STEP="Install st2 dependencies" && install_st2_dependencies
749760
STEP="Install st2 dependencies (RabbitMQ)" && install_rabbitmq
750761
STEP="Install st2 dependencies (MongoDB)" && install_mongodb
762+
STEP="Install st2 dependencies (Redis)" && install_redis
751763
STEP="Install st2" && install_st2
752764
STEP="Configure st2 user" && configure_st2_user
753765
STEP="Configure st2 auth" && configure_st2_authentication

0 commit comments

Comments
 (0)