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
Commits on Source (14)
Showing
with 262 additions and 93 deletions
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
export BORG_PASSPHRASE="{{repo_passphrase}}" export BORG_PASSPHRASE="{{repo_passphrase}}"
export BORG_RSH="ssh -i /srv/borgbackup/repo_sshkey" export BORG_RSH="ssh -i /srv/borgbackup/repo_sshkey"
# Force locale for correct formatting
LANG=en_US.UTF-8
# Metrics output file in the prometheus node-exporter directory # Metrics output file in the prometheus node-exporter directory
PROM_FILE="/var/lib/prometheus/node-exporter/borgbackup.prom" PROM_FILE="/var/lib/prometheus/node-exporter/borgbackup.prom"
......
...@@ -22,8 +22,16 @@ ...@@ -22,8 +22,16 @@
- docker-compose.yml - docker-compose.yml
- Dockerfile - Dockerfile
- syncrepl_exporter.yml - syncrepl_exporter.yml
register: config
- name: start openldap docker - name: "stop {{ servicename}} docker"
docker_compose: docker_compose:
project_src: /srv/ldap/ project_src: "{{ basedir }}"
state: absent
when: config.changed
- name: "start {{ servicename}} docker"
docker_compose:
project_src: "{{ basedir }}"
state: present state: present
...@@ -52,4 +52,4 @@ ...@@ -52,4 +52,4 @@
docker_compose: docker_compose:
project_src: "{{ basedir }}" project_src: "{{ basedir }}"
state: present state: present
\ No newline at end of file
...@@ -36,5 +36,6 @@ alert: ...@@ -36,5 +36,6 @@ alert:
crit: 8 crit: 8
disks: disks:
- { mountpoint: "/", warn: "10 GB", crit: "3 GB" } - { mountpoint: "/", warn: "10 GB", crit: "3 GB" }
- { mountpoint: "/mnt/data", warn: "10 GB", crit: "3 GB" } # btrfs currently no data from node exporter
# - { mountpoint: "/mnt/data", warn: "10 GB", crit: "3 GB" }
...@@ -71,9 +71,9 @@ alert: ...@@ -71,9 +71,9 @@ alert:
warn: 8 warn: 8
crit: 16 crit: 16
containers: containers:
- { name: "coturn_coturn_1" }
- { name: "dockerstats_app_1" } - { name: "dockerstats_app_1" }
- { name: "dokuwiki_app_1" } - { name: "dokuwiki_app_1" }
- { name: "coturn_coturn_1" }
- { name: "gitlab_app_1" } - { name: "gitlab_app_1" }
- { name: "gitlab_dind_1" } - { name: "gitlab_dind_1" }
- { name: "gitlab_runner_1" } - { name: "gitlab_runner_1" }
...@@ -101,14 +101,15 @@ alert: ...@@ -101,14 +101,15 @@ alert:
- { name: "mail_mailman-core_1" } - { name: "mail_mailman-core_1" }
- { name: "mail_mailman-web_1" } - { name: "mail_mailman-web_1" }
- { name: "mail_mailman-nginx_1" } - { name: "mail_mailman-nginx_1" }
- { name: "matrix_ma1sd_1" }
- { name: "matrix_db_1" }
- { name: "matrix_synapse_1" }
- { name: "matterbridge_cw_1" } - { name: "matterbridge_cw_1" }
- { name: "matterbridge_wz_1" } - { name: "matterbridge_wz_1" }
- { name: "matterbridge_web_1" } - { name: "matterbridge_web_1" }
- { name: "matterbridge_restarter_1" } - { name: "matterbridge_restarter_1" }
- { name: "matrix_ma1sd_1" }
- { name: "matrix_db_1" }
- { name: "matrix_synapse_1" }
- { name: "traefik_app_1" } - { name: "traefik_app_1" }
- { name: "vpnserver_app_1" }
- { name: "warpapi_app_1" } - { name: "warpapi_app_1" }
- { name: "wordpress_app_1" } - { name: "wordpress_app_1" }
- { name: "wordpress_db_1" } - { name: "wordpress_db_1" }
......
...@@ -20,7 +20,7 @@ prod: ...@@ -20,7 +20,7 @@ prod:
vms: vms:
children: children:
weatherwax: weatherwax-vms:
hosts: hosts:
# Server für interne Dienste # Server für interne Dienste
# Container auf dem internen Proxmox Server # Container auf dem internen Proxmox Server
...@@ -34,7 +34,7 @@ prod: ...@@ -34,7 +34,7 @@ prod:
carrot: carrot:
ansible_ssh_host: 192.168.0.202 ansible_ssh_host: 192.168.0.202
tiffany: tiffany-vms:
hosts: hosts:
# Öffentlicher Webserver Warpzone # Öffentlicher Webserver Warpzone
# VM auf Tiffany # VM auf Tiffany
......
...@@ -153,7 +153,8 @@ ...@@ -153,7 +153,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"
} }
- { - {
...@@ -172,7 +173,9 @@ ...@@ -172,7 +173,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 +189,7 @@ ...@@ -186,7 +189,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,
......
...@@ -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
...@@ -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 != '': exit()
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")
...@@ -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$",
}
}
apply Notification "matrix" to Host {
import "matrix-host-notification"
users = [ "matrix" ]
interval = 4h
assign where host.address
}
apply Notification "matrix" to Service {
import "matrix-service-notification"
users = [ "matrix" ]
interval = 4h
assign where service.name
}
...@@ -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"
}
}
...@@ -3,3 +3,18 @@ object UserGroup "icingaadmins" { ...@@ -3,3 +3,18 @@ object UserGroup "icingaadmins" {
display_name = "Icinga 2 Admin Group" display_name = "Icinga 2 Admin Group"
} }
object User "matrix" {
import "generic-user"
display_name = "Matrix User"
vars.matrix = {
token = "{{ matrix_notification_access_token }}"
channel = "!iYefxbySFEfFQfUGEK:matrix.warpzone.ms"
server = "https://matrix.warpzone.ms"
}
}
object UserGroup "matrix" {
display_name = "Matrix Group"
assign where user.vars.matrix
}
...@@ -10,7 +10,7 @@ services: ...@@ -10,7 +10,7 @@ services:
db: db:
image: postgres:13.6 image: postgres:13.11
restart: always restart: always
volumes: volumes:
- /srv/matrix/db:/var/lib/postgresql/data - /srv/matrix/db:/var/lib/postgresql/data
...@@ -24,7 +24,7 @@ services: ...@@ -24,7 +24,7 @@ services:
synapse: synapse:
image: matrixdotorg/synapse:v1.78.0 image: matrixdotorg/synapse:v1.83.0
restart: always restart: always
cpu_count: "1" cpu_count: "1"
cpuset: "0" cpuset: "0"
......