Skip to content

Commit

Permalink
New features
Browse files Browse the repository at this point in the history
- manage environment timeout
- manage graphite exporter
  • Loading branch information
tuxmea committed Dec 12, 2023
1 parent cde5b18 commit ff84c84
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ The following environment variables are supported:
| **PUPPETDB_SERVER_URLS** | The `server_urls` to set in `/etc/puppetlabs/puppet/puppetdb.conf`<br><br>`https://puppetdb:8081` |
| **PUPPETDB_HOSTNAME** | The DNS name of the puppetdb <br><br> Defaults to `puppetdb` |
| **PUPPETDB_SSL_PORT** | The TLS port of the puppetdb <br><br> Defaults to `8081` |
| **PUPPETSERVER_GRAPHITE_EXPORTER_ENABLED** | Activate the graphite exporter. Also needs **PUPPETSERVER_GRAPHITE_HOST** and **PUPPETSERVER_GRAPHITE_PORT**<br><br> Defaults to `false` |
| **PUPPETSERVER_ENVIRONMENT_TIMEOUT** | Configure the environment timeout<br><br> Defaults to `unlimited` |

## Initialization Scripts

Expand Down
5 changes: 4 additions & 1 deletion puppetserver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ ENV PUPPETSERVER_JAVA_ARGS="-Xms1024m -Xmx1024m" \
PUPPETDB_SERVER_URLS=https://puppetdb:8081 \
PUPPET_STORECONFIGS_BACKEND="puppetdb" \
PUPPET_STORECONFIGS=true \
PUPPET_REPORTS="puppetdb"
PUPPET_REPORTS="puppetdb" \
PUPPETSERVER_GRAPHITE_EXPORTER_ENABLED=false \
PUPPETSERVER_ENVIRONMENT_TIMEOUT=unlimited

# NOTE: this is just documentation on defaults
EXPOSE 8140
Expand All @@ -51,6 +53,7 @@ COPY docker-entrypoint.sh \
healthcheck.sh \
/
COPY docker-entrypoint.d /docker-entrypoint.d
COPY metrics.conf.tmpl /metrics.conf.tmpl
# k8s uses livenessProbe, startupProbe, readinessProbe and ignores HEALTHCHECK
HEALTHCHECK --interval=20s --timeout=15s --retries=12 --start-period=3m CMD ["/healthcheck.sh"]

Expand Down
10 changes: 10 additions & 0 deletions puppetserver/docker-entrypoint.d/83-environment-cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
#
if [ -n "$PUPPETSERVER_ENVIRONMENT_TIMEOUT" ]; then
echo "Settings environment_timeout to ${PUPPETSERVER_ENVIRONMENT_TIMEOUT}"
puppet config set --section master environment_timeout $PUPPETSERVER_ENVIRONMENT_TIMEOUT
else
echo "Removing environment_timeout"
puppet config delete --section master environment_timeout
fi

12 changes: 12 additions & 0 deletions puppetserver/docker-entrypoint.d/84-enable_graphite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

if [[ "$PUPPETSERVER_GRAPHITE_EXPORTER_ENABLED" == "true" ]]; then
if [ -n "$PUPPETSERVER_GRAPHITE_HOST" and -n "$PUPPETSERVER_GRAPHITE_PORT" ]; then
echo "Enabling graphite exporter"
sed -e "s/GRAPHITE_HOST/$PUPPETSERVER_GRAPHITE_HOST/" -e "s/GRAPHITE_PORT/$PUPPETSERVER_GRAPHITE_PORT/" /metrics.conf.tmpl > /etc/puppetlabs/puppetserver/conf.d/metrics.conf
else
echo "ERROR: no PUPPETSERVER_GRAPHITE_HOST or PUPPETSERVER_GRAPHITE_PORT set."
exit 99
fi
fi

53 changes: 53 additions & 0 deletions puppetserver/metrics.conf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# settings related to metrics
metrics: {
# a server id that will be used as part of the namespace for metrics produced
# by this server
server-id: localhost
registries: {
puppetserver: {
# specify metrics to allow in addition to those in the default list
#metrics-allowed: ["compiler.compile.production"]

reporters: {
# enable or disable JMX metrics reporter
jmx: {
enabled: true
}
# enable or disable Graphite metrics reporter
graphite: {
enabled: true
}
}

}
}

# this section is used to configure settings for reporters that will send
# the metrics to various destinations for external viewing
reporters: {
graphite: {
# graphite host
host: "GRAPHITE_HOST"
# graphite metrics port
port: GRAPHITE_PORT
# how often to send metrics to graphite
update-interval-seconds: 5
}
}
metrics-webservice: {
jolokia: {
# Enable or disable the Jolokia-based metrics/v2 endpoint.
# Default is true.
# enabled: false

# Configure any of the settings listed at:
# https://jolokia.org/reference/html/agents.html#war-agent-installation
servlet-init-params: {
# Specify a custom security policy:
# https://jolokia.org/reference/html/security.html
# policyLocation: "file:///etc/puppetlabs/puppetserver/jolokia-access.xml"
}
}
}

}

0 comments on commit ff84c84

Please sign in to comment.