Module: Beaker::DSL::InstallUtils::FOSSUtils
- Includes:
- AIODefaults, FOSSDefaults, PuppetUtils
- Included in:
- Beaker::DSL::InstallUtils
- Defined in:
- lib/beaker/dsl/install_utils/foss_utils.rb
Overview
This module contains methods to install FOSS puppet from various sources
To mix this is into a class you need the following:
- a method hosts that yields any hosts implementing Host's interface to act upon.
- a method options that provides an options hash, see Options::OptionsHash
- the module Roles that provides access to the various hosts implementing Host's interface to act upon
- the module Wrappers the provides convenience methods for Command creation
Constant Summary collapse
- SourcePath =
The default install path
"/opt/puppet-git-repos"- GitURI =
A regex to know if the uri passed is pointing to a git repo
%r{^(git|https?|file)://|^git@|^gitmirror@}- GitHubSig =
Github's ssh signature for cloning via ssh
'github.com,207.97.227.239 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=='
Constants included from FOSSDefaults
Beaker::DSL::InstallUtils::FOSSDefaults::FOSS_DEFAULTS, Beaker::DSL::InstallUtils::FOSSDefaults::FOSS_DEFAULT_DOWNLOAD_URLS
Constants included from AIODefaults
Instance Method Summary collapse
- #compute_puppet_msi_name(host, opts) ⇒ Object private
-
#configure_foss_defaults_on(hosts) ⇒ Object
Set defaults and PATH for these hosts to be either foss or aio, have host == aio for aio settings, defaults to foss.
-
#configure_puppet(opts = {}) ⇒ Object
deprecated
Deprecated.
Use #configure_puppet_on instead.
-
#configure_puppet_on(hosts, opts = {}) ⇒ Object
Configure puppet.conf on the given host(s) based upon a provided hash.
-
#extract_repo_info_from(uri) ⇒ Hash{Symbol=>String}
Returns a hash containing the project name, repository path, and revision (defaults to HEAD).
-
#find_git_repo_versions(host, path, repository) ⇒ Hash
Executes git describe on [host] and returns a Hash with the key of [repository[:name]] and value of the output from git describe.
- #install_a_puppet_msi_on(hosts, opts) ⇒ Object private
-
#install_cert_on_windows(host, cert_name, cert) ⇒ Object
This method will install a pem file certifcate on a windows host.
- #install_from_git(host, path, repository) ⇒ Object
-
#install_packages_from_local_dev_repo(host, package_name) ⇒ Object
Installs packages from the local development repository on the given host.
-
#install_puppet(opts = {}) ⇒ Object
deprecated
Deprecated.
Use #install_puppet_on instead.
-
#install_puppet_agent_dev_repo_on(hosts, opts) ⇒ Object
(also: #install_puppetagent_dev_repo)
Install development repo of the puppet-agent on the given host(s).
-
#install_puppet_agent_from_dmg_on(hosts, opts) ⇒ Object
private
Installs puppet-agent and dependencies from dmg on provided host(s).
-
#install_puppet_agent_from_msi_on(hosts, opts) ⇒ Object
Installs Puppet Agent and dependencies from msi on provided host(s).
-
#install_puppet_agent_on(hosts, opts) ⇒ Object
Install Puppet Agent based on specified hosts using provided options.
-
#install_puppet_agent_pe_promoted_repo_on(hosts, opts) ⇒ Object
Install shared repo of the puppet-agent on the given host(s).
-
#install_puppet_from_deb_on(hosts, opts) ⇒ Object
(also: #install_puppet_from_deb)
private
Installs Puppet and dependencies from deb on provided host(s).
-
#install_puppet_from_dmg_on(hosts, opts) ⇒ Object
(also: #install_puppet_from_dmg)
private
Installs Puppet and dependencies from dmg on provided host(s).
-
#install_puppet_from_freebsd_ports_on(hosts, opts) ⇒ Object
(also: #install_puppet_from_freebsd_ports)
private
Installs Puppet and dependencies from FreeBSD ports.
-
#install_puppet_from_gem_on(hosts, opts) ⇒ Object
(also: #install_puppet_from_gem, #install_puppet_agent_from_gem_on)
private
Installs Puppet and dependencies from gem on provided host(s).
-
#install_puppet_from_msi_on(hosts, opts) ⇒ Object
(also: #install_puppet_from_msi)
Installs Puppet and dependencies from msi on provided host(s).
-
#install_puppet_from_openbsd_packages_on(hosts, opts) ⇒ Object
private
Installs Puppet and dependencies from OpenBSD packages.
-
#install_puppet_from_rpm_on(hosts, opts) ⇒ Object
(also: #install_puppet_from_rpm)
private
Installs Puppet and dependencies using rpm on provided host(s).
-
#install_puppet_on(hosts, opts = {}) ⇒ Object
Install FOSS based on specified hosts using provided options.
-
#install_puppetlabs_dev_repo(host, package_name, build_version, repo_configs_dir = 'tmp/repo_configs', opts = options) ⇒ Object
Install development repository on the given host.
-
#install_puppetlabs_release_repo_on(hosts, repo = nil, opts = options) ⇒ Object
(also: #install_puppetlabs_release_repo)
Install official puppetlabs release repository configuration on host(s).
Methods included from PuppetUtils
#add_puppet_paths_on, #configure_defaults_on, #construct_puppet_path, #remove_defaults_on, #remove_puppet_paths_on
Methods included from FOSSDefaults
#add_foss_defaults_on, #add_platform_foss_defaults, #remove_foss_defaults_on, #remove_platform_foss_defaults
Methods included from AIODefaults
#add_aio_defaults_on, #add_platform_aio_defaults, #remove_aio_defaults_on, #remove_platform_aio_defaults
Instance Method Details
#compute_puppet_msi_name(host, opts) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 500 def compute_puppet_msi_name(host, opts) version = opts[:version] install_32 = host['install_32'] || opts['install_32'] less_than_3_dot_7 = version && version_is_less(version, '3.7') # If there's no version declared, install the latest in the 3.x series if not version if !host.is_x86_64? || install_32 host['dist'] = 'puppet-latest' else host['dist'] = 'puppet-x64-latest' end # Install Puppet 3.x with the x86 installer if: # - we are on puppet < 3.7, or # - we are less than puppet 4.0 and on an x86 host, or # - we have install_32 set on host or globally # Install Puppet 3.x with the x64 installer if: # - we are otherwise trying to install Puppet 3.x on a x64 host elsif less_than_3_dot_7 or not host.is_x86_64? or install_32 host['dist'] = "puppet-#{version}" elsif host.is_x86_64? host['dist'] = "puppet-#{version}-x64" else raise "I don't understand how to install Puppet version: #{version}" end end |
#configure_foss_defaults_on(hosts) ⇒ Object
Set defaults and PATH for these hosts to be either foss or aio, have host == aio for aio settings, defaults to foss.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 36 def configure_foss_defaults_on( hosts ) block_on hosts do |host| if (not_controller(host) && host[:version] && (not version_is_less(host[:version], '4.0'))) \ or (host['type'] && host['type'] =~ /aio/) # add aio defaults to host add_aio_defaults_on(host) # provide a sane default here for puppetservice host['puppetservice'] ||= 'puppetserver' else add_foss_defaults_on(host) end # add pathing env add_puppet_paths_on(host) end end |
#configure_puppet(opts = {}) ⇒ Object
Use #configure_puppet_on instead.
339 340 341 342 343 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 339 def configure_puppet(opts={}) hosts.each do |host| configure_puppet_on(host,opts) end end |
#configure_puppet_on(hosts, opts = {}) ⇒ Object
Configure puppet.conf on the given host(s) based upon a provided hash
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 369 def configure_puppet_on(hosts, opts = {}) block_on hosts do |host| if host['platform'] =~ /windows/ puppet_conf = host.puppet['config'] conf_data = '' opts.each do |section,| conf_data << "[#{section}]`n" .each do |option,value| conf_data << "#{option}=#{value}`n" end conf_data << "`n" end on host, powershell("\$text = \\\"#{conf_data}\\\"; Set-Content -path '#{puppet_conf}' -value \$text") else puppet_conf = host.puppet['config'] conf_data = '' opts.each do |section,| conf_data << "[#{section}]\n" .each do |option,value| conf_data << "#{option}=#{value}\n" end conf_data << "\n" end on host, "echo \"#{conf_data}\" > #{puppet_conf}" end end end |
#extract_repo_info_from(uri) ⇒ Hash{Symbol=>String}
Returns a hash containing the project name, repository path, and revision (defaults to HEAD)
70 71 72 73 74 75 76 77 78 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 70 def extract_repo_info_from uri require 'pathname' project = {} repo, rev = uri.split('#', 2) project[:name] = Pathname.new(repo).basename('.git').to_s project[:path] = repo project[:rev] = rev || 'HEAD' return project end |
#find_git_repo_versions(host, path, repository) ⇒ Hash
This requires the helper methods:
- Helpers#on
Returns Executes git describe on [host] and returns a Hash with the key of [repository[:name]] and value of the output from git describe.
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 112 def find_git_repo_versions host, path, repository logger.notify("\n * Grab version for #{repository[:name]}") version = {} on host, "cd #{path}/#{repository[:name]} && " + "git describe || true" do version[repository[:name]] = stdout.chomp end version end |
#install_a_puppet_msi_on(hosts, opts) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 560 def install_a_puppet_msi_on(hosts, opts) block_on hosts do |host| link = "#{opts[:win_download_url]}/#{host['dist']}.msi" if not link_exists?( link ) raise "Puppet #{version} at #{link} does not exist!" end if host.is_cygwin? dest = "#{host['dist']}.msi" on host, "curl -O #{link}" #Because the msi installer doesn't add Puppet to the environment path #Add both potential paths for simplicity #NOTE - this is unnecessary if the host has been correctly identified as 'foss' during set up puppetbin_path = "\"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin\":\"/cygdrive/c/Program Files/Puppet Labs/Puppet/bin\"" on host, %Q{ echo 'export PATH=$PATH:#{puppetbin_path}' > /etc/bash.bashrc } on host, "cmd /C 'start /w msiexec.exe /qn /i #{dest}'" else dest = "C:\\Windows\\Temp\\#{host['dist']}.msi" on host, powershell("$webclient = New-Object System.Net.WebClient; $webclient.DownloadFile('#{link}','#{dest}')") on host, "start /w msiexec.exe /qn /i #{dest}" end configure_foss_defaults_on( host ) if not host.is_cygwin? host.mkdir_p host['distmoduledir'] end end end |
#install_cert_on_windows(host, cert_name, cert) ⇒ Object
This method will install a pem file certifcate on a windows host
1232 1233 1234 1235 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 1232 def install_cert_on_windows(host, cert_name, cert) create_remote_file(host, "C:\\Windows\\Temp\\#{cert_name}.pem", cert) on host, "certutil -v -addstore Root C:\\Windows\\Temp\\#{cert_name}.pem" end |
#install_from_git(host, path, repository) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 126 def install_from_git host, path, repository name = repository[:name] repo = repository[:path] rev = repository[:rev] depth = repository[:depth] depth_branch = repository[:depth_branch] target = "#{path}/#{name}" if (depth_branch.nil?) depth_branch = rev end clone_cmd = "git clone #{repo} #{target}" if (depth) clone_cmd = "git clone --branch #{depth_branch} --depth #{depth} #{repo} #{target}" end logger.notify("\n * Clone #{repo} if needed") on host, "test -d #{path} || mkdir -p #{path}" on host, "test -d #{target} || #{clone_cmd}" logger.notify("\n * Update #{name} and check out revision #{rev}") commands = ["cd #{target}", "remote rm origin", "remote add origin #{repo}", "fetch origin +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/*", "clean -fdx", "checkout -f #{rev}"] on host, commands.join(" && git ") logger.notify("\n * Install #{name} on the system") # The solaris ruby IPS package has bindir set to /usr/ruby/1.8/bin. # However, this is not the path to which we want to deliver our # binaries. So if we are using solaris, we have to pass the bin and # sbin directories to the install.rb install_opts = '' install_opts = '--bindir=/usr/bin --sbindir=/usr/sbin' if host['platform'].include? 'solaris' on host, "cd #{target} && " + "if [ -f install.rb ]; then " + "ruby ./install.rb #{install_opts}; " + "else true; fi" end |
#install_packages_from_local_dev_repo(host, package_name) ⇒ Object
This method only works on redhat-like and debian-like hosts.
This method is paired to be run directly after #install_puppetlabs_dev_repo
Installs packages from the local development repository on the given host
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 1008 def install_packages_from_local_dev_repo( host, package_name ) if host['platform'] =~ /debian|ubuntu|cumulus/ find_filename = '*.deb' find_command = 'dpkg -i' elsif host['platform'] =~ /fedora|el|centos/ find_filename = '*.rpm' find_command = 'rpm -ivh' else raise "No repository installation step for #{host['platform']} yet..." end find_command = "find /root/#{package_name} -type f -name '#{find_filename}' -exec #{find_command} {} \\;" on host, find_command configure_foss_defaults_on( host ) end |
#install_puppet(opts = {}) ⇒ Object
Use #install_puppet_on instead.
174 175 176 177 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 174 def install_puppet(opts = {}) #send in the global hosts! install_puppet_on(hosts, opts) end |
#install_puppet_agent_dev_repo_on(hosts, opts) ⇒ Object Also known as: install_puppetagent_dev_repo
on windows, the :ruby_arch host parameter can determine in addition
Install development repo of the puppet-agent on the given host(s). Downloaded from location of the form DEV_BUILDS_URL/puppet-agent/AGENT_VERSION/repos
to other settings whether the 32 or 64bit install is used
1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 1054 def install_puppet_agent_dev_repo_on( hosts, opts ) opts[:puppet_agent_version] ||= opts[:version] #backward compatability if not opts[:puppet_agent_version] raise "must provide :puppet_agent_version (puppet-agent version) for install_puppet_agent_dev_repo_on" end block_on hosts do |host| variant, version, arch, codename = host['platform'].to_array opts = FOSS_DEFAULT_DOWNLOAD_URLS.merge(opts) opts[:download_url] = "#{opts[:dev_builds_url]}/puppet-agent/#{ opts[:puppet_agent_sha] || opts[:puppet_agent_version] }/repos/" opts[:copy_base_local] ||= File.join('tmp', 'repo_configs') opts[:copy_dir_external] ||= File.join('/', 'root') opts[:puppet_collection] ||= 'PC1' host[:type] = 'aio' #we are installing agent, so we want aio type release_path = opts[:download_url] variant, version, arch, codename = host['platform'].to_array copy_dir_local = File.join(opts[:copy_base_local], variant) onhost_copy_base = opts[:copy_dir_external] case variant when /^(fedora|el|centos|sles)$/ variant = ((variant == 'centos') ? 'el' : variant) release_path << "#{variant}/#{version}/#{opts[:puppet_collection]}/#{arch}" release_file = "puppet-agent-#{opts[:puppet_agent_version]}-1.#{variant}#{version}.#{arch}.rpm" when /^(debian|ubuntu|cumulus)$/ if arch == 'x86_64' arch = 'amd64' end release_path << "deb/#{codename}/#{opts[:puppet_collection]}" release_file = "puppet-agent_#{opts[:puppet_agent_version]}-1#{codename}_#{arch}.deb" when /^windows$/ release_path << 'windows' onhost_copy_base = '`cygpath -smF 35`/' is_config_32 = host['ruby_arch'] == 'x86' || host['install_32'] || opts['install_32'] should_install_64bit = host.is_x86_64? && !is_config_32 # only install 64bit builds if # - we do not have install_32 set on host # - we do not have install_32 set globally arch_suffix = should_install_64bit ? '64' : '86' release_file = "puppet-agent-x#{arch_suffix}.msi" when /^osx$/ onhost_copy_base = File.join('/var', 'root') mac_pkg_name = "puppet-agent-#{opts[:puppet_agent_version]}" release_path << "/apple/#{opts[:puppet_collection]}" release_file = "#{mac_pkg_name}-#{variant}-#{version}-x86_64.dmg" else raise "No repository installation step for #{variant} yet..." end onhost_copied_file = File.join(onhost_copy_base, release_file) fetch_http_file( release_path, release_file, copy_dir_local) scp_to host, File.join(copy_dir_local, release_file), onhost_copy_base case variant when /^(fedora|el|centos|sles)$/ on host, "rpm -ivh #{onhost_copied_file}" when /^(debian|ubuntu|cumulus)$/ on host, "dpkg -i --force-all #{onhost_copied_file}" on host, "apt-get update" when /^windows$/ result = on host, "echo #{onhost_copied_file}" onhost_copied_file = result.raw_output.chomp on host, Command.new("start /w #{onhost_copied_file}", [], { :cmdexe => true }) when /^osx$/ host.install_package("#{mac_pkg_name}*") end configure_foss_defaults_on( host ) end end |
#install_puppet_agent_from_dmg_on(hosts, opts) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Installs puppet-agent and dependencies from dmg on provided host(s).
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 677 def install_puppet_agent_from_dmg_on(hosts, opts) opts[:puppet_collection] ||= 'PC1' opts[:puppet_collection] = opts[:puppet_collection].upcase #needs to be upcase, more lovely consistency block_on hosts do |host| host[:type] = 'aio' #we are installing agent, so we want aio type variant, version, arch, codename = host['platform'].to_array agent_version = opts[:puppet_agent_version] || 'latest' pkg_name = "puppet-agent-#{agent_version}*" if agent_version == 'latest' dmg_name = "puppet-agent-#{agent_version}.dmg" on host, "curl -O #{opts[:mac_download_url]}/#{dmg_name}" else dmg_name = "puppet-agent-#{agent_version}-osx-#{version}-x86_64.dmg" on host, "curl -O #{opts[:mac_download_url]}/#{opts[:puppet_collection]}/#{dmg_name}" end host.install_package(pkg_name) configure_foss_defaults_on( host ) end end |
#install_puppet_agent_from_msi_on(hosts, opts) ⇒ Object
on windows, the :ruby_arch host parameter can determine in addition
Installs Puppet Agent and dependencies from msi on provided host(s).
to other settings whether the 32 or 64bit install is used
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 540 def install_puppet_agent_from_msi_on(hosts, opts) block_on hosts do |host| host[:type] = 'aio' #we are installing agent, so we want aio type is_config_32 = true == (host['ruby_arch'] == 'x86') || host['install_32'] || opts['install_32'] should_install_64bit = host.is_x86_64? && !is_config_32 arch = should_install_64bit ? 'x64' : 'x86' # If we don't specify a version install the latest MSI for puppet-agent if opts[:puppet_agent_version] host['dist'] = "puppet-agent-#{opts[:puppet_agent_version]}-#{arch}" else host['dist'] = "puppet-agent-#{arch}-latest" end install_a_puppet_msi_on(host, opts) end end |
#install_puppet_agent_on(hosts, opts) ⇒ Object
This will attempt to add a repository for apt.puppetlabs.com on Debian, Ubuntu, or Cumulus machines, or yum.puppetlabs.com on EL or Fedora machines, then install the package 'puppet-agent'.
Install Puppet Agent based on specified hosts using provided options
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 296 def install_puppet_agent_on(hosts, opts) opts = FOSS_DEFAULT_DOWNLOAD_URLS.merge(opts) opts[:puppet_collection] ||= 'pc1' #hi! i'm case sensitive! be careful! opts[:puppet_agent_version] ||= opts[:version] #backwards compatability with old parameter name block_on hosts do |host| host[:type] = 'aio' #we are installing agent, so we want aio type case host['platform'] when /el-4|sles/ # pe-only agent, get from dev repo logger.warn("install_puppet_agent_on for pe-only platform #{host['platform']} - use install_puppet_agent_pe_promoted_repo_on") when /el-|fedora/ install_puppetlabs_release_repo(host, opts[:puppet_collection]) if opts[:puppet_agent_version] host.install_package("puppet-agent-#{opts[:puppet_agent_version]}") else host.install_package('puppet-agent') end when /debian|ubuntu|cumulus/ install_puppetlabs_release_repo(host, opts[:puppet_collection]) if opts[:puppet_agent_version] host.install_package("puppet-agent=#{opts[:puppet_agent_version]}-1#{host['platform'].codename}") else host.install_package('puppet-agent') end when /windows/ install_puppet_agent_from_msi_on(host, opts) when /osx/ install_puppet_agent_from_dmg_on(host, opts) else if opts[:default_action] == 'gem_install' opts[:version] = opts[:puppet_gem_version] install_puppet_from_gem_on(host, opts) on host, "echo '' >> #{host.puppet['hiera_config']}" else raise "install_puppet_agent_on() called for unsupported " + "platform '#{host['platform']}' on '#{host.name}'" end end end end |
#install_puppet_agent_pe_promoted_repo_on(hosts, opts) ⇒ Object
on windows, the :ruby_arch host parameter can determine in addition
Install shared repo of the puppet-agent on the given host(s). Downloaded from location of the form PE_PROMOTED_BUILDS_URL/PE_VER/puppet-agent/AGENT_VERSION/repo
to other settings whether the 32 or 64bit install is used
1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 1149 def install_puppet_agent_pe_promoted_repo_on( hosts, opts ) opts[:puppet_agent_version] ||= 'latest' block_on hosts do |host| pe_ver = host[:pe_ver] || opts[:pe_ver] || '4.0.0-rc1' variant, version, arch, codename = host['platform'].to_array opts = FOSS_DEFAULT_DOWNLOAD_URLS.merge(opts) opts[:download_url] = "#{opts[:pe_promoted_builds_url]}/puppet-agent/#{ pe_ver }/#{ opts[:puppet_agent_version] }/repos" opts[:copy_base_local] ||= File.join('tmp', 'repo_configs') opts[:copy_dir_external] ||= File.join('/', 'root') opts[:puppet_collection] ||= 'PC1' host[:type] = 'aio' #we are installing agent, so we want aio type release_path = opts[:download_url] variant, version, arch, codename = host['platform'].to_array copy_dir_local = File.join(opts[:copy_base_local], variant) onhost_copy_base = opts[:copy_dir_external] case variant when /^(fedora|el|centos|sles)$/ variant = ((variant == 'centos') ? 'el' : variant) release_file = "/repos/#{variant}/#{version}/#{opts[:puppet_collection]}/#{arch}/puppet-agent-*.rpm" download_file = "puppet-agent-#{variant}-#{version}-#{arch}.tar.gz" when /^(debian|ubuntu|cumulus)$/ if arch == 'x86_64' arch = 'amd64' end release_file = "/repos/apt/#{codename}/pool/#{opts[:puppet_collection]}/p/puppet-agent/puppet-agent*#{arch}.deb" download_file = "puppet-agent-#{variant}-#{version}-#{arch}.tar.gz" when /^windows$/ onhost_copy_base = '`cygpath -smF 35`/' is_config_32 = host['ruby_arch'] == 'x86' || host['install_32'] || opts['install_32'] should_install_64bit = host.is_x86_64? && !is_config_32 # only install 64bit builds if # - we do not have install_32 set on host # - we do not have install_32 set globally arch_suffix = should_install_64bit ? '64' : '86' release_path += "/windows/" release_file = "/puppet-agent-x#{arch_suffix}.msi" download_file = "puppet-agent-x#{arch_suffix}.msi" when /^osx$/ onhost_copy_base = File.join('/var', 'root') release_file = "/repos/apple/#{opts[:puppet_collection]}/puppet-agent-*" download_file = "puppet-agent-#{variant}-#{version}.tar.gz" else raise "No pe-promoted installation step for #{variant} yet..." end onhost_copied_download = File.join(onhost_copy_base, download_file) onhost_copied_file = File.join(onhost_copy_base, release_file) fetch_http_file( release_path, download_file, copy_dir_local) scp_to host, File.join(copy_dir_local, download_file), onhost_copy_base case variant when /^(fedora|el|centos)$/ on host, "tar -zxvf #{onhost_copied_download} -C #{onhost_copy_base}" on host, "yum --nogpgcheck localinstall -y #{onhost_copied_file}" when /^(sles)$/ on host, "tar -zxvf #{onhost_copied_download} -C #{onhost_copy_base}" on host, "rpm -ihv #{onhost_copied_file}" when /^(debian|ubuntu|cumulus)$/ on host, "tar -zxvf #{onhost_copied_download} -C #{onhost_copy_base}" on host, "dpkg -i --force-all #{onhost_copied_file}" on host, "apt-get update" when /^windows$/ result = on host, "echo #{onhost_copied_file}" onhost_copied_file = result.raw_output.chomp on host, Command.new("start /w #{onhost_copied_file}", [], { :cmdexe => true }) when /^osx$/ on host, "tar -zxvf #{onhost_copied_download} -C #{onhost_copy_base}" # move to better location on host, "mv #{onhost_copied_file}.dmg ." host.install_package("puppet-agent-*") end configure_foss_defaults_on( host ) end end |
#install_puppet_from_deb_on(hosts, opts) ⇒ Object Also known as: install_puppet_from_deb
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Installs Puppet and dependencies from deb on provided host(s).
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 440 def install_puppet_from_deb_on( hosts, opts ) block_on hosts do |host| install_puppetlabs_release_repo(host) if opts[:facter_version] host.install_package("facter=#{opts[:facter_version]}-1puppetlabs1") end if opts[:hiera_version] host.install_package("hiera=#{opts[:hiera_version]}-1puppetlabs1") end if opts[:version] host.install_package("puppet-common=#{opts[:version]}-1puppetlabs1") host.install_package("puppet=#{opts[:version]}-1puppetlabs1") else host.install_package('puppet') end configure_foss_defaults_on( host ) end end |
#install_puppet_from_dmg_on(hosts, opts) ⇒ Object Also known as: install_puppet_from_dmg
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Installs Puppet and dependencies from dmg on provided host(s).
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 631 def install_puppet_from_dmg_on( hosts, opts ) block_on hosts do |host| # install puppet-agent if puppet version > 4.0 OR not puppet version is provided if (opts[:version] && !version_is_less(opts[:version], '4.0.0')) || !opts[:version] if opts[:puppet_agent_version].nil? raise "You must specify the version of puppet-agent you " + "want to install if you want to install Puppet 4.0 " + "or greater on OSX" end install_puppet_agent_from_dmg_on(host, opts) else puppet_ver = opts[:version] || 'latest' facter_ver = opts[:facter_version] || 'latest' hiera_ver = opts[:hiera_version] || 'latest' if [puppet_ver, facter_ver, hiera_ver].include?(nil) raise "You need to specify versions for OSX host\n eg. install_puppet({:version => '3.6.2',:facter_version => '2.1.0',:hiera_version => '1.3.4',})" end on host, "curl -O #{opts[:mac_download_url]}/puppet-#{puppet_ver}.dmg" on host, "curl -O #{opts[:mac_download_url]}/facter-#{facter_ver}.dmg" on host, "curl -O #{opts[:mac_download_url]}/hiera-#{hiera_ver}.dmg" host.install_package("puppet-#{puppet_ver}") host.install_package("facter-#{facter_ver}") host.install_package("hiera-#{hiera_ver}") configure_foss_defaults_on( host ) end end end |
#install_puppet_from_freebsd_ports_on(hosts, opts) ⇒ Object Also known as: install_puppet_from_freebsd_ports
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Installs Puppet and dependencies from FreeBSD ports
602 603 604 605 606 607 608 609 610 611 612 613 614 615 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 602 def install_puppet_from_freebsd_ports_on( hosts, opts ) if (opts[:version]) logger.warn "If you wish to choose a specific Puppet version, use `install_puppet_from_gem_on('~> 3.*')`" end block_on hosts do |host| if host['platform'] =~ /freebsd-9/ host.install_package("puppet") else host.install_package("sysutils/puppet") end end end |
#install_puppet_from_gem_on(hosts, opts) ⇒ Object Also known as: install_puppet_from_gem, install_puppet_agent_from_gem_on
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Installs Puppet and dependencies from gem on provided host(s)
733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 733 def install_puppet_from_gem_on( hosts, opts ) block_on hosts do |host| # There are a lot of special things to do for Solaris and Solaris 10. # This is easier than checking host['platform'] every time. is_solaris10 = host['platform'] =~ /solaris-10/ is_solaris = host['platform'] =~ /solaris/ # Hosts may be provisioned with csw but pkgutil won't be in the # PATH by default to avoid changing the behavior for Puppet's tests if is_solaris10 on host, 'ln -s /opt/csw/bin/pkgutil /usr/bin/pkgutil' end # Solaris doesn't necessarily have this, but gem needs it if is_solaris on host, 'mkdir -p /var/lib' end unless host.check_for_command( 'gem' ) gempkg = case host['platform'] when /solaris-11/ then 'ruby-18' when /ubuntu-14/ then 'ruby' when /solaris-10|ubuntu|debian|el-|cumulus/ then 'rubygems' when /openbsd/ then 'ruby' else raise "install_puppet() called with default_action " + "'gem_install' but program `gem' is " + "not installed on #{host.name}" end host.install_package gempkg end # Link 'gem' to /usr/bin instead of adding /opt/csw/bin to PATH. if is_solaris10 on host, 'ln -s /opt/csw/bin/gem /usr/bin/gem' end if host['platform'] =~ /debian|ubuntu|solaris|cumulus/ gem_env = YAML.load( on( host, 'gem environment' ).stdout ) gem_paths_array = gem_env['RubyGems Environment'].find {|h| h['GEM PATHS'] != nil }['GEM PATHS'] path_with_gem = 'export PATH=' + gem_paths_array.join(':') + ':${PATH}' on host, "echo '#{path_with_gem}' >> ~/.bashrc" end gemflags = '--no-ri --no-rdoc --no-format-executable' if opts[:facter_version] on host, "gem install facter -v'#{opts[:facter_version]}' #{gemflags}" end if opts[:hiera_version] on host, "gem install hiera -v'#{opts[:hiera_version]}' #{gemflags}" end ver_cmd = opts[:version] ? "-v '#{opts[:version]}'" : '' on host, "gem install puppet #{ver_cmd} #{gemflags}" # Similar to the treatment of 'gem' above. # This avoids adding /opt/csw/bin to PATH. if is_solaris gem_env = YAML.load( on( host, 'gem environment' ).stdout ) # This is the section we want - this has the dir where gem executables go. env_sect = 'EXECUTABLE DIRECTORY' # Get the directory where 'gem' installs executables. # On Solaris 10 this is usually /opt/csw/bin gem_exec_dir = gem_env['RubyGems Environment'].find {|h| h[env_sect] != nil }[env_sect] on host, "ln -s #{gem_exec_dir}/hiera /usr/bin/hiera" on host, "ln -s #{gem_exec_dir}/facter /usr/bin/facter" on host, "ln -s #{gem_exec_dir}/puppet /usr/bin/puppet" end # A gem install might not necessarily create these ['confdir', 'logdir', 'codedir'].each do |key| host.mkdir_p host.puppet[key] if host.puppet.has_key?(key) end configure_foss_defaults_on( host ) end end |
#install_puppet_from_msi_on(hosts, opts) ⇒ Object Also known as: install_puppet_from_msi
on windows, the :ruby_arch host parameter can determine in addition
Installs Puppet and dependencies from msi on provided host(s).
to other settings whether the 32 or 64bit install is used
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 475 def install_puppet_from_msi_on( hosts, opts ) block_on hosts do |host| version = opts[:version] if version && !version_is_less(version, '4.0.0') if opts[:puppet_agent_version].nil? raise "You must specify the version of puppet agent you " + "want to install if you want to install Puppet 4.0 " + "or greater on Windows" end opts[:version] = opts[:puppet_agent_version] install_puppet_agent_from_msi_on(host, opts) else compute_puppet_msi_name(host, opts) install_a_puppet_msi_on(host, opts) end configure_foss_defaults_on( host ) end end |
#install_puppet_from_openbsd_packages_on(hosts, opts) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Installs Puppet and dependencies from OpenBSD packages
709 710 711 712 713 714 715 716 717 718 719 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 709 def install_puppet_from_openbsd_packages_on(hosts, opts) if (opts[:version]) logger.warn "If you wish to choose a specific Puppet version, use `install_puppet_from_gem_on('~> 3.*')`" end block_on hosts do |host| host.install_package('puppet') configure_foss_defaults_on(host) end end |
#install_puppet_from_rpm_on(hosts, opts) ⇒ Object Also known as: install_puppet_from_rpm
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Installs Puppet and dependencies using rpm on provided host(s).
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 410 def install_puppet_from_rpm_on( hosts, opts ) block_on hosts do |host| install_puppetlabs_release_repo(host) if opts[:facter_version] host.install_package("facter-#{opts[:facter_version]}") end if opts[:hiera_version] host.install_package("hiera-#{opts[:hiera_version]}") end puppet_pkg = opts[:version] ? "puppet-#{opts[:version]}" : 'puppet' host.install_package("#{puppet_pkg}") configure_foss_defaults_on( host ) end end |
#install_puppet_on(hosts, opts = {}) ⇒ Object
This will attempt to add a repository for apt.puppetlabs.com on Debian, Ubuntu, or Cumulus machines, or yum.puppetlabs.com on EL or Fedora machines, then install the package 'puppet' or 'puppet-agent'.
Install FOSS based on specified hosts using provided options
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 221 def install_puppet_on(hosts, opts={}) opts = FOSS_DEFAULT_DOWNLOAD_URLS.merge(opts) # If version isn't specified assume the latest in the 3.x series if opts[:version] and not version_is_less(opts[:version], '4.0.0') # backwards compatability opts[:puppet_agent_version] ||= opts[:version] install_puppet_agent_on(hosts, opts) else block_on hosts do |host| if host['platform'] =~ /el-(5|6|7)/ relver = $1 install_puppet_from_rpm_on(host, opts.merge(:release => relver, :family => 'el')) elsif host['platform'] =~ /fedora-(\d+)/ relver = $1 install_puppet_from_rpm_on(host, opts.merge(:release => relver, :family => 'fedora')) elsif host['platform'] =~ /(ubuntu|debian|cumulus)/ install_puppet_from_deb_on(host, opts) elsif host['platform'] =~ /windows/ relver = opts[:version] install_puppet_from_msi_on(host, opts) elsif host['platform'] =~ /osx/ install_puppet_from_dmg_on(host, opts) elsif host['platform'] =~ /openbsd/ install_puppet_from_openbsd_packages_on(host, opts) elsif host['platform'] =~ /freebsd/ install_puppet_from_freebsd_ports_on(host, opts) else if opts[:default_action] == 'gem_install' opts[:version] ||= '~> 3.x' install_puppet_from_gem_on(host, opts) else raise "install_puppet() called for unsupported platform '#{host['platform']}' on '#{host.name}'" end end host[:version] = opts[:version] # Certain install paths may not create the config dirs/files needed on host, "mkdir -p #{host['puppetpath']}" unless host[:type] =~ /aio/ on host, "echo '' >> #{host.puppet['hiera_config']}" end end nil end |
#install_puppetlabs_dev_repo(host, package_name, build_version, repo_configs_dir = 'tmp/repo_configs', opts = options) ⇒ Object
This method only works on redhat-like and debian-like hosts.
Install development repository on the given host. This method pushes all repository information including package files for the specified package_name to the host and modifies the repository configuration file to point at the new repository. This is particularly useful for installing development packages on hosts that can't access the builds server.
879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 879 def install_puppetlabs_dev_repo ( host, package_name, build_version, repo_configs_dir = 'tmp/repo_configs', opts = ) variant, version, arch, codename = host['platform'].to_array platform_configs_dir = File.join(repo_configs_dir, variant) opts = FOSS_DEFAULT_DOWNLOAD_URLS.merge(opts) # some of the uses of dev_builds_url below can't include protocol info, # plus this opens up possibility of switching the behavior on provided # url type _, protocol, hostname = opts[:dev_builds_url].partition /.*:\/\// dev_builds_url = protocol + hostname on host, "mkdir -p /root/#{package_name}" case variant when /^(fedora|el|centos)$/ variant = (($1 == 'centos') ? 'el' : $1) fedora_prefix = ((variant == 'fedora') ? 'f' : '') if host.is_pe? pattern = "pl-%s-%s-repos-pe-%s-%s%s-%s.repo" else pattern = "pl-%s-%s-%s-%s%s-%s.repo" end repo_filename = pattern % [ package_name, build_version, variant, fedora_prefix, version, arch ] repo = fetch_http_file( "%s/%s/%s/repo_configs/rpm/" % [ dev_builds_url, package_name, build_version ], repo_filename, platform_configs_dir) link = nil package_repos = opts[:dev_builds_repos].nil? ? [] : [opts[:dev_builds_repos]] package_repos.push(['products', 'devel']).flatten! package_repos.each do |repo| link = "%s/%s/%s/repos/%s/%s%s/%s/%s/" % [ dev_builds_url, package_name, build_version, variant, fedora_prefix, version, repo, arch ] unless link_exists?( link ) logger.debug("couldn't find link at '#{repo}', falling back to next option...") else logger.debug("found link at '#{repo}'") break end end raise "Unable to reach a repo directory at #{link}" unless link_exists?( link ) repo_dir = fetch_http_dir( link, platform_configs_dir ) config_dir = '/etc/yum.repos.d/' scp_to host, repo, config_dir scp_to host, repo_dir, "/root/#{package_name}" search = "baseurl\\s*=\\s*http:\\/\\/#{hostname}.*$" replace = "baseurl=file:\\/\\/\\/root\\/#{package_name}\\/#{arch}" sed_command = "sed -i 's/#{search}/#{replace}/'" find_and_sed = "find #{config_dir} -name \"*.repo\" -exec #{sed_command} {} \\;" on host, find_and_sed when /^(debian|ubuntu|cumulus)$/ list = fetch_http_file( "%s/%s/%s/repo_configs/deb/" % [ dev_builds_url, package_name, build_version ], "pl-%s-%s-%s.list" % [ package_name, build_version, codename ], platform_configs_dir ) repo_dir = fetch_http_dir( "%s/%s/%s/repos/apt/%s" % [ dev_builds_url, package_name, build_version, codename ], platform_configs_dir ) config_dir = '/etc/apt/sources.list.d' scp_to host, list, config_dir scp_to host, repo_dir, "/root/#{package_name}" repo_name = nil package_repos = opts[:dev_builds_repos].nil? ? [] : [opts[:dev_builds_repos]] package_repos.flatten! package_repos.each do |repo| repo_path = "/root/#{package_name}/#{codename}/#{repo}" repo_check = on(host, "[[ -d #{repo_path} ]]", :acceptable_exit_codes => [0,1]) if repo_check.exit_code == 0 logger.debug("found repo at '#{repo_path}'") repo_name = repo break else logger.debug("couldn't find repo at '#{repo_path}', falling back to next option...") end end if repo_name.nil? repo_name = 'main' logger.debug("using default repo '#{repo_name}'") end search = "deb\\s\\+http:\\/\\/#{hostname}.*$" replace = "deb file:\\/\\/\\/root\\/#{package_name}\\/#{codename} #{codename} #{repo_name}" sed_command = "sed -i 's/#{search}/#{replace}/'" find_and_sed = "find #{config_dir} -name \"*.list\" -exec #{sed_command} {} \\;" on host, find_and_sed on host, "apt-get update" configure_foss_defaults_on( host ) else raise "No repository installation step for #{variant} yet..." end end |
#install_puppetlabs_release_repo_on(hosts, repo = nil, opts = options) ⇒ Object Also known as: install_puppetlabs_release_repo
This method only works on redhat-like and debian-like hosts.
Install official puppetlabs release repository configuration on host(s).
824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 |
# File 'lib/beaker/dsl/install_utils/foss_utils.rb', line 824 def install_puppetlabs_release_repo_on( hosts, repo = nil, opts = ) block_on hosts do |host| variant, version, arch, codename = host['platform'].to_array repo_name = repo.nil? ? '' : '-' + repo opts = FOSS_DEFAULT_DOWNLOAD_URLS.merge(opts) case variant when /^(fedora|el|centos)$/ variant = (($1 == 'centos') ? 'el' : $1) rpm = "puppetlabs-release%s-%s-%s.noarch.rpm" % [repo_name, variant, version] remote = URI.join( opts[:release_yum_repo_url], rpm ) on host, "rpm --replacepkgs -ivh #{remote}" when /^(debian|ubuntu|cumulus)$/ deb = "puppetlabs-release%s-%s.deb" % [repo_name, codename] remote = URI.join( opts[:release_apt_repo_url], deb ) on host, "wget -O /tmp/puppet.deb #{remote}" on host, "dpkg -i --force-all /tmp/puppet.deb" on host, "apt-get update" else raise "No repository installation step for #{variant} yet..." end configure_foss_defaults_on( host ) end end |