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 266 additions and 185 deletions
...@@ -30,7 +30,7 @@ def do_work(): ...@@ -30,7 +30,7 @@ def do_work():
# There are no topics - just exit # There are no topics - just exit
if (len(topics) == 0): if (len(topics) == 0):
exit() return True
# calculate date of next tuesday # calculate date of next tuesday
d = datetime.date.today() d = datetime.date.today()
......
...@@ -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"
......
...@@ -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
...@@ -49,8 +50,16 @@ RUN cd /opt/ \ ...@@ -49,8 +50,16 @@ RUN cd /opt/ \
&& cd /opt/check_metric_value/ \ && cd /opt/check_metric_value/ \
&& git checkout b94d3c3e78497a05e3b4520d33421f37e4d77985 && git checkout b94d3c3e78497a05e3b4520d33421f37e4d77985
# icinga2-matrix_notification - commit from 15.04.2012 # icinga2-matrix-bot - commit from 10.06.2018
# create a symlink to emulate virtualenv
# patch matrix-service-notification.sh
RUN cd /opt/ \ RUN cd /opt/ \
&& git clone https://github.com/linuxmail/icinga2-matrix_notification \ && git clone https://github.com/symptog/icinga2-matrix-bot.git \
&& cd /opt/icinga2-matrix_notification/ \ && cd /opt/icinga2-matrix-bot/ \
&& git checkout 99d2174a3b00e9a88648fe58bcd975368f69837d && 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
...@@ -80,131 +80,49 @@ object CheckCommand "check_metric_value" { ...@@ -80,131 +80,49 @@ object CheckCommand "check_metric_value" {
*/ */
object NotificationCommand "matrix-host-notification" { object NotificationCommand "matrix-host-notification" {
import "plugin-notification-command" import "plugin-notification-command"
command = [ "/opt/icinga2-matrix_notification/scripts/matrix-host-notification.sh" ]
arguments += { command = [ "/opt/icinga2-matrix-bot/icinga2/matrix-host-notification.sh" ]
"-4" = "$notification_address$"
"-6" = "$notification_address6$" env = {
"-b" = "$notification_author$" "NOTIFICATIONTYPE" = "$notification.type$"
"-c" = "$notification_comment$" "HOSTALIAS" = "$host.display_name$",
"-d" = { "HOSTADDRESS" = "$address$",
required = true "HOSTNAME" = "$host.name$",
value = "$notification_date$" "HOSTSTATE" = "$host.state$",
} "LONGDATETIME" = "$icinga.long_date_time$",
"-i" = "$notification_icingaweb2url$" "HOSTOUTPUT" = "$host.output$",
"-l" = { "NOTIFICATIONAUTHORNAME" = "$notification.author$",
required = true "NOTIFICATIONCOMMENT" = "$notification.comment$",
value = "$notification_hostname$" "HOSTDISPLAYNAME" = "$host.display_name$",
} "ICINGA_WEBURL" = "$notification_icingaweb2url$",
"-m" = { "MATRIX_SERVER" = "$user.vars.matrix.server$",
required = true "MATRIX_TOKEN" = "$user.vars.matrix.token$",
value = "$notification_matrix_room_id$" "MATRIX_CHANNEL" = "$user.vars.matrix.channel$",
} }
"-n" = {
required = true
value = "$notification_hostdisplayname$"
}
"-o" = {
required = true
value = "$notification_hostoutput$"
}
"-s" = {
required = true
value = "$notification_hoststate$"
}
"-t" = {
required = true
value = "$notification_type$"
}
"-x" = {
required = true
value = "$notification_matrix_server$"
}
"-y" = {
required = true
value = "$notification_matrix_token$"
}
}
vars.notification_address = "$address$"
vars.notification_address6 = "$address6$"
vars.notification_author = "$notification.author$"
vars.notification_comment = "$notification.comment$"
vars.notification_date = "$icinga.long_date_time$"
vars.notification_hostdisplayname = "$host.display_name$"
vars.notification_hostname = "$host.name$"
vars.notification_hostoutput = "$host.output$"
vars.notification_hoststate = "$host.state$"
vars.notification_type = "$notification.type$"
} }
object NotificationCommand "matrix-service-notification" { object NotificationCommand "matrix-service-notification" {
import "plugin-notification-command" import "plugin-notification-command"
command = [ "/opt/icinga2-matrix_notification/scripts/matrix-service-notification.sh" ]
arguments += { command = [ "/opt/icinga2-matrix-bot/icinga2/matrix-service-notification.sh" ]
"-4" = {
required = true env = {
value = "$notification_address$" "NOTIFICATIONTYPE" = "$notification.type$"
} "SERVICEDESC" = "$service.name$"
"-6" = "$notification_address6$" "HOSTALIAS" = "$host.display_name$",
"-b" = "$notification_author$" "HOSTNAME" = "$host.name$",
"-c" = "$notification_comment$" "HOSTADDRESS" = "$address$",
"-d" = { "SERVICESTATE" = "$service.state$",
required = true "LONGDATETIME" = "$icinga.long_date_time$",
value = "$notification_date$" "SERVICEOUTPUT" = "$service.output$",
} "NOTIFICATIONAUTHORNAME" = "$notification.author$",
"-e" = { "NOTIFICATIONCOMMENT" = "$notification.comment$",
required = true "HOSTDISPLAYNAME" = "$host.display_name$",
value = "$notification_servicename$" "SERVICEDISPLAYNAME" = "$service.display_name$",
} "ICINGA_WEBURL" = "$notification_icingaweb2url$",
"-i" = "$notification_icingaweb2url$" "MATRIX_SERVER" = "$user.vars.matrix.server$",
"-l" = { "MATRIX_TOKEN" = "$user.vars.matrix.token$",
required = true "MATRIX_CHANNEL" = "$user.vars.matrix.channel$",
value = "$notification_hostname$" }
}
"-m" = {
required = true
value = "$notification_matrix_room_id$"
}
"-n" = {
required = true
value = "$notification_hostdisplayname$"
}
"-o" = {
required = true
value = "$notification_serviceoutput$"
}
"-s" = {
required = true
value = "$notification_servicestate$"
}
"-t" = {
required = true
value = "$notification_type$"
}
"-u" = {
required = true
value = "$notification_servicedisplayname$"
}
"-x" = {
required = true
value = "$notification_matrix_server$"
}
"-y" = {
required = true
value = "$notification_matrix_token$"
}
}
vars.notification_address = "$address$"
vars.notification_address6 = "$address6$"
vars.notification_author = "$notification.author$"
vars.notification_comment = "$notification.comment$"
vars.notification_date = "$icinga.long_date_time$"
vars.notification_hostdisplayname = "$host.display_name$"
vars.notification_hostname = "$host.name$"
vars.notification_servicedisplayname = "$service.display_name$"
vars.notification_serviceoutput = "$service.output$"
vars.notification_servicestate = "$service.state$"
vars.notification_type = "$notification.type$"
vars.notification_servicename = "$service.name$"
} }
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" ]
}
// https://github.com/linuxmail/icinga2-matrix_notification apply Notification "matrix" to Host {
/** import "matrix-host-notification"
* Example Matrix.org apply rules.
* The "!<id>:matrix.org" needs to be replaced with the room ID
* for example "!SDFfskjfdszhdaslasdkjhdasd:matrix.org".
* Also a Matrix access token is required too.
*/
apply Notification "Matrix host problems" to Host { users = [ "matrix" ]
import "matrix-host-notification"
user_groups = [ "icingaadmins" ] interval = 4h
vars.notification_matrix_server = "https://{{ matrix_notification_domain }}" assign where host.address && host.vars.enable_nofitications != false
vars.notification_matrix_room_id = "{{ matrix_notification_room }}"
vars.notification_matrix_token = "{{ matrix_notification_access_token }}"
# Assign to all hosts
assign where host.address
} }
apply Notification "Matrix service problems" to Service {
import "matrix-service-notification"
user_groups = [ "icingaadmins" ] apply Notification "matrix" to Service {
import "matrix-service-notification"
users = [ "matrix" ]
vars.notification_matrix_server = "https://{{ matrix_notification_domain }}" interval = 4h
vars.notification_matrix_room_id = "{{ matrix_notification_room }}"
vars.notification_matrix_token = "{{ matrix_notification_access_token }}"
# Assign to all services assign where service.name && service.vars.enable_nofitications != false
assign where service.name
} }
...@@ -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"
}
...@@ -87,32 +87,24 @@ template Notification "mail-service-notification" { ...@@ -87,32 +87,24 @@ template Notification "mail-service-notification" {
*/ */
template Notification "matrix-host-notification" { template Notification "matrix-host-notification" {
command = "matrix-host-notification" command = "matrix-host-notification"
states = [ Up, Down ] states = [ Up, Down ]
types = [ Problem, Acknowledgement, Recovery, Custom, types = [ Problem, Acknowledgement, Custom, FlappingStart, FlappingEnd ]
FlappingStart, FlappingEnd,
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
vars += {
// notification_icingaweb2url = "https://{{ domain }}/icingaweb2"
notification_logtosyslog = false
}
// interval = 0s
period = "24x7" period = "24x7"
vars += {
notification_icingaweb2url = "https://{{ domain }}/icingaweb2"
}
} }
template Notification "matrix-service-notification" { template Notification "matrix-service-notification" {
command = "matrix-service-notification" command = "matrix-service-notification"
states = [ OK, Warning, Critical, Unknown ]
types = [ Problem, Acknowledgement, Recovery, Custom,
FlappingStart, FlappingEnd,
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
vars += { states = [ OK, Critical, Unknown ]
// notification_icingaweb2url = "https://{{ domain }}/icingaweb2" types = [ Problem, Acknowledgement, Custom, FlappingStart, FlappingEnd ]
notification_logtosyslog = false
}
// interval = 0s
period = "24x7" 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
}
...@@ -69,6 +69,13 @@ ...@@ -69,6 +69,13 @@
- mailu/overrides/postfix/postfix.cf - mailu/overrides/postfix/postfix.cf
register: config register: config
- name: "set local dns record"
become: true
blockinfile:
path: /etc/hosts
create: yes
block: |
{{ ext_ip4 }} mailserver.warpzone.ms
# - name: deploy LogRotate configs # - name: deploy LogRotate configs
# template: # template:
......
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
# Set Version # Set Version
MAILU_VERSION=2.0.4 MAILU_VERSION=2.0.4
# enable IPv6
SUBNET6=fd00:dead:beef:25::/64
# Autocreate Admin User # Autocreate Admin User
INITIAL_ADMIN_ACCOUNT=mailadmin INITIAL_ADMIN_ACCOUNT=mailadmin
INITIAL_ADMIN_DOMAIN={{ domain }} INITIAL_ADMIN_DOMAIN={{ domain }}
......
...@@ -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"
......