Module: Beaker::DSL::InstallUtils::PEClientTools

Included in:
PE
Defined in:
lib/beaker-pe/pe-client-tools/install_helper.rb

Instance Method Summary collapse

Instance Method Details

#install_dev_repos_on(package, host, sha, repo_configs_dir, opts = {}) ⇒ Object

`install_dev_repos_on` is used in various projects in the puppetlabs namespace; when they are all switched to call `install_puppetlabs_dev_repo`, this method can be removed.


66
67
68
# File 'lib/beaker-pe/pe-client-tools/install_helper.rb', line 66

def install_dev_repos_on(package, host, sha, repo_configs_dir, opts={})
  install_puppetlabs_dev_repo(host, package, sha, repo_configs_dir, opts)
end

#install_pe_client_tools_on(hosts, opts = {}) ⇒ Object


6
7
8
9
10
11
12
13
14
15
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
# File 'lib/beaker-pe/pe-client-tools/install_helper.rb', line 6

def install_pe_client_tools_on(hosts, opts = {})
  product = 'pe-client-tools'
  required_keys = [:puppet_collection, :pe_client_tools_sha, :pe_client_tools_version]

  unless required_keys.all? { |opt| opts.keys.include?(opt) && opts[opt]}
    raise ArgumentError, "The keys #{required_keys.to_s} are required in the opts hash"
  end
  urls = { :dev_builds_url   => "http://builds.delivery.puppetlabs.net",
  }

  opts = urls.merge(opts)
  block_on hosts do |host|
    variant, version, arch, codename = host['platform'].to_array
    package_name = ''
    # If we're installing a tagged version, then the package will be
    # located in a directory named after the tag. Otherwise, look for
    # it by SHA.
    if opts[:pe_client_tools_version] =~ /^\d+(\.\d+)+$/
      directory = opts[:pe_client_tools_version]
    else
      directory = opts[:pe_client_tools_sha]
    end
    case host['platform']
      when /win/
        package_name << product
        release_path = "#{opts[:dev_builds_url]}/#{product}/#{directory}/artifacts/#{variant}"
        package_name << "-#{opts[:pe_client_tools_version]}-x#{arch}.msi"
        generic_install_msi_on(host, File.join(release_path, package_name), {}, {:debug => true})
      when /osx/
        release_path = "#{opts[:dev_builds_url]}/#{product}/#{directory}/artifacts/apple/#{version}/#{opts[:puppet_collection]}/#{arch}"
        package_base = "#{product}-#{opts[:pe_client_tools_version]}"
        package_base << '-1' if opts[:pe_client_tools_version]

        dmg = package_base + ".#{variant}#{version}.dmg"
        copy_dir_local = File.join('tmp', 'repo_configs')
        fetch_http_file(release_path, dmg, copy_dir_local)
        scp_to host, File.join(copy_dir_local, dmg), host.external_copy_base

        package_name = package_base + '*'
        installer = package_name + '-installer.pkg'
        host.generic_install_dmg(dmg, package_name, installer)
      else
        install_dev_repos_on(product, host, directory, '/tmp/repo_configs',{:dev_builds_url => opts[:dev_builds_url]})
        host.install_package('pe-client-tools')
        if host['platform'] =~ /cisco|centos|redhat|eos|sles|el-|fedora-(2[2-9]|3[0-9])/
          host.exec(Command.new('rpm -q pe-client-tools')) do |command|
            raise "Wanted version not installed." unless command.stdout =~ /-#{opts[:pe_client_tools_version]}/
          end
        elsif host['platform'] =~ /ubuntu|debian|cumulus|huaweios/
          host.exec(Command.new("apt-cache policy pe-client-tools | sed -n -e 's/Installed: //p'")) do |command|
            raise "Wanted version not installed." unless command.stdout =~ /-#{opts[:pe_client_tools_version]}/
          end
        end
    end
  end
end