Skip to content

Instantly share code, notes, and snippets.

View timogoebel's full-sized avatar

Timo Goebel timogoebel

View GitHub Profile
@timogoebel
timogoebel / create.rb
Created March 23, 2020 12:58
create a vm on vsphere with fog-vsphere
#!/usr/bin/env ruby
require 'fog'
require 'awesome_print'
require 'pry'
client = ::Fog::Compute.new(
:provider => 'vsphere',
:vsphere_username => 'xx',
:vsphere_password => 'xx',
# config/initializers/plugin_test.rb
# This initializer allows to run tests from Foreman plugins
# via rails 5 test runner
# Usage: bundle exec rails test --engine foreman_bootdisk ../foreman_bootdisk/test/unit/example_test.rb
require 'rails/test_unit/runner'
module Foreman
module RailsRunnerExtensions
def attach_before_load_options(opts)
super
@timogoebel
timogoebel / keybase.md
Created October 2, 2018 12:00
keybase.md

Keybase proof

I hereby claim:

  • I am timogoebel on github.
  • I am timogoebel (https://keybase.io/timogoebel) on keybase.
  • I have a public key whose fingerprint is 9E64 7A17 F33A AECF BFB2 24C2 2B7F 983B A6C2 1733

To claim this, I am signing this object:

@timogoebel
timogoebel / cloud-init-template.erb
Created April 26, 2018 12:13
vSphere Templates for Foreman & cloud-init with the foreman_userdata plugin
#cloud-config
hostname: <%= @host.name %>
fqdn: <%= @host %>
manage_etc_hosts: true
users: {}
runcmd:
- |
<%= indent(2) { snippet('puppet_setup customized', :variables => { :full_puppet_run => true }) } %>
phone_home:
# lib/foreman_solarwinds/engine.rb
config.autoload_paths += Dir["#{config.root}/app/services"]
config.autoload_paths += Dir["#{config.root}/app/services/concerns"]
config.to_prepare do
begin
::IPAM.send(:include, ForemanSolarwinds::IpamExtensions)
rescue StandardError => e
Rails.logger.warn "ForemanSolarwinds: skipping engine hook (#{e})"
end
@timogoebel
timogoebel / 0001-convert-skip-foreman-tasks-tables.patch
Created November 6, 2017 10:09
Skip Dynflow and Foreman Tasks tables when converting Foreman database from MySQL to Postgres
From 7d31b83218e0abad7fdaf4534c8b0629dbc944a3 Mon Sep 17 00:00:00 2001
From: Timo Goebel <mail@timogoebel.name>
Date: Mon, 6 Nov 2017 11:08:28 +0100
Subject: [PATCH] convert: skip foreman tasks tables
---
lib/tasks/convert.rake | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/tasks/convert.rake b/lib/tasks/convert.rake
@timogoebel
timogoebel / filelock.py
Created August 18, 2017 09:42
GFS2 filelock test
import time
import fcntl, struct
lockfile = open('/media/test/lockfile', 'w')
lockdata = struct.pack('hhllhh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)
while 1:
try:
fcntl.fcntl(lockfile.fileno(), fcntl.F_SETLK, lockdata)
print "I have the lock."
time.sleep(1)
@timogoebel
timogoebel / random_ip.rb
Created August 3, 2017 11:49
Generate a random IP in ruby
#!/usr/bin/env ruby
require 'ipaddr'
family = Socket::AF_INET
subnet_range = IPAddr.new("8.0.0.0/8", family).to_range
from = subnet_range.first(2).last
to = IPAddr.new(subnet_range.last.to_i - 2, family)
@timogoebel
timogoebel / physical.json
Created July 4, 2017 17:07
facter big servers
facter --json
{
"uptime_seconds": 14927393,
"architecture": "x86_64",
"virtual": "physical",
"is_virtual": false,
"augeasversion": "1.4.0",
"kernel": "Linux",
"is_rootserver": "true",
"blockdevice_sda_size": 4000787030016,
@timogoebel
timogoebel / Gemfile
Created May 9, 2017 09:53
vmware vsphere html5 console
source 'https://rubygems.org'
gem 'fog'
gem 'fog-vsphere'
gem 'awesome_print'
gem 'pry'