8
@facts = Facter.to_hash
10
def configure_mcollective(server, mcollective_password, psk=nil)
12
pw = Passmakr.new(:phonemic, 8)
13
psk = pw.password[:string]
17
["server", "client"].each do |cfgfile|
18
templ = File.readlines("/etc/mcollective/#{cfgfile}.cfg.templ")
20
File.open("/etc/mcollective/#{cfgfile}.cfg", "w") do |f|
22
l.gsub!("@@hostname@@", @facts["hostname"])
23
l.gsub!("@@server@@", server)
24
l.gsub!("@@psk@@", psk)
25
l.gsub!("@@mcollective_password@@", mcollective_password)
32
puts("mcollective_psk=#{psk}") if @facts["mcollective"] == "server"
35
def configure_activemq(mcollective_password)
36
templ = File.readlines("/etc/activemq/activemq.xml.templ")
38
File.open("/etc/activemq/activemq.xml", "w") do |f|
40
l.gsub!("@@mcollective_password@@", mcollective_password)
47
if @facts.include?("mcollective")
48
mcollective_type = @facts["mcollective"]
50
if mcollective_type == "server"
51
puts("Configuring MCollective as a server...")
53
pw = Passmakr.new(:phonemic, 8)
54
mcollective_password = pw.password[:string]
56
puts("\n\n======= User Data for nodes ======")
57
puts("mcollective=#{@facts['ipaddress']}")
58
puts("mcollective_password=#{mcollective_password}")
60
configure_mcollective("localhost", mcollective_password)
61
configure_activemq(mcollective_password)
62
puts("==================================")
66
system("/etc/init.d/activemq restart")
68
puts("\nSleeping 10 seconds...")
71
system("cp /root/mcollective-plugins-read-only/agent/registration-monitor/registration.rb /usr/libexec/mcollective/mcollective/agent/")
73
puts("Starting MCollective....")
74
system("/etc/init.d/mcollective restart")
75
elsif mcollective_type =~ /\d+\.\d+\.\d+\.\d+/
76
unless @facts.include?("mcollective_password") && @facts.include?("mcollective_psk")
77
STDERR.puts("mcollective_password and mcollective_psk user data was not set")
81
puts("Configuring MCollective as a node with server @ #{mcollective_type}...")
83
mcollective_password = @facts["mcollective_password"]
84
mcollective_psk = @facts["mcollective_psk"]
86
configure_mcollective(mcollective_type, mcollective_password, mcollective_psk)
87
system("/etc/init.d/mcollective restart")
89
system("cp /usr/local/etc/mcollective-node.motd /etc/motd")
92
STDERR.puts("Please set mcollective=server|1.2.3.4 user data")