lib/dtk-node-agent/installer.rb in dtk-node-agent-0.7.7 vs lib/dtk-node-agent/installer.rb in dtk-node-agent-0.8.0
- old
+ new
@@ -1,5 +1,22 @@
+#
+# Copyright (C) 2010-2016 dtk contributors
+#
+# This file is part of the dtk project.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
module DTK
module NodeAgent
class Installer
require 'facter'
@@ -44,22 +61,14 @@
shell "wget #{logstash_forwarder_url}"
puts "Installing logstash-forwarder"
shell "dpkg -i #{logstash_forwarder_package}"
shell "apt-get update"
shell "rm puppetlabs-release-#{@distcodename}.deb #{logstash_forwarder_package}"
- # install mcollective
- puts "Installing MCollective..."
- shell "apt-get -y install mcollective"
# pin down the puppetlabs apt repo
FileUtils.cp("#{base_dir}/src/etc/apt/preferences.d/puppetlabs", "/etc/apt/preferences.d/puppetlabs")
elsif @osfamily == 'redhat'
shell "yum -y install yum-utils wget curl"
- # install upgrades
- Array(CONFIG[:upgrades][:redhat]).each do |package|
- shell "yum -y install #{package}"
- shell "yum -y update #{package}"
- end
case @osmajrelease
when "5"
shell "rpm -ivh #{CONFIG[:puppetlabs_el5_rpm_repo]}"
@osarch == 'X86_64' ? (shell "rpm -ivh #{CONFIG[:rpm_forge_el5_X86_64_repo]}") : (shell "rpm -ivh #{CONFIG[:rpm_forge_el5_i686_repo]}")
# 20xx is the major release naming pattern of Amazon Linux
@@ -72,13 +81,16 @@
shell "rpm -ivh #{CONFIG[:puppetlabs_el7_rpm_repo]}"
else
puts "#{@osname} #{@osmajrelease} is not supported. Exiting now..."
exit(1)
end
- puts "Installing MCollective..."
- shell "yum -y install mcollective"
shell "yum -y install git"
+ # install upgrades
+ Array(CONFIG[:upgrades][:redhat]).each do |package|
+ shell "yum -y install #{package}"
+ shell "yum -y update #{package}"
+ end
# install ec2-run-user-data init script
# but only if the machine is running on AWS
if `curl -m 5 -sI http://169.254.169.254/latest/meta-data/`.include? '200 OK'
FileUtils.cp("#{base_dir}/src/etc/init.d/ec2-run-user-data", "/etc/init.d/ec2-run-user-data") unless File.exist?("/etc/init.d/ec2-run-user-data")
set_init("ec2-run-user-data")
@@ -91,11 +103,11 @@
else
puts "Unsuported OS for automatic agent installation. Exiting now..."
exit(1)
end
- puts "Installing additions for MCollective and Puppet..."
+ puts "Installing additions Puppet..."
install_additions
puts "Installing DTK Arbiter"
install_arbiter
end
@@ -152,28 +164,16 @@
# create puppet group
shell "groupadd puppet" unless `grep puppet /etc/group`.include? "puppet"
# create necessary dirs
[ '/var/log/puppet/',
'/var/lib/puppet/lib/puppet/indirector',
- '/etc/puppet/modules',
- '/usr/share/mcollective/plugins/mcollective'
+ '/etc/puppet/modules'
].map! { |p| FileUtils.mkdir_p(p) unless File.directory?(p) }
# copy puppet libs
FileUtils.cp_r(Dir.glob("#{base_dir}/puppet_additions/puppet_lib_base/puppet/indirector/*"), "/var/lib/puppet/lib/puppet/indirector/")
# copy r8 puppet module
FileUtils.cp_r(Dir.glob("#{base_dir}/puppet_additions/modules/r8"), "/etc/puppet/modules")
- # copy mcollective plugins
- FileUtils.cp_r(Dir.glob("/usr/libexec/mcollective/mcollective/*"), "/usr/share/mcollective/plugins/mcollective") if File.directory?("/usr/libexec/mcollective/")
- mco_add_dir = "#{base_dir}/mcollective_additions"
- mco_plugin_dir = "#{mco_add_dir}/plugins/v#{CONFIG[:mcollective_version]}"
- FileUtils.cp_r(Dir.glob("#{mco_plugin_dir}/*"), "/usr/share/mcollective/plugins/mcollective")
- # copy mcollective config
- FileUtils.cp_r("#{mco_add_dir}/server.cfg", "/etc/mcollective", :remove_destination => true)
- # copy compatible mcollective init script
- FileUtils.cp_r("#{mco_add_dir}/#{@osfamily}.mcollective.init", "/etc/init.d/mcollective", :remove_destination => true)
- FileUtils.cp_r("#{mco_add_dir}/#{@osfamily}.mcollective.service", "/usr/lib/systemd/system/mcollective.service", :remove_destination => true) if File.exist?("/usr/lib/systemd/system/mcollective.service")
- set_init("mcollective")
end
def self.base_dir
File.expand_path('../..', File.dirname(__FILE__))
end
@@ -190,11 +190,16 @@
def self.install_arbiter
shell "git clone -b stable https://github.com/dtk/dtk-arbiter /usr/share/dtk/dtk-arbiter"
Dir.chdir "/usr/share/dtk/dtk-arbiter"
shell "bundle install --without development"
+ puts "Installing dtk-arbiter init script"
FileUtils.ln_sf("/usr/share/dtk/dtk-arbiter/etc/#{@osfamily}.dtk-arbiter.init", "/etc/init.d/dtk-arbiter")
set_init("dtk-arbiter")
+ puts "Installing dtk-arbiter monit config."
+ monit_cfg_path = (@osfamily == 'debian') ? "/etc/monit/conf.d" : "/etc/monit.d"
+ set_init("monit")
+ FileUtils.ln_sf("/usr/share/dtk/dtk-arbiter/etc/dtk-arbiter.monit", "#{monit_cfg_path}/dtk-arbiter")
end
end
end
-end
+end
\ No newline at end of file