Class: BeakerPuppetHelpers::InstallUtils
- Inherits:
-
Object
- Object
- BeakerPuppetHelpers::InstallUtils
- Defined in:
- lib/beaker_puppet_helpers/install_utils.rb
Overview
Methods to install Puppet
Constant Summary collapse
- REPOS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ openvox: { release: { apt: 'https://apt.voxpupuli.org/', yum: 'https://yum.voxpupuli.org/', }, }, puppet: { release: { apt: 'https://apt.puppet.com', yum: 'https://yum.puppet.com', }, }, }.freeze
Class Method Summary collapse
-
.collection2packagename(host, collection, prefer_aio: nil) ⇒ String
Determine if we need the Perforce or OpenVox Package, based on the collection.
-
.implementation_from_collection(collection) ⇒ String
returns the used implementation (puppet or openvox).
-
.install_openvox_agent_from_url_on(host, base_url, version) ⇒ Object
Install the openvox-agent package on a host by downloading it directly from an artifact server.
-
.install_puppet_release_repo_on(host, collection = 'puppet') ⇒ Object
Install official Puppet release repository configuration on host(s).
-
.openvox_agent_staging_package_filename(host, version) ⇒ String
private
Build the openvox-agent package filename for a given host and version.
-
.openvox_package_name ⇒ String
Determine the openvox package name.
-
.package_name(host, prefer_aio: true, implementation: 'openvox') ⇒ String
Determine the correct package name, based on implementation, AIO and OS.
-
.puppet_package_name(host, prefer_aio: true) ⇒ String
Determine the Puppet package name.
- .wget_on(host, url) ⇒ Object private
Class Method Details
.collection2packagename(host, collection, prefer_aio: nil) ⇒ String
Determine if we need the Perforce or OpenVox Package, based on the collection
123 124 125 126 127 128 |
# File 'lib/beaker_puppet_helpers/install_utils.rb', line 123 def self.collection2packagename(host, collection, prefer_aio: nil) prefer_aio = collection != 'none' if prefer_aio.nil? implementation = implementation_from_collection(collection) package_name(host, prefer_aio: prefer_aio, implementation: implementation) end |
.implementation_from_collection(collection) ⇒ String
returns the used implementation (puppet or openvox)
29 30 31 32 33 34 35 |
# File 'lib/beaker_puppet_helpers/install_utils.rb', line 29 def self.implementation_from_collection(collection) if collection == 'none' 'puppet' else collection.gsub(/\d+/, '') end end |
.install_openvox_agent_from_url_on(host, base_url, version) ⇒ Object
Install the openvox-agent package on a host by downloading it directly from an artifact server.
The correct package filename is derived from the host's packaging_platform
attribute (see openvox_agent_staging_package_filename for the expected format).
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/beaker_puppet_helpers/install_utils.rb', line 233 def self.install_openvox_agent_from_url_on(host, base_url, version) filename = openvox_agent_staging_package_filename(host, version) url = "#{base_url}/#{version}/#{filename}" variant = host['packaging_platform'].split('-', 3).first case variant when 'el', 'fedora', 'sles', 'amazon' # RPM: install_package accepts a URL directly (calls rpm/yum/zypper) host.install_package(url) when 'debian', 'ubuntu' # Deb: must be downloaded to a local path first, then installed wget_on(host, url) do |filename| host.install_package(filename) end else raise ArgumentError, "No install strategy for variant '#{variant}' " \ "(packaging_platform: '#{host['packaging_platform']}')" end end |
.install_puppet_release_repo_on(host, collection = 'puppet') ⇒ Object
This method only works on redhat-like and debian-like hosts. There are no official Puppet releases for other platforms.
Install official Puppet release repository configuration on host(s).
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 86 87 88 89 |
# File 'lib/beaker_puppet_helpers/install_utils.rb', line 53 def self.install_puppet_release_repo_on(host, collection = 'puppet') implementation = implementation_from_collection(collection) repos = REPOS[implementation.to_sym][:release] variant, version, _arch = host['packaging_platform'].split('-', 3) case variant when 'el', 'fedora', 'sles', 'cisco-wrlinux' # sles 11 and later do not handle gpg keys well. We can't # automatically import the keys because of sad things, so we # have to manually import it once we install the release # package. We'll have to remember to update this block when # we update the signing keys if variant == 'sles' && version >= '11' %w[puppet puppet-20250406].each do |gpg_key| wget_on(host, "https://yum.puppet.com/RPM-GPG-KEY-#{gpg_key}") do |filename| host.exec(Beaker::Command.new("rpm --import '#{filename}'")) end end end url = "#{repos[:yum]}/#{collection}-release-#{variant}-#{version}.noarch.rpm" host.install_package(url) when 'debian', 'ubuntu' relname = (implementation == 'openvox') ? "#{variant}#{version}" : host['platform'].codename url = "#{repos[:apt]}/#{collection}-release-#{relname}.deb" wget_on(host, url) do |filename| host.install_package(filename) end host.exec(Beaker::Command.new('apt-get update')) # On Debian we can't count on /etc/profile.d host.add_env_var('PATH', '/opt/puppetlabs/bin') else raise "No repository installation step for #{variant} yet..." end end |
.openvox_agent_staging_package_filename(host, version) ⇒ String
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.
Build the openvox-agent package filename for a given host and version.
The host's packaging_platform attribute must follow the Beaker
convention: "
"el-8-x86_64", "el-9-aarch64", "el-10-x86_64"
"fedora-42-x86_64"
"sles-15-x86_64", "sles-16-aarch64"
"amazon-2-aarch64", "amazon-2023-x86_64"
"ubuntu-22.04-amd64", "ubuntu-24.04-arm64"
"debian-11-amd64", "debian-12-arm64"
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/beaker_puppet_helpers/install_utils.rb', line 192 def self.openvox_agent_staging_package_filename(host, version) variant, release, arch = host['packaging_platform'].split('-', 3) case variant when 'el' "openvox-agent-#{version}-1.el#{release}.#{arch}.rpm" when 'fedora' "openvox-agent-#{version}-1.fc#{release}.#{arch}.rpm" when 'sles' "openvox-agent-#{version}-1.sles#{release}.#{arch}.rpm" when 'amazon' "openvox-agent-#{version}-1.amazon#{release}.#{arch}.rpm" when 'debian', 'ubuntu' "openvox-agent_#{version}-1+#{variant}#{release}_#{arch}.deb" else raise ArgumentError, "No openvox-agent package filename known for variant '#{variant}' " \ "(packaging_platform: '#{host['packaging_platform']}'). " \ 'Supported variants: el, fedora, sles, amazon, debian, ubuntu' end end |
.openvox_package_name ⇒ String
Determine the openvox package name
157 158 159 |
# File 'lib/beaker_puppet_helpers/install_utils.rb', line 157 def self.openvox_package_name 'openvox-agent' end |
.package_name(host, prefer_aio: true, implementation: 'openvox') ⇒ String
Determine the correct package name, based on implementation, AIO and OS
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/beaker_puppet_helpers/install_utils.rb', line 100 def self.package_name(host, prefer_aio: true, implementation: 'openvox') case implementation when 'openvox' openvox_package_name when 'puppet' puppet_package_name(host, prefer_aio: prefer_aio) when 'none' 'puppet' else raise StandardError, "Unknown requirement '#{implementation}'" end end |
.puppet_package_name(host, prefer_aio: true) ⇒ String
Determine the Puppet package name
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/beaker_puppet_helpers/install_utils.rb', line 137 def self.puppet_package_name(host, prefer_aio: true) case host['packaging_platform'].split('-', 3).first when 'debian' # 12 started to ship puppet-agent with puppet as a legacy package (prefer_aio || host['packaging_platform'].split('-', 3)[1].to_i >= 12) ? 'puppet-agent' : 'puppet' when /el|fedora|sles|cisco_/ prefer_aio ? 'puppet-agent' : 'puppet' when /freebsd/ 'sysutils/puppet8' when 'ubuntu' # 23.04 started to ship puppet-agent with puppet as a legacy package (prefer_aio || host['packaging_platform'].split('-', 3)[1].to_i >= 2304) ? 'puppet-agent' : 'puppet' else 'puppet' end end |
.wget_on(host, url) ⇒ 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.
164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/beaker_puppet_helpers/install_utils.rb', line 164 def self.wget_on(host, url) extension = File.extname(url) name = File.basename(url, extension) target = host.tmpfile(name, extension) begin host.exec(Beaker::Command.new("wget -O '#{target}' '#{url}'")) yield target ensure host.rm_rf(target) end end |