Skip to content

Commit 5c0ca15

Browse files
committed
Add custom script to loop to jobs we want to trigger from master
Signed-off-by: Pedro Algarvio <[email protected]>
1 parent f34540a commit 5c0ca15

9 files changed

+85
-30
lines changed

docker/elastic/centosstream8.Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@ RUN ls -lah /src \
3030

3131
FROM base as minion-2
3232

33+
RUN dnf install -y salt-minion
3334
ADD docker/elastic/conf/supervisord.minion.conf /etc/supervisor/conf.d/minion.conf
3435
ADD docker/elastic/conf/beacons.conf /etc/salt/minion.d/beacons.conf
3536
ADD docker/elastic/conf/analytics.minion.conf /etc/salt/minion.d/salt-analytics.conf
36-
ADD docker/elastic/conf/demo-schedule.conf /etc/salt/minion.d/demo-schedule.conf
3737
ADD docker/elastic/conf/logging.conf /etc/salt/minion.d/logging.conf
3838
RUN mkdir -p /etc/salt/minion.d \
3939
&& echo 'id: minion-2' > /etc/salt/minion.d/id.conf \
40-
&& echo 'master: master-1' > /etc/salt/minion.d/master.conf \
41-
&& dnf install -y salt-minion
40+
&& echo 'master: master-1' > /etc/salt/minion.d/master.conf
4241

4342
CMD ["/usr/bin/supervisord","-c","/etc/supervisor/supervisord.conf"]

docker/elastic/centosstream9.Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,28 @@ RUN ls -lah /src \
3030

3131
FROM base as master-1
3232

33+
RUN dnf install -y salt-master
3334
ADD docker/elastic/conf/supervisord.master.conf /etc/supervisor/conf.d/master.conf
35+
ADD docker/elastic/conf/supervisord.loop-jobs.conf /etc/supervisor/conf.d/loop-jobs.conf
36+
ADD docker/elastic/loop-jobs.sh /usr/bin/loop-jobs.sh
3437
ADD docker/elastic/conf/analytics.master.conf /etc/salt/master.d/salt-analytics.conf
3538
ADD docker/elastic/conf/logging.conf /etc/salt/master.d/logging.conf
3639
RUN mkdir -p /etc/salt/master.d \
3740
&& echo 'id: master-1' > /etc/salt/master.d/id.conf \
38-
&& echo 'open_mode: true' > /etc/salt/master.d/open-mode.conf \
39-
&& dnf install -y salt-master
41+
&& echo 'open_mode: true' > /etc/salt/master.d/open-mode.conf
4042

4143
CMD ["/usr/bin/supervisord","-c","/etc/supervisor/supervisord.conf"]
4244

4345

4446
FROM base as minion-1
4547

48+
RUN dnf install -y salt-minion
4649
ADD docker/elastic/conf/supervisord.minion.conf /etc/supervisor/conf.d/minion.conf
4750
ADD docker/elastic/conf/beacons.conf /etc/salt/minion.d/beacons.conf
4851
ADD docker/elastic/conf/analytics.minion.conf /etc/salt/minion.d/salt-analytics.conf
49-
ADD docker/elastic/conf/demo-schedule.conf /etc/salt/minion.d/demo-schedule.conf
5052
ADD docker/elastic/conf/logging.conf /etc/salt/minion.d/logging.conf
5153
RUN mkdir -p /etc/salt/minion.d \
5254
&& echo 'id: minion-1' > /etc/salt/minion.d/id.conf \
53-
&& echo 'master: master-1' > /etc/salt/minion.d/master.conf \
54-
&& dnf install -y salt-minion
55+
&& echo 'master: master-1' > /etc/salt/minion.d/master.conf
5556

5657
CMD ["/usr/bin/supervisord","-c","/etc/supervisor/supervisord.conf"]

docker/elastic/conf/analytics.master.conf

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,20 @@ analytics:
1212
processors:
1313
job-aggregate:
1414
plugin: job-aggregate
15+
cast-to-es:
16+
plugin: jobs_to_es
1517

1618
forwarders:
17-
test-forwarder:
18-
plugin: test
19+
elasticsearch-forwarder:
20+
plugin: elasticsearch
21+
hosts:
22+
- http://node01:9200
1923

2024
pipelines:
2125

2226
jobs-pipeline:
2327
collect: events-collector
24-
process: job-aggregate
25-
forward: test-forwarder
28+
process:
29+
- job-aggregate
30+
- cast-to-es
31+
forward: elasticsearch-forwarder

docker/elastic/conf/demo-schedule.conf

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[program:loop-jobs]
2+
command=/bin/sh /usr/bin/loop-jobs.sh

docker/elastic/debian10.Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@ RUN ls -lah /src \
3030

3131
FROM base as minion-4
3232

33+
RUN apt install -y salt-minion
3334
ADD docker/elastic/conf/supervisord.minion.conf /etc/supervisor/conf.d/minion.conf
3435
ADD docker/elastic/conf/beacons.conf /etc/salt/minion.d/beacons.conf
3536
ADD docker/elastic/conf/analytics.minion.conf /etc/salt/minion.d/salt-analytics.conf
36-
ADD docker/elastic/conf/demo-schedule.conf /etc/salt/minion.d/demo-schedule.conf
3737
ADD docker/elastic/conf/logging.conf /etc/salt/minion.d/logging.conf
3838
RUN mkdir -p /etc/salt/minion.d \
3939
&& echo 'id: minion-4' > /etc/salt/minion.d/id.conf \
40-
&& echo 'master: master-2' > /etc/salt/minion.d/master.conf \
41-
&& apt install -y salt-minion
40+
&& echo 'master: master-2' > /etc/salt/minion.d/master.conf
4241

4342
CMD ["/usr/bin/supervisord","-c","/etc/supervisor/supervisord.conf"]

docker/elastic/debian11.Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,28 @@ RUN ls -lah /src \
3030

3131
FROM base as master-2
3232

33+
RUN apt install -y salt-master
3334
ADD docker/elastic/conf/supervisord.master.conf /etc/supervisor/conf.d/master.conf
35+
ADD docker/elastic/conf/supervisord.loop-jobs.conf /etc/supervisor/conf.d/loop-jobs.conf
36+
ADD docker/elastic/loop-jobs.sh /usr/bin/loop-jobs.sh
3437
ADD docker/elastic/conf/analytics.master.conf /etc/salt/master.d/salt-analytics.conf
3538
ADD docker/elastic/conf/logging.conf /etc/salt/master.d/logging.conf
3639
RUN mkdir -p /etc/salt/master.d \
3740
&& echo 'id: master-2' > /etc/salt/master.d/id.conf \
38-
&& echo 'open_mode: true' > /etc/salt/master.d/open-mode.conf \
39-
&& apt install -y salt-master
41+
&& echo 'open_mode: true' > /etc/salt/master.d/open-mode.conf
4042

4143
CMD ["/usr/bin/supervisord","-c","/etc/supervisor/supervisord.conf"]
4244

4345

4446
FROM base as minion-3
4547

48+
RUN apt install -y salt-minion
4649
ADD docker/elastic/conf/supervisord.minion.conf /etc/supervisor/conf.d/minion.conf
4750
ADD docker/elastic/conf/beacons.conf /etc/salt/minion.d/beacons.conf
4851
ADD docker/elastic/conf/analytics.minion.conf /etc/salt/minion.d/salt-analytics.conf
49-
ADD docker/elastic/conf/demo-schedule.conf /etc/salt/minion.d/demo-schedule.conf
5052
ADD docker/elastic/conf/logging.conf /etc/salt/minion.d/logging.conf
5153
RUN mkdir -p /etc/salt/minion.d \
5254
&& echo 'id: minion-3' > /etc/salt/minion.d/id.conf \
53-
&& echo 'master: master-2' > /etc/salt/minion.d/master.conf \
54-
&& apt install -y salt-minion
55+
&& echo 'master: master-2' > /etc/salt/minion.d/master.conf
5556

5657
CMD ["/usr/bin/supervisord","-c","/etc/supervisor/supervisord.conf"]

docker/elastic/docker-compose.yml

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ services:
3030
- es-network
3131
depends_on:
3232
- node01
33+
healthcheck:
34+
test:
35+
[
36+
"CMD-SHELL",
37+
"curl -s -I http://localhost:5601 | grep -q 'HTTP/1.1 302 Found'",
38+
]
39+
interval: 10s
40+
timeout: 10s
41+
retries: 120
3342

3443
metricbeat:
3544
image: docker.elastic.co/beats/metricbeat:${STACK_VERSION}
@@ -45,7 +54,8 @@ services:
4554

4655
master-1:
4756
depends_on:
48-
- kibana
57+
kibana:
58+
condition: service_healthy
4959
container_name: master-1
5060
build:
5161
context: ../../
@@ -55,9 +65,21 @@ services:
5565
es-network:
5666
aliases:
5767
- master-1
68+
healthcheck:
69+
test:
70+
[
71+
"CMD-SHELL",
72+
"ps $(cat /var/run/salt-master.pid) > /dev//null 2>&1 && test -S /var/run/salt/master/workers.ipc",
73+
]
74+
interval: 5s
75+
timeout: 10s
76+
retries: 120
5877
minion-1:
5978
depends_on:
60-
- kibana
79+
kibana:
80+
condition: service_healthy
81+
master-1:
82+
condition: service_healthy
6183
container_name: minion-1
6284
build:
6385
context: ../../
@@ -69,7 +91,10 @@ services:
6991
- minion-1
7092
minion-2:
7193
depends_on:
72-
- kibana
94+
kibana:
95+
condition: service_healthy
96+
master-1:
97+
condition: service_healthy
7398
container_name: minion-2
7499
build:
75100
context: ../../
@@ -81,7 +106,8 @@ services:
81106
- minion-2
82107
master-2:
83108
depends_on:
84-
- kibana
109+
kibana:
110+
condition: service_healthy
85111
container_name: master-2
86112
build:
87113
context: ../../
@@ -91,9 +117,21 @@ services:
91117
es-network:
92118
aliases:
93119
- master-2
120+
healthcheck:
121+
test:
122+
[
123+
"CMD-SHELL",
124+
"ps $(cat /var/run/salt-master.pid) > /dev//null 2>&1 && test -S /var/run/salt/master/workers.ipc",
125+
]
126+
interval: 5s
127+
timeout: 10s
128+
retries: 120
94129
minion-3:
95130
depends_on:
96-
- kibana
131+
kibana:
132+
condition: service_healthy
133+
master-2:
134+
condition: service_healthy
97135
container_name: minion-3
98136
build:
99137
context: ../../
@@ -105,7 +143,10 @@ services:
105143
- minion-3
106144
minion-4:
107145
depends_on:
108-
- kibana
146+
kibana:
147+
condition: service_healthy
148+
master-2:
149+
condition: service_healthy
109150
container_name: minion-4
110151
build:
111152
context: ../../

docker/elastic/loop-jobs.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
sleep 20
3+
while true; do
4+
SLEEP=$(shuf -i 3-10 -n 1)
5+
sleep $SLEEP
6+
/usr/bin/salt \* test.fib 3
7+
SLEEP=$(shuf -i 3-10 -n 1)
8+
sleep $SLEEP
9+
/usr/bin/salt \* test.ping
10+
done

0 commit comments

Comments
 (0)