Class: Pupmin::Nodes

Inherits:
Object
  • Object
show all
Defined in:
lib/pupmin/nodes.rb

Overview

Node/Agent grouping and other informational helpers

Class Method Summary collapse

Class Method Details

.allObject

Simple list all nodes by fqdn values



5
6
7
8
9
10
11
12
# File 'lib/pupmin/nodes.rb', line 5

def self.all
  puppetdb = Pupmin::PuppetDB.build
  nodes = []
  puppetdb.request('facts', ['=', 'name', 'fqdn']).data.each do |x|
      nodes.push(x['value'])
  end
  nodes
end

.deactivate(certname) ⇒ Object



25
26
27
28
29
# File 'lib/pupmin/nodes.rb', line 25

def self.deactivate(certname)
  pdb = Pupmin::PuppetDB.build
  rsp = pdb.command('deactivate node', {'certname' => certname, 'producer_timestamp' => Pupmin::Util.make_timestamp}, 3)
  rsp.data
end

.random(num = 5) ⇒ Object

Display a random number of hosts



15
16
17
18
19
20
21
22
23
# File 'lib/pupmin/nodes.rb', line 15

def self.random(num = 5)
  rand_hosts = []
  all_hosts = all().shuffle!
  # hosts.shuffle!
  num.to_i.times do
    rand_hosts.push(all_hosts.shift)
  end
  rand_hosts
end