class PuppetRundeck
Attributes
config_file[RW]
source[RW]
username[RW]
Public Class Methods
configure()
click to toggle source
# File lib/puppet-rundeck.rb, line 34 def configure Puppet[:config] = PuppetRundeck.config_file Puppet.parse_config end
Public Instance Methods
respond(required_tag=nil)
click to toggle source
# File lib/puppet-rundeck.rb, line 45 def respond(required_tag=nil) response['Content-Type'] = 'text/xml' response_xml = %Q(<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE project PUBLIC "-//DTO Labs Inc.//DTD Resources Document 1.0//EN" "project.dtd">\n<project>\n) # Fix for 2.6 to 2.7 indirection difference Puppet[:clientyamldir] = "$yamldir" if Puppet::Node.respond_to? :terminus_class Puppet::Node.terminus_class = :yaml nodes = Puppet::Node.search("*") else Puppet::Node.indirection.terminus_class = :yaml nodes = Puppet::Node.indirection.search("*") end Puppet::Node.indirection.terminus_class = :plain nodes.each do |n| if Puppet::Node::Facts.respond_to? :find tags = Puppet::Resource::Catalog.find(n.name).tags else tags = Puppet::Face[:catalog, :current].find(n.name).tags end if ! required_tag.nil? next if ! tags.include? required_tag end facts = n.parameters os_family = facts["kernel"] =~ /windows/i ? 'windows' : 'unix' response_xml << <<-EOH <node name="#{xml_escape(n.name)}" type="Node" description="#{xml_escape(n.name)}" osArch="#{xml_escape(facts["kernel"])}" osFamily="#{xml_escape(os_family)}" osName="#{xml_escape(facts["operatingsystem"])}" osVersion="#{xml_escape(facts["operatingsystemrelease"])}" tags="#{xml_escape([n.environment, tags.join(',')].join(','))}" username="#{xml_escape(PuppetRundeck.username)}" hostname="#{xml_escape(facts["fqdn"])}"/> EOH end response_xml << "</project>" response_xml end
xml_escape(input)
click to toggle source
# File lib/puppet-rundeck.rb, line 40 def xml_escape(input) # don't know if is string, so convert to string first, then to XML escaped text. return input.to_s.fast_xs end