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 / 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 kjetil.homme@redpill-linpro.com
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
1) baseconfig::filebeat on ubuntu-14.04-x86_64 should compile into a catalogue without dependency cycles
Failure/Error: it { should compile.with_all_deps }
RuntimeError:
Could not find the daemon directory (tested [/etc/sv,/var/lib/service])
# /var/lib/gems/2.3.0/gems/puppet-4.10.10/lib/puppet/provider/service/runit.rb:50:in `defpath'
# /var/lib/gems/2.3.0/gems/puppet-4.10.10/lib/puppet/type/service.rb:180:in `block (3 levels) in <module:Puppet>'
# /var/lib/gems/2.3.0/gems/puppet-4.10.10/lib/puppet/type.rb:834:in `set_default'
# /var/lib/gems/2.3.0/gems/rspec-puppet-2.6.11/lib/rspec-puppet/monkey_patches.rb:86:in `call'
# /var/lib/gems/2.3.0/gems/rspec-puppet-2.6.11/lib/rspec-puppet/monkey_patches.rb:86:in `block in <class:Type>'