Skip to content

Instantly share code, notes, and snippets.

View nbuchwitz's full-sized avatar
👋
hi there

Nicolai nbuchwitz

👋
hi there
View GitHub Profile
---
- name: Setup Icinga2 Client
hosts: all
vars:
icinga2_pki_path: /var/lib/icinga2/certs
icinga2_master: "icinga-master.fqdn"
icinga2_cn: "{{ inventory_hostname }}"
icinga2_zone: "{{ inventory_hostname }}"
# connection direction: master <- client
icinga2_endpoint: "icinga-satellite-or-master.fqdn,icinga-satellite-or-master.fqdn,5665"
@nbuchwitz
nbuchwitz / remove-cname.yml
Last active November 29, 2018 15:16
Remove Route54 CNAME records with Ansible
- name: Remove CNAME record
route53:
state: absent
zone: "{{ item.zone }}"
record: "{{ item.record }}"
type: CNAME
value: "{{ item.target }}"
loop:
- { record: "somthing", zone: "example.com", target: "target.host.example.com" }
- { record: "another.one", zone: "example.com", target: "target.host.example.com" }
- route53:
state: get
zone: foo.com
record: new.foo.com
type: CNAME
register: rec
- debug:
msg: rec
@nbuchwitz
nbuchwitz / revpimodio_replace_io_demo.py
Last active June 25, 2021 14:51
RevPiModIO2 replace_io example
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: ts=4:sw=4:et
import revpimodio2
import paho.mqtt.client as mqtt
# connect to mqtt broker
client = mqtt.Client()
client.connect("your-broker.example.com", 1883)
---
- hosts: jitsi
become: True
vars:
jitsi_domain: "jitsi.example.org"
certbot_mail: "foo@example.org"
pre_tasks:
- name: Enable tls transport for apt
apt:
name: apt-transport-https
- name: schedule downtime
uri:
url: "https://{{ icinga_host }}:{{ icinga_port | default(5665) }}/v1/actions/schedule-downtime"
user: "{{ icinga_user }}"
password: "{{ icinga_password }}"
force_basic_auth: True
validate_certs: False
method: POST
headers:
Accept: "application/json"
@nbuchwitz
nbuchwitz / dashboard.json
Last active January 10, 2022 21:54
esphome gas meter
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
import revpimodio2
def ev(name, value):
# payload is bytes, so we need to know the enconding (eg. ascii, utf-8, etc...)
print(name, value.decode('ascii'))
rpi = revpimodio2.RevPiModIO(autorefresh=True, monitoring=True)
rpi.handlesignalend()
# define IO: change length of string in the frm argument
#!/usr/bin/env python3
import sys
import json
import argparse
import os.path
DEFAULT_CONFIG_NEW = "/var/www/revpi/pictory/projects/_config.rsc"
DEFAULT_CONFIG_OLD = "/var/www/pictory/projects/_config.rsc"
import os
import revpimodio2
class Application():
def __init__(self):
self.rpi = revpimodio2.RevPiModIO(autorefresh=True)
self.rpi.handlesignalend(self.cleanup_revpi)
self.rpi.core.x2in.reg_event(self.event_shutdown, edge=revpimodio2.RISING)