Skip to content

Instantly share code, notes, and snippets.

View frimik's full-sized avatar

Mikael Fridh frimik

  • Electronic Arts / DICE
  • Uppsala, Sweden
View GitHub Profile
@frimik
frimik / answers.yaml
Created February 11, 2013 22:06
foreman-installer answers.yaml: Puppet+Foreman on same host.
# Format:
# <classname>: false - don't include this class
# <classname>: true - include and use the defaults
# <classname>:
# <param>: <value> - include and override the default(s)
#
# See params.pp in each class for what options are available
---
foreman: true
foreman:
@frimik
frimik / gist:4730558
Last active December 7, 2016 06:59
Foreman + Libvirt

TheForeman + Libvirt notes

Foreman+KVM on the same physical host

Set up a bridge

  • virsh iface-bridge eth0 br0
  • If you had NM_CONTROLLED=no in there, re-add it to both ifcfg files because virsh probably just removed it for you.
@frimik
frimik / Makefile
Created February 1, 2013 15:23
pkgbuild Makefile hack. tmtowtdi!
SPEC := $(wildcard *.spec)
ARCHS := $(shell spec-archs $(SPEC))
DEFINES := --define "_sourcedir $(shell pwd)"
DEFINES += --define "_srcrpmdir $(shell pwd)"
DEFINES += --define "_rpmdir $(shell pwd)"
SRPMS := $(wildcard *.src.rpm)
MOCKDIR := "$(shell pwd)/mock"
RPMBUILD := rpmbuild-md5
#MOCKOPTS := --no-cleanup-after
@frimik
frimik / my_tasks.rake
Created February 1, 2013 00:02
Foreman CSV rake task example
namespace :my_tasks do
desc "CSV output"
task :csv => :environment do
require 'csv'
hosts = Host.all
CSV.open('/tmp/hosts.csv', 'w') do |writer|
hosts.each do |h|
row_array = [ h.name, h.operatingsystem, h.environment, h.model, h.facts_hash["memorysize"] ]
writer << row_array
@frimik
frimik / puppet-template-patterns.erb
Last active May 6, 2020 12:02
Puppet Template Patterns to remember.
## Check if variable is defined
# Replaces has_variable?(var) and if @var variations.
# include?() pattern from @Jan_vStone.
#
# scope.lookupvar return values for undefined variables:
# Puppet 3.x: nil
# Puppet 2.6.x: :undefined
# Puppet 2.7.x: :undefined
<% if ! [:undefined, nil, ''].include?(masquerade_address = scope.lookupvar('ftp::masquerade_address')) -%>
MasqueradeAddress <%= masquerade_address %>
@frimik
frimik / puppetmaster.conf
Created September 15, 2012 13:00
Apache mod_disk_cache + mod_expires for 30x to 400x faster puppet file_metadata* requests.
# Several other articles written about similar setups but
# this seems like the most simple one if you're already using
# Passenger under Apache
#
# http://paperairoplane.net/?p=380
# http://www.masterzen.fr/2010/03/21/more-puppet-offloading/
#
# Add %D for "The time taken to serve the request, in microseconds."
@frimik
frimik / proftpd-1.3.4b-CreateHome-noroot.patch
Created August 14, 2012 19:02
ProFTPD Ghetto patch: create homedirectories on a root squashed NFS root fails.
diff -up proftpd-1.3.4b/src/mkhome.c.CreateHome proftpd-1.3.4b/src/mkhome.c
--- proftpd-1.3.4b/src/mkhome.c.CreateHome 2012-08-14 20:35:35.992192002 +0200
+++ proftpd-1.3.4b/src/mkhome.c 2012-08-14 20:35:46.295209351 +0200
@@ -289,7 +289,7 @@ int create_home(pool *p, const char *hom
dst_mode = *((mode_t *) c->argv[1]);
- PRIVS_ROOT
+ PRIVS_USER
@frimik
frimik / gist:3240577
Created August 2, 2012 20:55
Foreman 0.4-stable Hosts Overview Patch - Add custom fields and links
diff -up ./app/models/host.rb.orig ./app/models/host.rb
--- ./app/models/host.rb.orig 2011-12-26 12:55:29.000000000 +0000
+++ ./app/models/host.rb 2012-01-03 10:23:08.650399870 +0000
@@ -16,7 +16,7 @@ class Host < Puppet::Rails::Host
class Jail < Safemode::Jail
allow :name, :diskLayout, :puppetmaster, :operatingsystem, :os, :environment, :ptable, :hostgroup, :url_for_boot,
- :params, :hostgroup, :domain, :ip, :mac, :shortname, :architecture
+ :params, :hostgroup, :domain, :ip, :mac, :shortname, :model
end
@frimik
frimik / gist:3211260
Created July 30, 2012 22:39
generate Foreman SHA1 hash
# Run the interactive ruby shell:
# paste in:
require 'digest/sha1'
def encrypt_password(pass)
password_salt = Digest::SHA1.hexdigest([Time.now, rand].join)
password_hash = Digest::SHA1.hexdigest([pass, password_salt].join)
end
@frimik
frimik / post-receive.email.sh
Created April 26, 2012 21:04
post-receive.email
#!/bin/bash
#
# IRC notification post-receive hook.
# Based on https://wiki.icinga.org/display/community/GIT+Commit+Bot
#
# Author: Mikael Fridh <frimik@gmail.com>
#
# This script pulls out the commit information and sends it to
# the Notify plugin in supybot via localhost 5050.
#