Skip to content

Instantly share code, notes, and snippets.

View rmetzler's full-sized avatar
💭
Recruiters should mention the role and salary range if you spam me.

Richard Metzler rmetzler

💭
Recruiters should mention the role and salary range if you spam me.
View GitHub Profile
@rmetzler
rmetzler / check_dns.sh
Created September 14, 2021 14:06 — forked from anapsix/check_dns.sh
Watch for DNS changes and reload NGINX (or do something else)
#!/usr/bin/env bash
#
## example running it from cron
# MAILTO=""
# SHELL=/bin/bash
# VERBOSE=1
# CMD_ON_FAILURE='/etc/init.d/nginx reload'
# * * * * * root timeout -k 2 5 /tmp/check_dns.sh upstream.server.com 2>>/var/log/check_dns.log
# * * * * * root sleep 10 && sed -e :a -e '$q;N;501,$D;ba' -i /var/log/check_dns.log
#
@rmetzler
rmetzler / .gitlab-ci.yml
Created August 16, 2021 06:22
autorebase in gitlab ci
image: node:16
stages:
- build
- test
build:
stage: build
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
@rmetzler
rmetzler / flatten.gotmpl
Last active June 20, 2023 03:30
flatten lists in helm and go templating
{{- define "flatten_list" -}}
{{- $output := list -}}
{{- range . -}}
{{- if (kindIs "slice" . ) -}}
{{- $output = (concat $output ( get (fromYaml (include "flatten_list" . ) ) "list" ) ) -}}
{{- else -}}
{{- $output = (append $output . ) -}}
{{- end -}}
{{- end -}}
{{- toYaml (dict "list" $output) -}}
@rmetzler
rmetzler / shell-execution.rb
Last active June 3, 2021 19:26 — forked from JosephPecoraro/shell-execution.rb
Shell Execution in Ruby
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Synchronous (blocking)
# Returns the output of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
@rmetzler
rmetzler / script-template.sh
Created December 15, 2020 20:12 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@rmetzler
rmetzler / default.vcl
Created October 2, 2020 09:03 — forked from mojodna/default.vcl
Resolve ELB IPs and create a dynamic Varnish backend list (intended to run out of cron).
# ...
include "dynamic_backends.vcl";
# ...
<!DOCTYPE html>
<html>
<head>
<title>XDebug Flame Graph</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2" />
<style>
label {cursor: pointer;}
svg{width:100%;}
</style>
@rmetzler
rmetzler / vault_logrotate
Created July 3, 2019 18:10 — forked from soloradish/vault_logrotate
logrotate setting file for HashiCorp's Vault audit file
# Change the path below to your own audit log path.
/var/log/vault/audit.log {
rotate 30
daily
# Do not execute rotate if the log file is empty.
notifempty
missingok
compress
# Set compress on next rotate cycl to prevent entry loss when performing compression.
delaycompress
@rmetzler
rmetzler / systemdunit.py
Created June 14, 2019 13:24 — forked from esamattis/systemdunit.py
Install Systemd units using Ansible
"""
Install Systemd units using Ansible
Handles unit restarting and systemd daemon reloading when the unit changes.
Also stops the unit correctly when uninstalled
In your playbook put this file to library/systemdunit.py and make sure the
server has python-sh package installed
@rmetzler
rmetzler / test.py
Created June 5, 2019 19:52 — forked from dmsimard/test.py
ara with ansible-runner
#!/usr/bin/env python3
# Proof of concept ara with ansible-runner
# Requires https://github.com/ansible/ansible-runner/issues/219#issuecomment-496191227
import ansible_runner
import os
from ara.setup import callback_plugins
PLAYBOOK = """
- name: Test for ansible-runner