Class: PuppetRundeck
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- PuppetRundeck
- Defined in:
- lib/puppet-rundeck.rb
Class Attribute Summary collapse
-
.config_file ⇒ Object
Returns the value of attribute config_file.
-
.source ⇒ Object
Returns the value of attribute source.
-
.username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.config_file ⇒ Object
Returns the value of attribute config_file.
30 31 32 |
# File 'lib/puppet-rundeck.rb', line 30 def config_file @config_file end |
.source ⇒ Object
Returns the value of attribute source.
32 33 34 |
# File 'lib/puppet-rundeck.rb', line 32 def source @source end |
.username ⇒ Object
Returns the value of attribute username.
31 32 33 |
# File 'lib/puppet-rundeck.rb', line 31 def username @username end |
Class Method Details
.configure ⇒ Object
34 35 36 37 |
# File 'lib/puppet-rundeck.rb', line 34 def configure Puppet[:config] = PuppetRundeck.config_file Puppet.parse_config end |
Instance Method Details
#respond(required_tag = nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# 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 = Puppet::Resource::Catalog.find(n.name). else = Puppet::Face[:catalog, :current].find(n.name). end if ! required_tag.nil? next if ! .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, .join(',')].join(','))}" username="#{xml_escape(PuppetRundeck.username)}" hostname="#{xml_escape(facts["fqdn"])}"/> EOH end response_xml << "</project>" response_xml end |
#xml_escape(input) ⇒ Object
40 41 42 43 |
# 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 |