Module: BeakerPuppet::Install::Puppet5

Includes:
Beaker::DSL::InstallUtils::FOSSDefaults
Included in:
BeakerPuppet::InstallUtils
Defined in:
lib/beaker-puppet/install_utils/puppet5.rb

Constant Summary

Constants included from Beaker::DSL::InstallUtils::FOSSDefaults

Beaker::DSL::InstallUtils::FOSSDefaults::FOSS_DEFAULTS, Beaker::DSL::InstallUtils::FOSSDefaults::FOSS_DEFAULT_DOWNLOAD_URLS

Instance Method Summary collapse

Methods included from Beaker::DSL::InstallUtils::FOSSDefaults

#add_foss_defaults_on, #add_platform_foss_defaults, #remove_foss_defaults_on, #remove_platform_foss_defaults

Instance Method Details

#fetch_build_details(sha_yaml_url) ⇒ Hash{String=>String}

grab build json from the builds server

Parameters:

  • sha_yaml_url (String)

    URL to the <SHA>.yaml file containing the build details

Returns:

  • (Hash{String=>String})

    build json parsed into a ruby hash



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/beaker-puppet/install_utils/puppet5.rb', line 15

def fetch_build_details(sha_yaml_url)
  dst_folder          = Dir.mktmpdir
  sha_yaml_filename   = File.basename(  sha_yaml_url )
  sha_yaml_folder_url = File.dirname(   sha_yaml_url )

  sha_yaml_file_local_path = fetch_http_file(
    sha_yaml_folder_url,
    sha_yaml_filename,
    dst_folder
  )
  file_hash = YAML.load_file( sha_yaml_file_local_path )

  logger.debug("YAML HASH BELOW:")
  logger.debug(file_hash)
  logger.debug("PLATFORM_DATA BELOW:")
  logger.debug(file_hash[:platform_data])
  return sha_yaml_folder_url, file_hash[:platform_data]
end

#host_urls(host, build_details, build_url) ⇒ String

gets the artifact & repo_config URLs for this host in the build

Parameters:

  • host (Host)

    Host to get artifact URL for

  • build_details (Hash)

    Details of the build in a hash

  • build_url (String)

    URL to the build

Returns:

  • (String, String)

    URL to the build artifact, URL to the repo_config (nil if there is no repo_config for this platform for this build)



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
# File 'lib/beaker-puppet/install_utils/puppet5.rb', line 42

def host_urls(host, build_details, build_url)
  packaging_platform = host[:packaging_platform]
  if packaging_platform.nil?
    message = "      :packaging_platform not provided for host '\#{host}', platform '\#{host[:platform]}'\n      :packaging_platform should be the platform-specific key from this list:\n        \#{ build_details.keys }\n    EOF\n    fail_test( message )\n  end\n\n  logger.debug(\"Platforms available for this build:\")\n  logger.debug(\"\#{ build_details.keys }\")\n  logger.debug(\"PLATFORM SPECIFIC INFO for \#{host} (packaging name '\#{packaging_platform}'):\")\n  packaging_data = build_details[packaging_platform]\n  logger.debug(\"- \#{ packaging_data }, isnil? \#{ packaging_data.nil? }\")\n  if packaging_data.nil?\n    message = <<-EOF\n      :packaging_platform '\#{packaging_platform}' for host '\#{host}' not in build details\n      :packaging_platform should be the platform-specific key from this list:\n        \#{ build_details.keys }\n    EOF\n    fail_test( message )\n  end\n\n  artifact_buildserver_path   = packaging_data[:artifact]\n  repoconfig_buildserver_path = packaging_data[:repo_config]\n  fail_test('no artifact_buildserver_path found') if artifact_buildserver_path.nil?\n\n  artifact_url    = \"\#{build_url}/\#{artifact_buildserver_path}\"\n  repoconfig_url  = \"\#{build_url}/\#{repoconfig_buildserver_path}\" unless repoconfig_buildserver_path.nil?\n  artifact_url_correct = link_exists?( artifact_url )\n  logger.debug(\"- artifact url: '\#{artifact_url}'. Exists? \#{artifact_url_correct}\")\n  fail_test('artifact url built incorrectly') if !artifact_url_correct\n\n  return artifact_url, repoconfig_url\nend\n"

#install_artifact_on(host, artifact_url, project_name) ⇒ Object

install build artifact on the given host

Parameters:

  • host (Host)

    Host to install artifact on

  • artifact_url (String)

    URL of the project install artifact

  • project_name (String)

    Name of project for artifact. Needed for OSX installs

Returns:

  • nil



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
115
116
117
118
119
# File 'lib/beaker-puppet/install_utils/puppet5.rb', line 87

def install_artifact_on(host, artifact_url, project_name)
  variant, _, _, _ = host[:platform].to_array
  onhost_package_file = nil
  if variant == 'eos'
    host.get_remote_file( artifact_url )
    onhost_package_file = File.basename( artifact_url )
  elsif variant == 'solaris'
    artifact_filename = File.basename( artifact_url )
    artifact_folder = File.dirname( artifact_url )
    fetch_http_file( artifact_folder, artifact_filename, '.' )
    onhost_package_dir = host.tmpdir( 'puppet_installer' )
    scp_to host, artifact_filename, onhost_package_dir
    onhost_package_file = "#{ onhost_package_dir }/#{ artifact_filename }"
  elsif variant == 'osx'
    on host, "curl -O #{ artifact_url }"
    onhost_package_file = "#{ project_name }*"
  end

  if variant == 'eos'
    # TODO Will be refactored into {Beaker::Host#install_local_package}
    #   immediately following this work. The release timing makes it
    #   necessary to have this here separately for a short while
    host.install_from_file( onhost_package_file )
  elsif onhost_package_file
    if onhost_package_dir
      host.install_local_package( onhost_package_file, '.' )
    else
      host.install_local_package( onhost_package_file )
    end
  else
    host.install_package( artifact_url )
  end
end

#install_from_build_data_url(project_name, sha_yaml_url) ⇒ Object

Note:

This install method only works for Puppet versions >= 5.0

Installs a specified puppet project on all hosts. Gets build information

from the provided YAML file located at the +sha_yaml_url+ parameter.

Parameters:

  • project_name (String)

    Name of the project to install

  • sha_yaml_url (String)

    URL to the <SHA>.yaml file containing the build details

Returns:

  • nil



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/beaker-puppet/install_utils/puppet5.rb', line 146

def install_from_build_data_url(project_name, sha_yaml_url)
  if !link_exists?( sha_yaml_url )
    message = "      <SHA>.yaml URL '\#{ sha_yaml_url }' does not exist.\n      Please update the `sha_yaml_url` parameter to the `puppet5_install` method.\n    EOF\n    fail_test( message )\n  end\n\n  base_url, build_details = fetch_build_details( sha_yaml_url )\n  hosts.each do |host|\n    artifact_url, repoconfig_url = host_urls( host, build_details, base_url )\n    if repoconfig_url.nil?\n      install_artifact_on( host, artifact_url, project_name )\n    else\n      install_repo_configs_on( host, repoconfig_url )\n      host.install_package( project_name )\n    end\n    configure_type_defaults_on( host )\n  end\nend\n"

#install_repo_configs_on(host, repoconfig_url) ⇒ Object

Sets up the repo_configs on the host for this build

Parameters:

  • host (Host)

    Host to install repo_configs on

  • repoconfig_url (String)

    URL to the repo_config

Returns:

  • nil



127
128
129
130
131
132
133
134
# File 'lib/beaker-puppet/install_utils/puppet5.rb', line 127

def install_repo_configs_on(host, repoconfig_url)
  if repoconfig_url.nil?
    logger.warn("No repo_config for host '#{host}'. Skipping repo_config install")
    return
  end

  install_repo_configs_from_url( host, repoconfig_url )
end