Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c68b404
When loading plugin configs, catch `KeyError` on unavailable plugins …
s0undt3ch Jul 18, 2023
afffb16
Fix regression which prevented pipelines without processors
s0undt3ch Jul 5, 2023
24076ca
Pass the event tag and stamp explicitly when calling `saf.utils.event…
s0undt3ch Jul 5, 2023
88fa320
Add the `id` attribute to `BeaconCollectedEvent`, which is minion ID.
s0undt3ch Jul 5, 2023
50b03e1
Add an elastic search forwarder (inc. example usage)
s0undt3ch Jul 5, 2023
230a994
Initial check in for job aggregations
Jul 3, 2023
925a440
Add grains collector and state aggregate processor
Jul 6, 2023
248fa1c
Renamed `src/saf/process/state_aggregate.py` -> `src/saf/process/job_…
s0undt3ch Jul 5, 2023
1a5f5ab
Make some additional improvements to the JobAggregate Processor
Jul 6, 2023
faccc76
Split master and minion pipelines
s0undt3ch Jul 5, 2023
6e113e7
Add a scheduled `test.ping` job to the minions
s0undt3ch Jul 5, 2023
e204602
Add default debug logging for the salt containers
s0undt3ch Jul 5, 2023
c9ed1a5
Add debug logging to the job_aggregate processor
s0undt3ch Jul 5, 2023
2a7deb5
Add a `jobs_to_es` processor
s0undt3ch Jul 6, 2023
9f792bc
Add custom script to loop to jobs we want to trigger from master
s0undt3ch Jul 6, 2023
88def5b
Some elastic example salt config file changes
s0undt3ch Jul 6, 2023
31a5f21
Allow providing the elastic search index in the configuration
s0undt3ch Jul 6, 2023
d522bea
The `jobs` should be optionally set.
s0undt3ch Jul 6, 2023
20b30af
Fix paths to `supervisord.conf`
s0undt3ch Jul 7, 2023
368d93a
`fun_args` also needs to be JSON dumped so that Elastic Search doesn'…
s0undt3ch Jul 7, 2023
356c24d
Fix elastic search docker example after the include grains update
s0undt3ch Jul 7, 2023
db0356b
Add a state run index to the elastic search docker example
s0undt3ch Jul 7, 2023
93a8bae
Setup the cache sooner
s0undt3ch Jul 10, 2023
e4c773a
Catch `JSONDecodeError` errors
s0undt3ch Jul 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RADIO
1 change: 1 addition & 0 deletions changelog/68.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix regression which prevented pipelines without processors
5 changes: 5 additions & 0 deletions changelog/68.improvement.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Several improvements to the project

* When loading plugin configs, catch `KeyError` on unavailable plugins and list all available.
* Pass the event tag and stamp explicitly when calling `saf.utils.eventbus._construct_event()`
* Add the `id` attribute to `BeaconCollectedEvent`, which is minion ID.
1 change: 1 addition & 0 deletions changelog/69.improvement.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add an Elastic Search forwarder(inc. example usage)
30 changes: 30 additions & 0 deletions docker/elastic/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Password for the 'elastic' user (at least 6 characters)
ELASTIC_PASSWORD=elastic

# Password for the 'kibana_system' user (at least 6 characters)
KIBANA_PASSWORD=kibana

# Version of Elastic products
#STACK_VERSION=8.8.2
STACK_VERSION=7.17.11

# Set the cluster name
CLUSTER_NAME=docker-cluster

# Set to 'basic' or 'trial' to automatically start the 30-day trial
LICENSE=basic
#LICENSE=trial

# Port to expose Elasticsearch HTTP API to the host
ES_PORT=9200
#ES_PORT=127.0.0.1:9200

# Port to expose Kibana to the host
KIBANA_PORT=5601
#KIBANA_PORT=80

# Increase or decrease based on the available host memory (in bytes)
MEM_LIMIT=2073741824

# Project namespace (defaults to the current folder name if not set)
#COMPOSE_PROJECT_NAME=myproject
39 changes: 39 additions & 0 deletions docker/elastic/centosstream8.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM ghcr.io/saltstack/salt-ci-containers/centos-stream:8 as base

ENV LANG=C.UTF-8
ENV LANGUAGE=C.UTF-8
RUN ln -sf /etc/localtime /usr/share/zoneinfo/America/Denver

RUN dnf update -y \
&& dnf upgrade -y \
&& dnf install -y sed vim tmux sudo tree net-tools bind-utils lsof nmap which binutils iputils epel-release procps \
&& dnf install -y --allowerasing curl \
&& dnf install -y multitail supervisor

RUN mkdir -p /etc/supervisor/conf.d/
ADD docker/elastic/conf/supervisord.conf /etc/supervisord.conf

RUN rpm --import https://repo.saltproject.io/salt/py3/redhat/9/x86_64/SALT-PROJECT-GPG-PUBKEY-2023.pub \
&& curl -fsSL https://repo.saltproject.io/salt/py3/redhat/9/x86_64/3006.repo | tee /etc/yum.repos.d/salt.repo \
&& dnf install -y salt

COPY ../../dist/salt*.whl /src/
RUN ls -lah /src \
&& /opt/saltstack/salt/salt-pip install /src/salt_analytics_framework*.whl \
&& rm -f /src/*.whl

COPY ../../examples/dist/salt*.whl /src/
RUN ls -lah /src \
&& /opt/saltstack/salt/salt-pip install --find-links /src/ salt-analytics.examples[elasticsearch] \
&& rm -f /src/*.whl


FROM base as minion-2

RUN dnf install -y salt-minion
ADD docker/elastic/conf/supervisord.minion.conf /etc/supervisor/conf.d/minion.conf
ADD docker/elastic/conf/beacons.conf /etc/salt/minion.d/beacons.conf
ADD docker/elastic/conf/analytics.minion.conf /etc/salt/minion.d/salt-analytics.conf
ADD docker/elastic/conf/minion-2.conf /etc/salt/minion.d/minion-2.conf

CMD ["/usr/bin/supervisord","-c","/etc/supervisord.conf"]
52 changes: 52 additions & 0 deletions docker/elastic/centosstream9.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
FROM ghcr.io/saltstack/salt-ci-containers/centos-stream:9 as base

ENV LANG=C.UTF-8
ENV LANGUAGE=C.UTF-8
RUN ln -sf /etc/localtime /usr/share/zoneinfo/America/Denver

RUN dnf update -y \
&& dnf upgrade -y \
&& dnf install -y sed vim tmux sudo tree net-tools bind-utils lsof nmap which binutils iputils epel-release procps \
&& dnf install -y --allowerasing curl \
&& dnf install -y multitail supervisor

RUN mkdir -p /etc/supervisor/conf.d/
ADD docker/elastic/conf/supervisord.conf /etc/supervisord.conf

RUN rpm --import https://repo.saltproject.io/salt/py3/redhat/9/x86_64/SALT-PROJECT-GPG-PUBKEY-2023.pub \
&& curl -fsSL https://repo.saltproject.io/salt/py3/redhat/9/x86_64/3006.repo | tee /etc/yum.repos.d/salt.repo \
&& dnf install -y salt

COPY ../../dist/salt*.whl /src/
RUN ls -lah /src \
&& /opt/saltstack/salt/salt-pip install /src/salt_analytics_framework*.whl \
&& rm -f /src/*.whl

COPY ../../examples/dist/salt*.whl /src/
RUN ls -lah /src \
&& /opt/saltstack/salt/salt-pip install --find-links /src/ salt-analytics.examples[elasticsearch] \
&& rm -f /src/*.whl


FROM base as master-1

RUN dnf install -y salt-master
ADD docker/elastic/conf/supervisord.master.conf /etc/supervisor/conf.d/master.conf
ADD docker/elastic/conf/supervisord.loop-jobs.conf /etc/supervisor/conf.d/loop-jobs.conf
ADD docker/elastic/loop-jobs.sh /usr/bin/loop-jobs.sh
ADD docker/elastic/conf/analytics.master.conf /etc/salt/master.d/salt-analytics.conf
ADD docker/elastic/conf/master-1.conf /etc/salt/master.d/master-1.conf
ADD docker/elastic/state-tree/*.sls /srv/salt/

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


FROM base as minion-1

RUN dnf install -y salt-minion
ADD docker/elastic/conf/supervisord.minion.conf /etc/supervisor/conf.d/minion.conf
ADD docker/elastic/conf/beacons.conf /etc/salt/minion.d/beacons.conf
ADD docker/elastic/conf/analytics.minion.conf /etc/salt/minion.d/salt-analytics.conf
ADD docker/elastic/conf/minion-1.conf /etc/salt/minion.d/minion-1.conf

CMD ["/usr/bin/supervisord","-c","/etc/supervisord.conf"]
57 changes: 57 additions & 0 deletions docker/elastic/conf/analytics.master.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
engines:
- analytics

analytics:

collectors:
jobs-collector:
plugin: event-bus
tags:
- "salt/job/*"

grains-collector:
plugin: grains
interval: 30
grains:
- "os"
- "id"
- "role"
- "datacenter"

processors:
job-aggregate:
plugin: job-aggregate
state-job-aggregate:
plugin: job-aggregate
jobs:
- "state.*"
cast-to-es:
plugin: jobs_to_es
state-cast-to-es:
plugin: state_jobs_to_es

forwarders:
elasticsearch-forwarder:
plugin: elasticsearch
hosts:
- http://node01:9200

pipelines:

jobs-pipeline:
collect:
- grains-collector
- jobs-collector
process:
- job-aggregate
- cast-to-es
forward: elasticsearch-forwarder

state-jobs-pipeline:
collect:
- grains-collector
- jobs-collector
process:
- state-job-aggregate
- state-cast-to-es
forward: elasticsearch-forwarder
31 changes: 31 additions & 0 deletions docker/elastic/conf/analytics.minion.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
engines:
- analytics

analytics:

collectors:
beacons-collector:
plugin: beacons
beacons:
- "*"

processors:
cast-to-es:
plugin: beacons_to_es

forwarders:
elasticsearch-forwarder:
plugin: elasticsearch
hosts:
- http://node01:9200
use_ssl: false
verify_ssl: false

pipelines:
elastic-pipeline:
collect:
- beacons-collector
process:
- cast-to-es
forward:
- elasticsearch-forwarder
17 changes: 17 additions & 0 deletions docker/elastic/conf/beacons.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
beacons:
# diskusage:
# - '^\/(?!home).*$': 1%
# - '^[a-zA-Z]:\\$': 1%
# - interval: 5
memusage:
- percent: 1%
- interval: 5
# salt_monitor:
# - salt_fun:
# - test.ping
# - interval: 5
## status:
## - interval: 5
## swapusage:
## - percent: 1%
## - interval: 5
5 changes: 5 additions & 0 deletions docker/elastic/conf/master-1.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
id: master-1
open_mode: true
log_level_logfile: debug
grains:
datacenter: dt-a
5 changes: 5 additions & 0 deletions docker/elastic/conf/master-2.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
id: master-2
open_mode: true
log_level_logfile: debug
grains:
datacenter: dt-b
6 changes: 6 additions & 0 deletions docker/elastic/conf/minion-1.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id: minion-1
master: master-1
log_level_logfile: debug
grains:
role: db
datacenter: dt-a
6 changes: 6 additions & 0 deletions docker/elastic/conf/minion-2.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id: minion-2
master: master-1
log_level_logfile: debug
grains:
role: web
datacenter: dt-a
6 changes: 6 additions & 0 deletions docker/elastic/conf/minion-3.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id: minion-3
master: master-2
log_level_logfile: debug
grains:
role: db
datacenter: dt-b
6 changes: 6 additions & 0 deletions docker/elastic/conf/minion-4.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id: minion-4
master: master-2
log_level_logfile: debug
grains:
role: web
datacenter: dt-b
29 changes: 29 additions & 0 deletions docker/elastic/conf/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[supervisord]
user=root
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (logging level;default info; others: debug,warn)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=true ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)

[unix_http_server]
file=/var/tmp/supervisor.sock
username=setup
password=setup

[supervisorctl]
serverurl=unix:///var/tmp/supervisor.sock ; use a unix:// URL for a unix socket
username=setup
password=setup

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[include]
files = /etc/supervisor/conf.d/*.conf
2 changes: 2 additions & 0 deletions docker/elastic/conf/supervisord.loop-jobs.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[program:loop-jobs]
command=/bin/sh /usr/bin/loop-jobs.sh
2 changes: 2 additions & 0 deletions docker/elastic/conf/supervisord.master.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[program:salt-master]
command=/opt/saltstack/salt/salt-master -l debug
2 changes: 2 additions & 0 deletions docker/elastic/conf/supervisord.minion.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[program:salt-minion]
command=/opt/saltstack/salt/salt-minion -l debug
39 changes: 39 additions & 0 deletions docker/elastic/debian10.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM ghcr.io/saltstack/salt-ci-containers/debian:10 as base

ENV LANG=C.UTF-8
ENV LANGUAGE=C.UTF-8
RUN ln -sf /etc/localtime /usr/share/zoneinfo/America/Denver

RUN apt update \
&& apt upgrade -y \
&& apt install -y curl sed vim tmux sudo tree net-tools bind9utils lsof nmap binutils multitail supervisor iputils-ping procps

RUN mkdir -p /etc/supervisor/conf.d/
ADD docker/elastic/conf/supervisord.conf /etc/supervisor/supervisord.conf

RUN mkdir /etc/apt/keyrings \
&& curl -fsSL -o /etc/apt/keyrings/salt-archive-keyring-2023.gpg https://repo.saltproject.io/salt/py3/debian/11/amd64/SALT-PROJECT-GPG-PUBKEY-2023.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/salt-archive-keyring-2023.gpg arch=amd64] https://repo.saltproject.io/salt/py3/debian/11/amd64/3006 bullseye main" | tee /etc/apt/sources.list.d/salt.list \
&& apt update \
&& apt install -y salt-common

COPY ../../dist/salt*.whl /src/
RUN ls -lah /src \
&& /opt/saltstack/salt/salt-pip install /src/salt_analytics_framework*.whl \
&& rm -f /src/*.whl

COPY ../../examples/dist/salt*.whl /src/
RUN ls -lah /src \
&& /opt/saltstack/salt/salt-pip install --find-links /src/ salt-analytics.examples[elasticsearch] \
&& rm -f /src/*.whl


FROM base as minion-4

RUN apt install -y salt-minion
ADD docker/elastic/conf/supervisord.minion.conf /etc/supervisor/conf.d/minion.conf
ADD docker/elastic/conf/beacons.conf /etc/salt/minion.d/beacons.conf
ADD docker/elastic/conf/analytics.minion.conf /etc/salt/minion.d/salt-analytics.conf
ADD docker/elastic/conf/minion-4.conf /etc/salt/minion.d/minion-4.conf

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