VIA Macros for German Umlauts on US-ANSI keyboards

If your US-ANSI keyboard supports VIA you can use it to create macros for the German Umlauts. All Keychron models should support this by now.

Requirement

  • Set the compose key of your desktop environment. I use Caps Lock for that.
  • The momentary layer key like MO(3) is bound to fn

Default behavior

# Type ö
Caps Lock, Shift-', o

# Type Ö
Caps Lock, Shift-', Shift-o

Custom behavior

# Type ö
fn-o

# Type Ö
fn-Shift-o

Macros

# Type ä/Ä
{KC_CAPS}{KC_RSFT,KC_QUOT}a

# Type ö/Ö
...

Useful jq commands

jq is great when dealing with JSON data. Check out the official jq Manual.

Content

Select only specific keys

Command

jq '.[] | { Name, OriginString...

GitLab CI: debugging failed jobs

It happens from time to time that a job in a GitLab pipeline fails. Sometimes, however, the error message is too meaningless to be helpful.

Example:

Running with gitlab-runner 16.7.0 (102c81ba)
  on <host>, system ID: <ID>
Resolving secrets
00:00
Preparing the "shell" executor
00:00
Using Shell (bash) executor...
Preparing environment
00:01
Running on <host>...
Getting source from Git repository
00:00
bash: line 157: /bin/mkdir: Argument list too long
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: e...

Useful PostgreSQL commands

on the bash (issued as postgres user)

Start/Stop/Restart PostgreSQL

pg_ctl -D $configdir start|stop|restart

Start/Stop/Restart the corresponding PostgreSQL using the given configuration directory. The configuration directory should contain the postgresql.conf file.

The following example would start the PostgreSQL of our governor instances: pg_ctl -D /var/lib/postgresql/config start

PostgreSQL fast shutdown

pg_ctl -D $configdir stop -m fast

Normal shutdown can take forever because postgres will w...

What are these numbers in /etc/fstab for?

Wondering what these numbers in the mount entries in /etc/fstab are meaning?

The first number fs_freq

When this field is set to 1 dump(8) will make a backup of the partition. Not using dump for backups? You can ignore the field.

The second number fs_passno

This field determines the order of partition to fsck. Every partition that have seen more than Maximum mount count will undergo an fsck unless the vaule is set to 0.

Lets see how Maximum mount count is set on my Ubuntu 22.04:

 sudo tune2fs -l /dev/n...

Use pg_repack to do a VACUUM FULL without holding an exclusive lock during processing

You can use pg_repack to do a VACUUM FULL without holding an exclusive lock during processing.

There is still a need of one exclusive lock at the beginning and the end of the repacking process. But in the time between, you can use the affected table.

To use it you have to do the following:

  1. Install pg_repack, e.g. for Ubuntu install the package according to your PostgreSQL Server version. There is no need to restart the PostgreSQL Server.
$ sudo apt-get install postgresql-16-repack
  1. Create the extension in the database...

Controlling multiple PostgreSQL installations on Debian/Ubuntu

Hint

This applies only to distributions based on Debian.

Requirement

You need to setup the PostgreSQL Apt Repository first.

If you have multiple Postgres versions installed on a system and want to start/stop/restore/.. them separately you need to use pg_ctlcluster

Usage: /usr/bin/pg_ctlcluster <version> <cluster> <action>

For example

/usr/bin/pg_ctlcluster 47 main start

With systemd you can start/stop the services via:

systemctl <action> p...

HowTo apply Test Driven Development to Container Images

Apply Test Driven Development(TDD) to the process of building container images by defining test before writing code and automate the testing process. Iterate through the TDD cycle while developing and running the tests later in continuous integration to ensure robust and reliable container images.

Installation

We create a Gemfile for installing all required gems.

# Gemfile
gem 'docker-api'
gem 'serverspec'
gem 'rspec'

Then we install them

bundle install

Preparation

Create the directory where the Tests a...

HowTo Generate Nagios Config with puppet fast

Creating Nagios Config with puppet

Let's have a look at the classic way of managing Nagios configuration with exported Puppet resources.
Here is a good article about the topic written by Eric Holzbach.

First we export the checks on the nodes we want to monitor:

@@nagios_service { “check_unicorns-${::hostname}”:
  host_name           => $::hostname,
  service_description => ‘Unicorn Status’,
  check_command       => ‘check_unicorn-${::hostname}“,
...

How to Protect container images with production tag from ECR lifecycle rules

If you want to automatically delete old container images from your Elastic Container Registry, the solution is a quite simple ECR Lifecycle Rule that deletes images e.g. 7 days after they have been pushed to the registry.

If you however want to always keep the image tagged production, possibly because that is a floating tag always associated with the image currently deployed to production, the situation suddenly is not so simple any more. ECR does not provide a keep action in their lifecycle rules, only "expire". The logic here is t...

Find dead code in puppet with puppet-ghostbuster

There is a gem puppet-ghostbuster which can help you find dead code in puppet projects.

To use it, (as of now) it's best to get the latest version from git, as the last release is not yet on rubygems.org.

# Gemfile
gem 'puppet-ghostbuster', git: 'https://github.com/voxpupuli/puppet-ghostbuster.git', ref: 'XXXXX'

After that you can use puppet-lint to find dead code in your project:

# You probably need to set some ENV Variables, see https://github.com/voxpupuli/puppet-ghostbu...

Change bwlimit for Proxmox storages

It's not possible to change the bwlimit of Proxmox storages via the Web-UI (at least in Proxmox 7.x).

To change the bwlimit you need to use the pvesm command and specify the limit for the desired category.

For example to increase the bwlimit for migrations:

pvesm set $NAME_OF_STORAGE --bwlimit migration=$INTEGER_LIMIT
# example
pvesm set ssd --bwlimit migration=500000

These are the different categories:

  • default
  • clone
  • migration
  • move
  • restore

Repair broken etcd node

If one etcd node is no longer a member of the remaining etcd cluster or fails to connect you need to remove it from the cluster and then add it again:

  1. Stop etcd on the broken node : sudo service etcd stop
  2. delete the data on the broken node sudo rm -r /var/lib/etcd/data/*
  3. delete the wal data on the broken node: sudo rm -r /var/lib/etcd/wal/*
  4. Follow the instructions for etcd runtime-configuration, remove the broken node from the cluster, then re-add it again and ...

Barman recovery fails with missing history file

When restoring a barman PITR backup you may encounter this error:

Copying required WAL segments.
EXCEPTION: {'ret': 2, 'err': '/bin/sh: 1: cannot open /var/lib/barman/foopostgres/wals/00000007.history: No such file\n', 'out': ''}

The reason is that the barman backups xlog.db file contains a history file which is no longer present in the wals directory of your backup. The most likely reason is that someone deleted this file in the past. If you do not need this file for restoring your current backup (maybe because it's very old a...

Terraform/Terragrunt: Hide Refreshing State..., Reading..., Read complete after... output

Terraform (and terragrunt) gives a lot of output when running plan or apply, outputting a lot of progress information when refreshing the state before creating the plan. They have reasons for this but it doesn't look like there is going to be any silent flags any time soon. Especially when running larger environments or running multiple modules with terragrunt, this will clog the output on your terminal or in your CI jobs, possibly making the signal hard to find among the noise.

H...

ACM certificate not showing up in CloudFront

Preface

Before you continue, ensure that you've created your certificate in the region us-east-1 (N. Virginia). Otherwise the certificate is not available for CloudFront.

The issue

At some point in time you may be confronted with the following issue:

  • you've requested an SSL certificate via ACM
  • the validation was successful
  • you try to add the freshly issued ACM certificate to a CloudFront configuration via AWS console
  • the certificate is not selectable from the dropdown in the distribution configuration

Fixing the is...

Pay attention to trailing slashes when using rsync

When you synchronize directories with rsync you have to pay attention to use (or not use) trailing /.

Example:

# without trailing slash
$ mkdir -p a/foo/bar/baz
$ mkdir b
$ rsync -a a b
$ find b
b
b/a
b/a/foo
b/a/foo/bar
b/a/foo/bar/baz

# with trailing slash
$ mkdir -p a/foo/bar/baz
$ mkdir b
$ rsync -a a/ b/
$ find b
b
b/foo
b/foo/bar
b/foo/bar/baz

Merge two PostgreSQL dumps

Attention

This is an edge-case. You probably don't want to mix different database dumps. It also requires that the mixed tables do not share relations to other database objects.

Scenario

  • You've got two database dumps:
    • dump_a.pgdump
    • dump_b.pgdump
  • Both dumps include these tables:
    • foobar
    • barfoo
    • foobaz
  • You want to create a dump with:
    • dump_a.foobar
    • dump_b.barfoo
    • dump_a.foobaz

Invalid and incomplete restore

These commands might be obvious but won't actually work:

pg_re...