Class: KnifeSolo::Bootstraps::Linux

Inherits:
Base
  • Object
show all
Defined in:
lib/knife-solo/bootstraps/linux.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #run_pre_bootstrap_checks

Methods included from InstallCommands

#bootstrap!, #gem_install, #gem_options, #http_client_get_url, #install_ohai_hints, #omnibus_install, #omnibus_options

Methods included from Delegates

#chef_version, #prepare, #run_command, #stream_command, #ui

Constructor Details

This class inherits a constructor from KnifeSolo::Bootstraps::Base

Instance Method Details

#debianoid_gem_installObject



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/knife-solo/bootstraps/linux.rb', line 39

def debianoid_gem_install
  ui.msg "Updating apt caches..."
  run_command("sudo apt-get update")

  ui.msg "Installing required packages..."
  @packages = %w(ruby ruby-dev libopenssl-ruby irb
                 build-essential wget ssl-cert rsync)
  run_command <<-BASH
    sudo DEBIAN_FRONTEND=noninteractive apt-get --yes install #{package_list}
  BASH

  gem_install
end

#debianoid_omnibus_installObject



53
54
55
56
57
# File 'lib/knife-solo/bootstraps/linux.rb', line 53

def debianoid_omnibus_install
  run_command("sudo apt-get update")
  run_command("sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' --force-yes -f install rsync ca-certificates wget")
  omnibus_install
end

#distroObject



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/knife-solo/bootstraps/linux.rb', line 70

def distro
  return @distro if @distro
  @distro = case issue
  when %r{Debian GNU/Linux [6789]}
    {:type => (x86? ? "debianoid_omnibus" : "debianoid_gem")}
  when %r{Debian}
    {:type => "debianoid_gem"}
  when %r{Raspbian}
    {:type => "debianoid_gem"}
  when %r{Linux Mint}
    {:type => "debianoid_gem"}
  when %r{Ubuntu}i
    {:type => (x86? ? "debianoid_omnibus" : "debianoid_gem")}
  when %r{Linaro}
    {:type => "debianoid_gem"}
  when %r{CentOS}
    {:type => "yum_omnibus"}
  when %r{Amazon Linux}
    {:type => "yum_omnibus"}
  when %r{Red Hat Enterprise}
    {:type => "yum_omnibus"}
  when %r{Oracle Linux Server}
    {:type => "yum_omnibus"}
  when %r{Enterprise Linux Enterprise Linux Server}
    {:type => "yum_omnibus"}
  when %r{Fedora release}
    {:type => "yum_omnibus"}
  when %r{Scientific Linux}
    {:type => "yum_omnibus"}
  when %r{CloudLinux}
    {:type => "yum_omnibus"}
  when %r{SUSE Linux Enterprise Server 1[12]}
    {:type => "omnibus"}
  when %r{openSUSE 1[23]}, %r{openSUSE Leap 42}
    {:type => "zypper_omnibus"}
  when %r{This is \\n\.\\O \(\\s \\m \\r\) \\t}
    {:type => "emerge_gem"}
  when %r{Arch Linux}, %r{Manjaro Linux}
    {:type => "pacman"}
  else
    raise "Distribution not recognized. Please run again with `-VV` option and file an issue: https://github.com/matschaffer/knife-solo/issues"
  end
  Chef::Log.debug("Distro detection yielded: #{@distro}")
  @distro
end

#emerge_gem_installObject



27
28
29
30
31
# File 'lib/knife-solo/bootstraps/linux.rb', line 27

def emerge_gem_install
  ui.msg("Installing required packages...")
  run_command("sudo USE='-test' ACCEPT_KEYWORDS='~amd64' emerge -u chef")
  gem_install
end

#gem_packagesObject



23
24
25
# File 'lib/knife-solo/bootstraps/linux.rb', line 23

def gem_packages
  ['ruby-shadow']
end

#issueObject



3
4
5
6
7
8
9
10
11
12
# File 'lib/knife-solo/bootstraps/linux.rb', line 3

def issue
  commands = [
    'lsb_release -d -s',
    'cat /etc/redhat-release',
    'cat /etc/os-release',
    'cat /etc/issue'
  ]
  result = prepare.run_with_fallbacks(commands)
  result.success? ? result.stdout.strip : nil
end

#package_listObject



19
20
21
# File 'lib/knife-solo/bootstraps/linux.rb', line 19

def package_list
  @packages.join(' ')
end

#pacman_installObject



33
34
35
36
37
# File 'lib/knife-solo/bootstraps/linux.rb', line 33

def pacman_install
  ui.msg("Installing required packages...")
  run_command("sudo pacman -Sy ruby rsync make gcc --noconfirm")
  run_command("sudo gem install chef --no-user-install --no-rdoc --no-ri")
end

#x86?Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/knife-solo/bootstraps/linux.rb', line 14

def x86?
  machine = run_command('uname -m').stdout.strip
  %w{i686 x86 x86_64}.include?(machine)
end

#yum_omnibus_installObject



64
65
66
67
68
# File 'lib/knife-solo/bootstraps/linux.rb', line 64

def yum_omnibus_install
  run_command("sudo yum clean all")
  run_command("sudo yum -y install rsync")
  omnibus_install
end

#zypper_omnibus_installObject



59
60
61
62
# File 'lib/knife-solo/bootstraps/linux.rb', line 59

def zypper_omnibus_install
  run_command("sudo zypper --non-interactive install rsync")
  omnibus_install
end