Class: PuppetPSSH::BaseCommand

Inherits:
Clamp::Command
  • Object
show all
Defined in:
lib/puppet-pssh.rb

Direct Known Subclasses

List, Run

Instance Method Summary collapse

Instance Method Details

#get_nodes(puppetmaster) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/puppet-pssh.rb', line 43

def get_nodes(puppetmaster)
  url = "#{use_ssl? ? 'https' : 'http'}://#{puppetmaster}:#{puppetmaster_port}/nodes"
  Log.debug "Puppet master host: #{puppetmaster}"
  Log.debug "Puppet master url: #{url}"

  nodes = []
  begin
    out = Excon.get url
    JSON.parse(out.body).each do |n| 
      next unless  n =~ /#{match}/
      nodes << n 
    end
  rescue TypeError => e
    raise Exception.new "Error retrieving node list from master host: #{puppetmaster}"
  rescue Excon::Errors::SocketError => e
    raise Exception.new "Could not connect to the puppet master host: #{puppetmaster}"
  end
  nodes
end

#master_urlObject



39
40
41
# File 'lib/puppet-pssh.rb', line 39

def master_url
  "#{use_ssl? ? 'https' : 'http'}://#{puppetmaster}:#{puppetmaster_port}/"
end