This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'foreman' | |
hosts = gethosts({"fact"=>{"domain"=>"lan", "puppetversion"=>"0.25.4"}}) | |
if hosts.nil? | |
puts "no hosts found" | |
else | |
puts hosts.join(" ") | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
module Puppet::Parser::Functions | |
# we parse the precedence here because the best place to specify | |
# it would be in site.pp but site.pp is only evaluated at startup | |
# so $fqdn etc would have no meaning there, this way it gets evaluated | |
# each run and has access to the right variables for that run | |
newfunction(:lookup, :type => :rvalue) do |args| | |
def var_to_fact str | |
while str =~ /%\{(.+?)\}/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This procedure must be followed after a puppetmaster has been created but before | |
# any clients have been created by that puppetmaster. It should be performed on | |
# the puppeteer in the directory where the openssl.cnf file is located. | |
# | |
# It requires the puppeteers id_rsa.pub to be in the authorized_keys template | |
# It requires that the puppetmaster service has been started at least once on | |
# new server | |
# It requires that the puppetmaster and httpd services have been stopped on the | |
# new server |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $Id: openssl.cnf,v 1.3 2007/06/03 18:15:11 jmates Exp $ | |
# | |
HOME = . | |
RANDFILE = $ENV::HOME/.rnd | |
[ ca ] | |
default_ca = CA_default | |
[ CA_default ] | |
dir = /var/lib/puppet/ssl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require "rubygems" | |
require 'net/http' | |
require "mechanize" | |
agent = Mechanize.new | |
url = "http://localhost:3000" | |
new_host_url = "#{url}/hosts/new" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this script via the runner app, e.g. | |
# ~foreman/scripts/runner -e production "thisscript" | |
dir = "/var/lib/puppet/reports" | |
User.current = User.find_by_login "admin" | |
Dir["#{dir}/*/*.yaml"].each do |yaml| | |
begin | |
print "importing #{yaml} " | |
puts Report.import File.read(yaml) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/extras/query/foreman.rb b/extras/query/foreman.rb | |
index dca1e25..703c0d0 100644 | |
--- a/extras/query/foreman.rb | |
+++ b/extras/query/foreman.rb | |
@@ -1,13 +1,22 @@ | |
require 'yaml' | |
-require 'net/http' | |
+require 'net/https' | |
+class NilClass; def closed?; true; end; end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require "rubygems" | |
require "rest_client" | |
require "json" | |
require "uri" | |
fqdn = ARGV[0] || raise("Must define a fqdn") | |
start = Time.now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User.current = User.find_by_login "admin" | |
old_name = "Puppet Master" | |
new_name = "common" | |
params = Hostgroup.find_by_name(old_name).group_parameters | |
old_params = params.collect{|p| [p.name, p.value]} | |
new_group = Hostgroup.find_by_name(new_name) | |
old_params.each do |param| | |
new_group.group_parameters << GroupParameter.create(:name => param[0], :value => param[1]) |