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
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
67
68
69
70
71
72
|
# File 'lib/etoro/utility/mcollective/puppet.rb', line 33
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 id is: #{result[:data][:lastrun]}")
if lastrun != result[:data][:lastrun]
@logger.info("#{host} - run completed")
@last_run_puppet.delete(host)
@logger.info("#{result[:data]}")
@logger.info("#{result[:data][:summary]['resources']['changed']} - changes were made on server.")
if result[:data][:summary]['resources']['failed'] != 0 || result[:data][:summary]['resources']['changed'] == 0
@logger.error("#{host} - Puppet run failed, check Event Viewer log.")
exit_flag = true
end
else
@logger.info("#{host} - Puppet not complete yet...")
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")
raise "Puppet run failed"
end
end
|
#execute ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/etoro/utility/mcollective/puppet.rb', line 15
def execute
if @config.has_key?(:tags)
@mc.runonce(:tags => @config[:tags])
else
@mc.runonce
end
sleep @config[:wait_for_status]
self.check_run_status
end
|
#hosts ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/etoro/utility/mcollective/puppet.rb', line 25
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
|