Skip to content

Instantly share code, notes, and snippets.

View kjetilho's full-sized avatar

Kjetil Torgrim Homme kjetilho

  • Redpill Linpro AS
  • Oslo, Norway
View GitHub Profile
@kjetilho
kjetilho / networkd.pp
Created August 6, 2024 22:49
routine network configuration
class networkd(
Hash $bonds = {},
Optional[Hash] $networks = undef,
Hash $units = {},
)
{
package {
# Ubuntu
'netplan.io': ensure => absent;
# RHEL
@kjetilho
kjetilho / xx.pp
Created December 17, 2020 20:51
plussignment
class a {
file { ['/a', '/b']: }
file{"/xx": ensure => absent, require => File['/a'] }
}
class b inherits a {
File["/xx"]{ require +> File['/b']}
}
include b
@kjetilho
kjetilho / fqdndns_ipaddress4.rb
Created September 16, 2020 06:28
simple custom facts to use resolved addresses in Puppet code
Facter.add(:fqdndns_ipaddress4) do
setcode do
begin
# Use the system configured nameservers to run a query
addrs = []
begin
require 'resolv'
Resolv::DNS.open do |dns|
ress = dns.getresources(Facter.value('fqdn'), Resolv::DNS::Resource::IN::A)
addrs = ress.map { |r| r.address }
@kjetilho
kjetilho / adjust_volume.sh
Created September 15, 2020 15:35
a script to adjust volume. it will try to use the most recent audio card by default.
#! /bin/bash
case $1 in
-c)
card=$2; shift; shift;;
*)
card=$(awk '/digital audio playback/ {c = substr($0, 7, 2)} END {print c}' /proc/asound/devices)
;;
esac
@kjetilho
kjetilho / Rakefile
Created September 1, 2020 15:17
this is how we configure puppet-lint in our Rakefile
# Common configuration
exclude_paths = [
'pkg/**/*',
'vendor/**/*',
'spec/fixtures/modules/**/*',
'modules/**/*',
]
# Configuration for 'rake lint'. See documentation at
# https://github.com/rodjek/puppet-lint
@kjetilho
kjetilho / my_i3status
Created June 5, 2020 08:53
wrapper for i3status which adjusts output and warns when battery is low
#! /usr/bin/perl -CSDL
use warnings;
use strict;
use utf8;
use JSON;
# Don't die when instant update is requested with a sloppy
# pkill -USR1 i3status
$SIG{USR1} = undef;
#! /bin/bash
#
# i3-disp-size
# Displays the focused container's dimensions in that container's corner.
#
# Written by GermainZ and kjetilho from #i3@freenode
#
# Dependencies:
#
# - i3 <https://i3wm.org/>
#! /usr/bin/perl
#
# puppetdb 1.0 - a wrapper to simplify lookups in PuppetDB.
# Written 2018 by [email protected]
use Getopt::Long;
use LWP::UserAgent;
use URI::Escape;
use JSON;
use strict;
ARG BASE_IMAGE=buster
FROM debian:$BASE_IMAGE
ENV DEBIAN_FRONTEND noninteractive
RUN mkdir -p /run/systemd && \
echo 'docker' > /run/systemd/container
CMD ["/bin/bash"]
#! /bin/bash
declare -A pvalue
parse_plist() {
declare -a pl=$1
pvalue=()
local i=0
while [[ i -lt ${#pl[@]} ]]
do