Class: Etoro::Utility::MCollective::Puppet
- Inherits:
-
RPC
- Object
- RPC
- Etoro::Utility::MCollective::Puppet
show all
- Defined in:
- lib/etoro/utility/mcollective/puppet.rb
Instance Attribute Summary
Attributes inherited from RPC
#current_host, #post_execute, #pre_execute
Instance Method Summary
collapse
Methods inherited from RPC
#class_filter, #fact_filter, #identity_filter, #initialize, #logging, #run, #sequential=, #sequential?, #validate
Instance Method Details
#check_run_status ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/etoro/utility/mcollective/puppet.rb', line 29
def check_run_status
@logger.info("Checking for Puppet run completion")
exit_flag = false
begin
timeout(@config[:timeout]) do
until @last_run_puppet == {}
@last_run_puppet.each do |host, lastrun|
run = rpcclient('puppet', :chomp => true)
run.identity_filter host
run.progress = false
results = run.last_run_summary
results.each do |result|
@logger.info("#{host} - Puppet last run: #{result[:data][:lastrun]}")
if lastrun != result[:data][:lastrun]
@logger.info("#{host} - run completed")
@last_run_puppet.delete(host)
if result[:data][:summary]['resources']['failed'] != 0
@logger.error("#{host} - Puppet run failed.")
exit_flag = true
end
else
@logger.info("#{host} - Puppet not complete")
end
end
end
sleep @config[:wait_between_checks]
end
end
rescue Timeout::Error
@logger.error("Puppet run timed out. Took more than #{@config[:timeout]} seconds")
exit_flag = true
end
if exit_flag == true then
@logger.error("Puppet run failed")
exit 1
end
end
|
#execute ⇒ Object
15
16
17
18
19
|
# File 'lib/etoro/utility/mcollective/puppet.rb', line 15
def execute
@mc.runonce
sleep @config[:wait_for_status]
self.check_run_status
end
|
#hosts ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/etoro/utility/mcollective/puppet.rb', line 21
def hosts
hosts = []
@last_run_puppet.each_key do |host|
hosts.push host
end
hosts
end
|
#status ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/etoro/utility/mcollective/puppet.rb', line 6
def status
@last_run_puppet = {}
@logger.info("Getting last puppet run information")
@mc.last_run_summary.each do |result|
@last_run_puppet[result[:sender]] = result[:data][:lastrun]
@logger.info("#{result[:sender]} - Puppet last run: #{result[:data][:lastrun]}")
end
end
|