Class: DTK::NodeAgent::Installer
- Inherits:
-
Object
- Object
- DTK::NodeAgent::Installer
- Defined in:
- lib/dtk-node-agent/installer.rb
Constant Summary collapse
- CONFIG =
read configuration
eval(File.open(File.('../config/install.config', File.dirname(__FILE__))) {|f| f.read })
Class Method Summary collapse
Class Method Details
.run(argv) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/dtk-node-agent/installer.rb', line 16 def self.run(argv) require 'optparse' require 'fileutils' require 'dtk-node-agent/version' = parse(argv) unless Process.uid == 0 puts "dtk-node-agent must be started with root/sudo privileges." exit(1) end if @osfamily == 'debian' # set up apt and install packages shell "apt-get update --fix-missing" shell "apt-get install -y build-essential wget curl git" # install upgrades Array(CONFIG[:upgrades][:debian]).each do |package| shell "apt-get install -y #{package}" end shell "wget http://apt.puppetlabs.com/puppetlabs-release-#{@distcodename}.deb" puts "Installing Puppet Labs repository..." shell "dpkg -i puppetlabs-release-#{@distcodename}.deb" shell "apt-get update" shell "rm puppetlabs-release-#{@distcodename}.deb" # 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]}") when "6", "n/a" shell "rpm -ivh #{CONFIG[:puppetlabs_el6_rpm_repo]}" @osarch == 'X86_64' ? (shell "rpm -ivh #{CONFIG[:rpm_forge_el6_X86_64_repo]}") : (shell "rpm -ivh #{CONFIG[:rpm_forge_el6_i686_repo]}") shell "yum-config-manager --disable rpmforge-release" shell "yum-config-manager --enable rpmforge-extras" when "7" 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 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") end else puts "Unsuported OS for automatic agent installation. Exiting now..." exit(1) end puts "Installing additions for MCollective and Puppet..." install_additions end |