Sha256: 23d27924cc786dbd31140baf6358bb77c6349c998cb7ab1df369fe06bd7ca86b

Contents?: true

Size: 816 Bytes

Versions: 6

Compression:

Stored size: 816 Bytes

Contents

#!/usr/bin/env ruby
# This is a cgi script intended to be installed on 
# puppetmasters v2.6 and v2.7

require 'mysql'
require 'cgi'

cgi = CGI.new

if cgi['q'].empty?
        puts "Content-type: text/plain\n\n"
        puts "KO"
        exit(0)
end

DB_HOST = 'localhost'
DB_USER = ''
DB_PASS = ''
DB_FIELDS = %w(farm site country)

fqdn = cgi['q'].gsub(/[^-_0-9a-zA-z\.]/, '')
QUERY = "select #{DB_FIELDS.join(', ')} from node left join datacenter dc on node.site=dc.datacenter where nodename='#{fqdn}';"
DB = "puppet"


begin
    puts "Content-type: text/plain\n\n"
    con = Mysql.new DB_HOST, DB_USER, DB_PASS
    rs = con.query "use " + DB
    rs = con.query QUERY
    rs.each do |r|
        puts r.join(',')
    end

rescue Mysql::Error => e
    puts e.errno
    puts e.error

ensure
    con.close if con
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hieracles-0.0.6 tools/nodeinfo
hieracles-0.0.5 tools/nodeinfo
hieracles-0.0.4 tools/nodeinfo
hieracles-0.0.3 tools/nodeinfo
hieracles-0.0.2 bin/nodeinfo
hieracles-0.0.1 bin/nodeinfo