Skip to content

Instantly share code, notes, and snippets.

View ohadlevy's full-sized avatar

Ohad Levy ohadlevy

  • Red Hat
  • Israel
View GitHub Profile
@ohadlevy
ohadlevy / gist:902205
Created April 4, 2011 19:06
push facts with ssl support
#! /usr/bin/env ruby
#
# This scripts runs on remote puppetmasters that you wish to import their nodes facts into Foreman
# it uploads all of the new facts its encounter based on a control file which is stored in /tmp directory.
# This script can run in cron, e.g. once every minute
# if you run it on many puppetmasters at the same time, you might consider adding something like:
# sleep rand(10) # that not all PM hammers the DB at once.
# [email protected]
# puppet config dir
#!/usr/bin/ruby
require "rubygems"
require "rest_client"
require "json"
require "uri"
fqdn = ARGV[0] || raise("Must define a fqdn")
mac = ARGV[1] || raise("Must define a mac")
ip = ARGV[2] || raise("Must define a IP")
#! /usr/bin/ruby
# Query Foreman
# example usage:
#
# query for hosts
# ~~~~~~~~~~~~~~~
# $myhosts = foreman("hosts","facts.domain ~ lab")
# returns all hosts which have lab as part of their domain.
#
#! /bin/sh
curl -H "Accept:application/json" \
-k -u admin:changeme \
-d "_method=put" \
-d "architecture[name]=x86_64_new" \
http://0.0.0.0:3000/architectures/x86_64
@ohadlevy
ohadlevy / foreman-cli
Created May 27, 2011 08:27 — forked from bgupta/foreman-cli
foreman-cli
#!/usr/bin/env ruby
# Copyright (C) 2011 Vijay Brian Gupta [email protected]
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@ohadlevy
ohadlevy / gist:1011921
Created June 7, 2011 08:58
Foreman ENC script with cache and fact upload
#! /usr/bin/env ruby
SETTINGS = {
:url => "http://foreman",
:puppetdir => "/var/lib/puppet",
:timeout => 3,
}
### Do not edit below this line
#! /bin/sh
#
USER="admin"
PASS="changeme"
NAME=$1
KATELLO_HOSTGROUP="15"
curl -H "Accept:application/json" \
-k -u $USER:$PASS \
-d "host[name]=$NAME" -d "host[hostgroup_id]=$KATELLO_HOSTGROUP" \
@ohadlevy
ohadlevy / add_arguments.rb
Created October 28, 2011 09:28 — forked from alvagante/add_arguments.rb
Puppet add_arguments.rb
Puppet::Parser::Functions::newfunction(:add_arguments, :doc => <<-'ENDHEREDOC') do |args|
Converts a hash into a set of arguments that are added to the specified resource.
This function takes two arguments: a resource name, and a hash describing
a set of resources. The hash should be in the form `{title => {parameters} }`:
# A hash of arguments:
$myarguments = {
uid => '1330',
group => allstaff,
class tester {
class { "params": variable => $enc_foo }
}
@ohadlevy
ohadlevy / d
Created December 15, 2011 11:09
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e9af70b..6f66db2 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -63,7 +63,7 @@ module ApplicationHelper
def link_to_add_puppetclass klass, type
options = klass.name.size > 28 ? {:'data-original-title'=>klass.name, :rel=>'twipsy'} : {}
- content_tag(:span, truncate(klass.name, :length => 28), options).html_safe +
+ content_tag(:span, truncate(klass.name, :length => 28), options.merge(:'data-type' => type)).html_safe +