Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • infrastruktur/ansible-warpzone
  • specki/ansible-warpzone
2 results
Show changes
Showing
with 661 additions and 136 deletions
--- ---
- name: "create folder struct for {{ servicename }}" - include: ../functions/get_secret.yml
file: with_items:
- { path: "{{ basedir }}/influxdb_password", length: 12 }
- { path: "{{ basedir }}/influxdb_token", length: 32 }
- name: "create folder struct for {{ basedir }}"
file:
path: "{{ item }}" path: "{{ item }}"
state: "directory" state: "directory"
with_items: with_items:
- "{{ basedir }}" - "{{ basedir }}"
- name: deploy {{ servicename }} config - name: "copy config files for {{ basedir }}"
template: template:
dest: "{{ basedir }}/{{ item }}"
src: "{{ item }}" src: "{{ item }}"
dest: "{{ basedir }}/{{ item }}"
with_items: with_items:
- docker-compose.yml - docker-compose.yml
register: config - telegraf.conf
register: config_files
# Start containers
- name: "stop {{ servicename }} docker" - name: "stop {{ servicename }} docker"
docker_compose: docker_compose:
project_src: "{{ basedir }}" project_src: "{{ basedir }}"
state: absent state: absent
when: config.changed when: config_files.changed
- name: "start {{ servicename }} docker" - name: "start {{ servicename }} docker"
docker_compose: docker_compose:
project_src: "{{ basedir }}" project_src: "{{ basedir }}"
state: present state: present
version: "3"
services:
app:
image: sfudeus/homematic_exporter:2023-05-21
restart: always
command: "--ccu_host {{ homematic.ccu2_host }} --ccu_port 2001 --port {{ homematic_metrics_port }}"
ports:
- "{{ int_ip4 }}:{{ homematic_metrics_port }}:{{ homematic_metrics_port }}"
networks:
- default
influxdb:
image: influxdb:2.6.1
restart: always
ports:
- "{{ int_ip4 }}:{{ influxdb_port }}:8086"
volumes:
- "{{ basedir }}/influxdb:/var/lib/influxdb2"
environment:
DOCKER_INFLUXDB_INIT_MODE: setup
DOCKER_INFLUXDB_INIT_USERNAME: homematic
DOCKER_INFLUXDB_INIT_PASSWORD: {{ influxdb_password }}
DOCKER_INFLUXDB_INIT_ORG: homematic
DOCKER_INFLUXDB_INIT_BUCKET: homematic
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: {{ influxdb_token }}
networks:
- default
telegraf:
image: telegraf:1.25.3
restart: always
depends_on:
- app
- influxdb
volumes:
- "{{ basedir }}/telegraf.conf:/etc/telegraf/telegraf.conf:ro"
# Telegraf Configuration
#
# Telegraf is entirely plugin driven. All metrics are gathered from the
# declared inputs, and sent to the declared outputs.
#
# Plugins must be declared in here to be active.
# To deactivate a plugin, comment out the name and any variables.
#
# Use 'telegraf -config telegraf.conf -test' to see what metrics a config
# file would generate.
#
# Environment variables can be used anywhere in this config file, simply surround
# them with ${}. For strings the variable must be within quotes (ie, "${STR_VAR}"),
# for numbers and booleans they should be plain (ie, ${INT_VAR}, ${BOOL_VAR})
# Global tags can be specified here in key="value" format.
[global_tags]
# dc = "us-east-1" # will tag all metrics with dc=us-east-1
# rack = "1a"
## Environment variables can be used as tags, and throughout the config file
# user = "$USER"
# Configuration for telegraf agent
[agent]
## Default data collection interval for all inputs
interval = "5s"
## Rounds collection interval to 'interval'
## ie, if interval="10s" then always collect on :00, :10, :20, etc.
round_interval = true
## Telegraf will send metrics to outputs in batches of at most
## metric_batch_size metrics.
## This controls the size of writes that Telegraf sends to output plugins.
metric_batch_size = 100
## Maximum number of unwritten metrics per output. Increasing this value
## allows for longer periods of output downtime without dropping metrics at the
## cost of higher maximum memory usage.
metric_buffer_limit = 10000
## Collection jitter is used to jitter the collection by a random amount.
## Each plugin will sleep for a random time within jitter before collecting.
## This can be used to avoid many plugins querying things like sysfs at the
## same time, which can have a measurable effect on the system.
collection_jitter = "0s"
## Default flushing interval for all outputs. Maximum flush_interval will be
## flush_interval + flush_jitter
flush_interval = "10s"
## Jitter the flush interval by a random amount. This is primarily to avoid
## large write spikes for users running a large number of telegraf instances.
## ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s
flush_jitter = "0s"
## By default or when set to "0s", precision will be set to the same
## timestamp order as the collection interval, with the maximum being 1s.
## ie, when interval = "10s", precision will be "1s"
## when interval = "250ms", precision will be "1ms"
## Precision will NOT be used for service inputs. It is up to each individual
## service input to set the timestamp at the appropriate precision.
## Valid time units are "ns", "us" (or "µs"), "ms", "s".
precision = ""
## Log at debug level.
# debug = false
## Log only error level messages.
# quiet = false
## Log target controls the destination for logs and can be one of "file",
## "stderr" or, on Windows, "eventlog". When set to "file", the output file
## is determined by the "logfile" setting.
# logtarget = "file"
## Name of the file to be logged to when using the "file" logtarget. If set to
## the empty string then logs are written to stderr.
# logfile = ""
## The logfile will be rotated after the time interval specified. When set
## to 0 no time based rotation is performed. Logs are rotated only when
## written to, if there is no log activity rotation may be delayed.
# logfile_rotation_interval = "0d"
## The logfile will be rotated when it becomes larger than the specified
## size. When set to 0 no size based rotation is performed.
# logfile_rotation_max_size = "0MB"
## Maximum number of rotated archives to keep, any older logs are deleted.
## If set to -1, no archives are removed.
# logfile_rotation_max_archives = 5
## Pick a timezone to use when logging or type 'local' for local time.
## Example: America/Chicago
# log_with_timezone = ""
## Override default hostname, if empty use os.Hostname()
hostname = ""
## If set to true, do no set the "host" tag in the telegraf agent.
omit_hostname = false
###############################################################################
# OUTPUT PLUGINS #
###############################################################################
# Configuration for sending metrics to InfluxDB 2.0
[[outputs.influxdb_v2]]
## The URLs of the InfluxDB cluster nodes.
##
## Multiple URLs can be specified for a single cluster, only ONE of the
## urls will be written to each interval.
## ex: urls = ["https://us-west-2-1.aws.cloud2.influxdata.com"]
urls = ["http://influxdb:8086"]
## Token for authentication.
token = "{{ influxdb_token }}"
## Organization is the name of the organization you wish to write to.
organization = "homematic"
## Destination bucket to write into.
bucket = "homematic"
## The value of this tag will be used to determine the bucket. If this
## tag is not set the 'bucket' option is used as the default.
# bucket_tag = ""
## If true, the bucket tag will not be added to the metric.
# exclude_bucket_tag = false
## Timeout for HTTP messages.
# timeout = "5s"
## Additional HTTP headers
# http_headers = {"X-Special-Header" = "Special-Value"}
## HTTP Proxy override, if unset values the standard proxy environment
## variables are consulted to determine which proxy, if any, should be used.
# http_proxy = "http://corporate.proxy:3128"
## HTTP User-Agent
# user_agent = "telegraf"
## Content-Encoding for write request body, can be set to "gzip" to
## compress body or "identity" to apply no encoding.
# content_encoding = "gzip"
## Enable or disable uint support for writing uints influxdb 2.0.
# influx_uint_support = false
## Optional TLS Config for use on HTTP connections.
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Use TLS but skip chain & host verification
# insecure_skip_verify = false
###############################################################################
# INPUT PLUGINS #
###############################################################################
# Read metrics from one or many prometheus clients
[[inputs.prometheus]]
## An array of urls to scrape metrics from.
urls = ["http://app:{{ homematic_metrics_port }}/metrics"]
## Metric version controls the mapping from Prometheus metrics into Telegraf metrics.
## See "Metric Format Configuration" in plugins/inputs/prometheus/README.md for details.
## Valid options: 1, 2
# metric_version = 1
## Url tag name (tag containing scrapped url. optional, default is "url")
# url_tag = "url"
## Whether the timestamp of the scraped metrics will be ignored.
## If set to true, the gather time will be used.
# ignore_timestamp = false
ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBCxsaY88ZP/bk15JNs2zzVbpG4S4uLYlzfMVlqSZQJVZ0t65vJMKp2yepp6BdOb2rAuXnhPX5zrFEP/A8idR0DFLR5kp6pvdKOeWToND3V763WXJvOutyoKIXPGSuEJF+Q== jabertwo ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBCxsaY88ZP/bk15JNs2zzVbpG4S4uLYlzfMVlqSZQJVZ0t65vJMKp2yepp6BdOb2rAuXnhPX5zrFEP/A8idR0DFLR5kp6pvdKOeWToND3V763WXJvOutyoKIXPGSuEJF+Q== jabertwo-home
ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBGR9N60F+0annoCi9cM+94jSxsw8KPgMf7GqKoFmxwpcDf6fd7Vc5sRQg0avnEg009D2nxihED0y2eTP2Tzn6eQQ/2LRXRfMCa+hRK99YYPUjpszH/y2bC2r/08CvcdeVA== jabertwo ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBGR9N60F+0annoCi9cM+94jSxsw8KPgMf7GqKoFmxwpcDf6fd7Vc5sRQg0avnEg009D2nxihED0y2eTP2Tzn6eQQ/2LRXRfMCa+hRK99YYPUjpszH/y2bC2r/08CvcdeVA== jabertwo-mob
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
- { role: all/common, tags: common } - { role: all/common, tags: common }
- { role: all/sysctl, tags: sysctl } - { role: all/sysctl, tags: sysctl }
##################################################
# Test Server
##################################################
################################################## ##################################################
# Produktive Server # Produktive Server
...@@ -26,6 +29,7 @@ ...@@ -26,6 +29,7 @@
remote_user: root remote_user: root
roles: roles:
- { role: common/proxmox, tags: proxmox } - { role: common/proxmox, tags: proxmox }
- { role: common/prometheus-node, tags: prometheus-node }
- { role: common/cronapt, tags: cronapt } - { role: common/cronapt, tags: cronapt }
...@@ -33,6 +37,7 @@ ...@@ -33,6 +37,7 @@
remote_user: root remote_user: root
roles: roles:
- { role: common/cronapt, tags: cronapt } - { role: common/cronapt, tags: cronapt }
- { role: common/prometheus-node, tags: prometheus-node }
- { role: common/wireguard, tags: wireguard } - { role: common/wireguard, tags: wireguard }
...@@ -87,7 +92,15 @@ ...@@ -87,7 +92,15 @@
servicename: homeassistant, servicename: homeassistant,
basedir: /srv/homeassistant, basedir: /srv/homeassistant,
domain: "ha.warpzone.lan", domain: "ha.warpzone.lan",
influxdb_port: 38086 homematic_callback_port: 8060,
influxdb_port: 38086
}
- {
role: intern/docker_homematic, tags: homematic,
servicename: homematic,
basedir: /srv/homematic,
homematic_metrics_port: 8010,
influxdb_port: 48086
} }
- { - {
role: intern/docker_mqtt, tags: mqtt, role: intern/docker_mqtt, tags: mqtt,
...@@ -148,7 +161,8 @@ ...@@ -148,7 +161,8 @@
} }
- { - {
role: common/docker_ldap, tags: ldap, role: common/docker_ldap, tags: ldap,
servicename: "ldap", servicename: ldap,
basedir: /srv/ldap,
domain: "ldap.warpzone.ms" domain: "ldap.warpzone.ms"
} }
- { - {
...@@ -159,11 +173,6 @@ ...@@ -159,11 +173,6 @@
domain_default: "www.warpzone.ms", domain_default: "www.warpzone.ms",
matrix_federation: true matrix_federation: true
} }
- {
role: webserver/docker_autodiscover, tags: autodiscover,
servicename: autodiscover,
basedir: /srv/autodiscover
}
- { - {
role: webserver/docker_coturn, tags: coturn, role: webserver/docker_coturn, tags: coturn,
servicename: "coturn", servicename: "coturn",
...@@ -172,7 +181,9 @@ ...@@ -172,7 +181,9 @@
- { - {
role: webserver/docker_dokuwiki, tags: dokuwiki, role: webserver/docker_dokuwiki, tags: dokuwiki,
servicename: "dokuwiki", servicename: "dokuwiki",
domain: "wiki.warpzone.ms" domain: "wiki.warpzone.ms",
basedir: /srv/dokuwiki,
healthchecks_url: "https://hc-ping.com/038adcfe-05bf-45b4-919b-88b69aab8844"
} }
- { - {
role: webserver/docker_gitlab, tags: gitlab, role: webserver/docker_gitlab, tags: gitlab,
...@@ -186,7 +197,7 @@ ...@@ -186,7 +197,7 @@
basedir: /srv/icinga, basedir: /srv/icinga,
domain: icinga.warpzone.ms, domain: icinga.warpzone.ms,
api_port: 5665, api_port: 5665,
mysql_port: 33306, mysql_port: 33306
} }
- { - {
role: webserver/docker_hackmd, tags: hackmd, role: webserver/docker_hackmd, tags: hackmd,
...@@ -202,10 +213,15 @@ ...@@ -202,10 +213,15 @@
} }
- { - {
role: webserver/docker_mail, tags: mail, role: webserver/docker_mail, tags: mail,
servicename: mail,
basedir: /srv/mail, basedir: /srv/mail,
domain: "warpzone.ms",
mailserver: "mailserver.warpzone.ms",
listserver: "listserver.warpzone.ms"
} }
- { - {
role: webserver/docker_matterbridge, tags: matterbridge, role: webserver/docker_matterbridge, tags: matterbridge,
servicename: matterbridge,
basedir: /srv/matterbridge, basedir: /srv/matterbridge,
domain: "www.warpzone.ms" domain: "www.warpzone.ms"
} }
......
version: '2.1'
services:
{% for domain in mail_domains %}
{{ domain }}:
image: monogramm/autodiscover-email-settings:1.4.0
restart: always
environment:
- DOMAIN={{ mail_domains[domain].maildomain }}
- IMAP_HOST={{ mail_domains[domain].mxserver }}
- IMAP_PORT=993
- IMAP_SOCKET=SSL
- POP_HOST={{ mail_domains[domain].mxserver }}
- POP_PORT=995
- POP_SOCKET=SSL
- SMTP_HOST={{ mail_domains[domain].mxserver }}
- SMTP_PORT=587
- SMTP_SOCKET=STARTTLS
labels:
- traefik.enable=true
- traefik.http.routers.{{ servicename }}-{{ domain }}.rule=Host(`autodiscover.{{ mail_domains[domain].maildomain }}`) || Host(`autoconfig.{{ mail_domains[domain].maildomain }}`)
- traefik.http.routers.{{ servicename }}-{{ domain }}.entrypoints=websecure
- traefik.http.services.{{ servicename }}-{{ domain }}.loadbalancer.server.port=8000
networks:
- default
- web
{% endfor %}
networks:
web:
external: true
...@@ -9,23 +9,19 @@ ...@@ -9,23 +9,19 @@
path: "{{item}}" path: "{{item}}"
state: "directory" state: "directory"
with_items: with_items:
- /srv/dokuwiki/ - "{{ basedir }}"
- /srv/dokuwiki/data - "{{ basedir }}/data"
- /srv/dokuwiki/pdftemplate - "{{ basedir }}/pdftemplate"
- name: Docker Compose Konfig-Datei erstellen - name: Docker Compose Konfig-Datei erstellen
template: template:
src: "{{item}}" src: "{{item}}"
dest: "/srv/dokuwiki/{{item}}" dest: "{{ basedir }}/{{item}}"
with_items: with_items:
- docker-compose.yml - docker-compose.yml
- Dockerfile - Dockerfile
- sendmail_plenum.py - sendmail_plenum.py
register: config
- name: start dokuwiki docker
docker_compose:
project_src: /srv/dokuwiki/
state: present
- name: Cronjob für Mailversand Plenumsmail - name: Cronjob für Mailversand Plenumsmail
cron: cron:
...@@ -33,5 +29,16 @@ ...@@ -33,5 +29,16 @@
weekday: "0" weekday: "0"
hour: "20" hour: "20"
minute: "0" minute: "0"
job: "/usr/bin/python3 /srv/dokuwiki/sendmail_plenum.py" job: "/usr/bin/python3 {{ basedir }}/sendmail_plenum.py"
disabled: false disabled: false
- name: "stop {{ servicename}} docker"
docker_compose:
project_src: "{{ basedir }}"
state: absent
when: config.changed
- name: "start {{ servicename}} docker"
docker_compose:
project_src: "{{ basedir }}"
state: present
...@@ -3,6 +3,7 @@ version: "3" ...@@ -3,6 +3,7 @@ version: "3"
services: services:
app: app:
# values set in configuration: noreply_email_user - noreply_email_pass - smtp_host - smtp_port
build: . build: .
image: "dokuwiki--{{ ansible_date_time.date }}--{{ ansible_date_time.hour }}-{{ ansible_date_time.minute }}-{{ ansible_date_time.second }}" image: "dokuwiki--{{ ansible_date_time.date }}--{{ ansible_date_time.hour }}-{{ ansible_date_time.minute }}-{{ ansible_date_time.second }}"
restart: always restart: always
...@@ -16,11 +17,8 @@ services: ...@@ -16,11 +17,8 @@ services:
- traefik.http.services.{{ servicename }}.loadbalancer.server.port=80 - traefik.http.services.{{ servicename }}.loadbalancer.server.port=80
networks: networks:
- default - default
- mail
- web - web
networks: networks:
mail:
external: true
web: web:
external: true external: true
...@@ -2,73 +2,76 @@ import smtplib ...@@ -2,73 +2,76 @@ import smtplib
import datetime import datetime
from email.message import EmailMessage from email.message import EmailMessage
from email.utils import formatdate from email.utils import formatdate
import requests
with open("/srv/dokuwiki/data/data/pages/intern/diskussionsthemen.txt") as fp:
raw = fp.read().split('\n') def do_work():
with open("/srv/dokuwiki/data/data/pages/intern/diskussionsthemen.txt") as fp:
# Extract Themen raw = fp.read().split('\n')
firstline = 0
lastline = 0 # Extract Themen
for index, line in enumerate(raw): firstline = 0
# Start marker lastline = 0
if "====== 1." in line: for index, line in enumerate(raw):
firstline = index + 1 # Start marker
continue if "====== 1." in line:
firstline = index + 1
continue
# End marker
if "====== 2." in line:
lastline = index
break
# End marker # Remove empty lines from topics
if "====== 2." in line: topics = []
lastline = index for extracted in raw[firstline:lastline-1]:
break if extracted != '':
topics.append(extracted)
# Remove empty lines from topics
topics = [] # There are no topics - just exit
for extracted in raw[firstline:lastline-1]: if (len(topics) == 0):
if extracted != '': return True
topics.append(extracted)
# calculate date of next tuesday
# There are no topics - just exit d = datetime.date.today()
if (len(topics) == 0): while d.strftime('%a') != 'Tue':
exit() d += datetime.timedelta(1)
# calculate date of next tuesday # mail template
d = datetime.date.today() mail = f"""
while d.strftime('%a') != 'Tue': Liebe Zonies,
d += datetime.timedelta(1)
es gibt wieder Themen die im Plenum besprochen werden sollen. Der nächste
# mail template Reguläre Termin ist am nächsten Dienstag ({str(d)}) um 20:00.
mail = f""" Im Wiki (https://wiki.warpzone.ms/intern:diskussionsthemen#diskussionsthemen_naechstes_plenum_automatische_einladung)
Liebe Zonies, stehen folgende Themen:
es gibt wieder Themen die im Plenum besprochen werden sollen. Der nächste
Reguläre Termin ist am nächsten Dienstag ({str(d)}) um 20:00.
Im Wiki (https://wiki.warpzone.ms/intern:diskussionsthemen#diskussionsthemen_naechstes_plenum_automatische_einladung)
stehen folgende Themen:
{chr(10).join(topics)}
Die Teilnahme ist natürlich auch remote möglich unter
https://jitsi.dorf-post.de/warpzone-plenum möglich.
Viele Grüße und bis Dienstag,
sendmail_plenum.py
"""
msg = EmailMessage()
msg['Subject'] = f'Aktuelle Plenumsthemen für Dienstag ({str(d)} 20:00)'
msg['From'] = '{{noreply_email_user}}'
msg['To'] = 'intern@warpzone.ms'
msg['Date'] = formatdate(localtime=True)
msg.set_content(mail)
server = smtplib.SMTP('{{smtp_host}}', {{smtp_port}})
server.starttls()
server.login("{{noreply_email_user}}", "{{noreply_email_pass}}")
server.send_message(msg)
server.quit()
{chr(10).join(topics)}
Die Teilnahme ist natürlich auch remote möglich unter
https://jitsi.dorf-post.de/warpzone-plenum möglich.
Viele Grüße und bis Dienstag,
sendmail_plenum.py
"""
msg = EmailMessage()
msg['Subject'] = f'Aktuelle Plenumsthemen für Dienstag ({str(d)} 20:00)'
msg['From'] = '{{noreply_email_user}}'
msg['To'] = 'intern@warpzone.ms'
msg['Date'] = formatdate(localtime=True)
msg.set_content(mail)
server = smtplib.SMTP('{{smtp_host}}', {{smtp_port}})
server.starttls()
server.login("{{noreply_email_user}}", "{{noreply_email_pass}}")
server.send_message(msg)
server.quit()
return True
success = False
try:
success = do_work()
finally:
requests.get("{{ healthchecks_url }}" if success else "{{ healthchecks_url }}" + "/fail")
...@@ -116,8 +116,8 @@ gitlab_rails['gitlab_email_enabled'] = true ...@@ -116,8 +116,8 @@ gitlab_rails['gitlab_email_enabled'] = true
# gitlab_rails['gitlab_email_smime_key_file'] = '/etc/gitlab/ssl/gitlab_smime.key' # gitlab_rails['gitlab_email_smime_key_file'] = '/etc/gitlab/ssl/gitlab_smime.key'
# gitlab_rails['gitlab_email_smime_cert_file'] = '/etc/gitlab/ssl/gitlab_smime.crt' # gitlab_rails['gitlab_email_smime_cert_file'] = '/etc/gitlab/ssl/gitlab_smime.crt'
# gitlab_rails['gitlab_email_smime_ca_certs_file'] = '/etc/gitlab/ssl/gitlab_smime_cas.crt' # gitlab_rails['gitlab_email_smime_ca_certs_file'] = '/etc/gitlab/ssl/gitlab_smime_cas.crt'
gitlab_rails['gitlab_email_from'] = '{{ noreply_email_user }}' gitlab_rails['gitlab_email_from'] = 'gitlab@{{ smtp_domain }}'
gitlab_rails['gitlab_email_display_name'] = 'Gitlab Warpzone' gitlab_rails['gitlab_email_display_name'] = 'Warpzone Gitlab'
gitlab_rails['gitlab_email_reply_to'] = '{{ noreply_email_user }}' gitlab_rails['gitlab_email_reply_to'] = '{{ noreply_email_user }}'
### GitLab user privileges ### GitLab user privileges
......
...@@ -5,7 +5,7 @@ services: ...@@ -5,7 +5,7 @@ services:
app: app:
image: gitlab/gitlab-ce:15.10.2-ce.0 image: gitlab/gitlab-ce:15.11.5-ce.0
restart: always restart: always
ports: ports:
- "444:22" - "444:22"
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
- { path: "{{ basedir }}/icinga_api_pass", length: 8 } - { path: "{{ basedir }}/icinga_api_pass", length: 8 }
- { path: "{{ basedir }}/mysql_admin_pass", length: 12 } - { path: "{{ basedir }}/mysql_admin_pass", length: 12 }
- { path: "{{ basedir }}/mysql_user_pass", length: 12 } - { path: "{{ basedir }}/mysql_user_pass", length: 12 }
- { path: "{{ basedir }}/matrix_notification_access_token", length: -1 }
- name: pakete installieren - name: pakete installieren
......
...@@ -13,9 +13,10 @@ RUN apt-get update \ ...@@ -13,9 +13,10 @@ RUN apt-get update \
libnet-dns-perl \ libnet-dns-perl \
libnet-ip-perl \ libnet-ip-perl \
perl \ perl \
python3-requests \
python3 \ python3 \
python3-paho-mqtt \ python3-pip \
python3-requests \
virtualenv \
&& apt-get autoremove -y \ && apt-get autoremove -y \
&& apt-get clean \ && apt-get clean \
&& rm -rf /tmp/* /var/lib/apt/lists/* /var/cache/debconf/*-old && rm -rf /tmp/* /var/lib/apt/lists/* /var/cache/debconf/*-old
...@@ -48,3 +49,17 @@ RUN cd /opt/ \ ...@@ -48,3 +49,17 @@ RUN cd /opt/ \
&& git clone https://github.com/elberfeld/check_metric_value.git \ && git clone https://github.com/elberfeld/check_metric_value.git \
&& cd /opt/check_metric_value/ \ && cd /opt/check_metric_value/ \
&& git checkout b94d3c3e78497a05e3b4520d33421f37e4d77985 && git checkout b94d3c3e78497a05e3b4520d33421f37e4d77985
# icinga2-matrix-bot - commit from 10.06.2018
# create a symlink to emulate virtualenv
# patch matrix-service-notification.sh
RUN cd /opt/ \
&& git clone https://github.com/symptog/icinga2-matrix-bot.git \
&& cd /opt/icinga2-matrix-bot/ \
&& git checkout 86d03ed8884950eb2b883a9a94ecf93460b8e0bb \
&& pip install -r requirements.txt \
&& mkdir /opt/icinga2-matrix-bot/.venv \
&& mkdir /opt/icinga2-matrix-bot/.venv/bin \
&& ln -s /usr/bin/python3 /opt/icinga2-matrix-bot/.venv/bin/python \
&& sed -i 's/matrix-host-state/matrix-service-state/' icinga2/matrix-service-notification.sh
\ No newline at end of file
/**
* Check MQTT values
*/
object CheckCommand "check_mqtt" { object CheckCommand "check_mqtt" {
import "plugin-check-command" import "plugin-check-command"
...@@ -33,6 +37,10 @@ object CheckCommand "check_mqtt" { ...@@ -33,6 +37,10 @@ object CheckCommand "check_mqtt" {
} }
} }
/**
* Check for Mail Blacklisting
*/
object CheckCommand "check_mail_blacklist" { object CheckCommand "check_mail_blacklist" {
import "plugin-check-command" import "plugin-check-command"
...@@ -45,6 +53,9 @@ object CheckCommand "check_mail_blacklist" { ...@@ -45,6 +53,9 @@ object CheckCommand "check_mail_blacklist" {
} }
} }
/**
* Check for Prometheus values
*/
object CheckCommand "check_metric_value" { object CheckCommand "check_metric_value" {
import "plugin-check-command" import "plugin-check-command"
...@@ -62,4 +73,56 @@ object CheckCommand "check_metric_value" { ...@@ -62,4 +73,56 @@ object CheckCommand "check_metric_value" {
"-w" = "$metric_warn$" "-w" = "$metric_warn$"
"-c" = "$metric_crit$" "-c" = "$metric_crit$"
} }
} }
\ No newline at end of file
/**
* Matrix Notification
*/
object NotificationCommand "matrix-host-notification" {
import "plugin-notification-command"
command = [ "/opt/icinga2-matrix-bot/icinga2/matrix-host-notification.sh" ]
env = {
"NOTIFICATIONTYPE" = "$notification.type$"
"HOSTALIAS" = "$host.display_name$",
"HOSTADDRESS" = "$address$",
"HOSTNAME" = "$host.name$",
"HOSTSTATE" = "$host.state$",
"LONGDATETIME" = "$icinga.long_date_time$",
"HOSTOUTPUT" = "$host.output$",
"NOTIFICATIONAUTHORNAME" = "$notification.author$",
"NOTIFICATIONCOMMENT" = "$notification.comment$",
"HOSTDISPLAYNAME" = "$host.display_name$",
"ICINGA_WEBURL" = "$notification_icingaweb2url$",
"MATRIX_SERVER" = "$user.vars.matrix.server$",
"MATRIX_TOKEN" = "$user.vars.matrix.token$",
"MATRIX_CHANNEL" = "$user.vars.matrix.channel$",
}
}
object NotificationCommand "matrix-service-notification" {
import "plugin-notification-command"
command = [ "/opt/icinga2-matrix-bot/icinga2/matrix-service-notification.sh" ]
env = {
"NOTIFICATIONTYPE" = "$notification.type$"
"SERVICEDESC" = "$service.name$"
"HOSTALIAS" = "$host.display_name$",
"HOSTNAME" = "$host.name$",
"HOSTADDRESS" = "$address$",
"SERVICESTATE" = "$service.state$",
"LONGDATETIME" = "$icinga.long_date_time$",
"SERVICEOUTPUT" = "$service.output$",
"NOTIFICATIONAUTHORNAME" = "$notification.author$",
"NOTIFICATIONCOMMENT" = "$notification.comment$",
"HOSTDISPLAYNAME" = "$host.display_name$",
"SERVICEDISPLAYNAME" = "$service.display_name$",
"ICINGA_WEBURL" = "$notification_icingaweb2url$",
"MATRIX_SERVER" = "$user.vars.matrix.server$",
"MATRIX_TOKEN" = "$user.vars.matrix.token$",
"MATRIX_CHANNEL" = "$user.vars.matrix.channel$",
}
}
object Host "warpfire" { object Host "wz-router" {
import "generic-host" import "generic-host"
address = "192.168.0.1" address = "192.168.0.1"
...@@ -7,11 +7,77 @@ object Host "warpfire" { ...@@ -7,11 +7,77 @@ object Host "warpfire" {
groups = [ "network" ] groups = [ "network" ]
} }
object Host "switch-sw01-hp" { object Host "wz-sw-core" {
import "generic-host" import "generic-host"
address = "192.168.0.100" address = "192.168.0.2"
groups = [ "network" ] groups = [ "network" ]
} }
object Host "wz-sw-access" {
import "generic-host"
address = "192.168.0.3"
# Keine Notifications, da der Switch aus ist wenn die Zone geschlossen ist
vars.enable_nofitications = false
groups = [ "network" ]
}
object Host "wz-sw-dach" {
import "generic-host"
address = "192.168.0.4"
groups = [ "network" ]
}
object Host "wz-ap-dach" {
import "generic-host"
address = "192.168.0.13"
groups = [ "network" ]
}
object Host "wz-ap-eingang" {
import "generic-host"
address = "192.168.0.14"
groups = [ "network" ]
}
object Host "wz-ap-lounge" {
import "generic-host"
address = "192.168.0.10"
groups = [ "network" ]
}
object Host "wz-ap-vortrag" {
import "generic-host"
address = "192.168.0.12"
groups = [ "network" ]
}
object Host "wz-ap-werkstatt" {
import "generic-host"
address = "192.168.0.11"
groups = [ "network" ]
}
object Host "homematic-ccu2" {
import "generic-host"
address = "{{ homematic.ccu2_host }}"
groups = [ "network" ]
}
apply Notification "matrix" to Host {
import "matrix-host-notification"
users = [ "matrix" ]
interval = 4h
assign where host.address && host.vars.enable_nofitications != false
}
apply Notification "matrix" to Service {
import "matrix-service-notification"
users = [ "matrix" ]
interval = 4h
assign where service.name && service.vars.enable_nofitications != false
}
...@@ -151,6 +151,8 @@ apply Service "spf record - {{ mail_domains[maildomain].maildomain }}" { ...@@ -151,6 +151,8 @@ apply Service "spf record - {{ mail_domains[maildomain].maildomain }}" {
assign where host.address && host.vars.is_dnsserver == "True" assign where host.address && host.vars.is_dnsserver == "True"
} }
{% if mail_domains[maildomain].dmarc is defined %}
apply Service "DMARC record - {{ mail_domains[maildomain].maildomain }}" { apply Service "DMARC record - {{ mail_domains[maildomain].maildomain }}" {
import "generic-service" import "generic-service"
...@@ -166,7 +168,7 @@ apply Service "DMARC record - {{ mail_domains[maildomain].maildomain }}" { ...@@ -166,7 +168,7 @@ apply Service "DMARC record - {{ mail_domains[maildomain].maildomain }}" {
assign where host.address && host.vars.is_dnsserver == "True" assign where host.address && host.vars.is_dnsserver == "True"
} }
{% endif %}
{% if mail_domains[maildomain].dkim is defined %} {% if mail_domains[maildomain].dkim is defined %}
{% for entry in mail_domains[maildomain].dkim %} {% for entry in mail_domains[maildomain].dkim %}
...@@ -179,7 +181,7 @@ apply Service "DKIM {{entry.selector}} record - {{ mail_domains[maildomain].mail ...@@ -179,7 +181,7 @@ apply Service "DKIM {{entry.selector}} record - {{ mail_domains[maildomain].mail
vars.dig_lookup = "{{entry.selector}}._domainkey.{{ mail_domains[maildomain].maildomain }}" vars.dig_lookup = "{{entry.selector}}._domainkey.{{ mail_domains[maildomain].maildomain }}"
vars.dig_record_type = "TXT" vars.dig_record_type = "TXT"
vars.dig_expected_address = "{{ entry.value }}" vars.dig_expected_address = "{{ entry.value | replace("\"","\\\"") }}"
vars.dig_arguments = "+tcp" vars.dig_arguments = "+tcp"
groups = [ "mail" ] groups = [ "mail" ]
......
apply Service "homematic-exporter" {
import "generic-service"
check_command = "http"
enable_perfdata = false
vars.http_address = "{{ hostvars['ogg'].int_ip4 }}"
vars.http_port = 8010
vars.http_uri = "/metrics"
groups = [ "exporter", "homematic" ]
assign where host.name == "ogg"
}
{% for device in homematic.devices_heizung %}
apply Service "{{ device.name }}_homematic_lowbat" {
import "generic-service"
check_command = "check_metric_value"
enable_perfdata = true
vars.metric_url = "http://{{ hostvars['ogg'].int_ip4 }}:8010/metrics"
vars.metric_name = "homematic_lowbat"
vars.metric_labelname = "device"
vars.metric_labelvalue = "{{ device.id }}:0"
vars.metric_operator = "gt"
vars.metric_warn = "0"
vars.metric_crit = "0"
assign where host.name == "ogg"
}
{% endfor %}
\ No newline at end of file
...@@ -9,4 +9,49 @@ apply Service "warpfire-admin" { ...@@ -9,4 +9,49 @@ apply Service "warpfire-admin" {
vars.http_port = 80 vars.http_port = 80
assign where host.name == "warpfire" assign where host.name == "warpfire"
} }
\ No newline at end of file
apply Service "wz-uplink-globe" {
import "generic-service"
check_command = "ping4"
vars.ping_address = "212.124.34.242"
vars.ping_wrta = "100"
vars.ping_crta = "300"
vars.ping_wpl = "20"
vars.ping_cpl = "50"
assign where host.name == "wz-router"
}
apply Service "wz-uplink-webdiscount-1" {
import "generic-service"
check_command = "ping4"
vars.ping_address = "212.3.64.45"
vars.ping_wrta = "100"
vars.ping_crta = "300"
vars.ping_wpl = "20"
vars.ping_cpl = "50"
assign where host.name == "wz-router"
}
apply Service "wz-uplink-webdiscount-2" {
import "generic-service"
check_command = "ping4"
vars.ping_address = "212.3.80.222"
vars.ping_wrta = "100"
vars.ping_crta = "300"
vars.ping_wpl= "20"
vars.ping_cpl = "50"
assign where host.name == "wz-router"
}
...@@ -81,3 +81,30 @@ template Notification "mail-service-notification" { ...@@ -81,3 +81,30 @@ template Notification "mail-service-notification" {
period = "24x7" period = "24x7"
} }
/**
* Provides default settings for Matrix.org service notifications.
*/
template Notification "matrix-host-notification" {
command = "matrix-host-notification"
states = [ Up, Down ]
types = [ Problem, Acknowledgement, Custom, FlappingStart, FlappingEnd ]
period = "24x7"
vars += {
notification_icingaweb2url = "https://{{ domain }}/icingaweb2"
}
}
template Notification "matrix-service-notification" {
command = "matrix-service-notification"
states = [ OK, Critical, Unknown ]
types = [ Problem, Acknowledgement, Custom, FlappingStart, FlappingEnd ]
period = "24x7"
vars += {
notification_icingaweb2url = "https://{{ domain }}/icingaweb2"
}
}