Class: PuppetMetadata::Beaker
- Inherits:
-
Object
- Object
- PuppetMetadata::Beaker
- Defined in:
- lib/puppet_metadata/beaker.rb
Overview
A class to provide abstractions for integration with beaker
Constant Summary collapse
- PIDFILE_COMPATIBLE_IMAGES =
These images have an older systemd, which they work with PIDFile parameter
{ 'CentOS' => { '7' => 'centos:7.6.1810', }, 'Ubuntu' => { '16.04' => 'ubuntu:xenial-20191212', }, }.freeze
- PIDFILE_INCOMPATIBLE =
There is no CentOS 8 image that works with PIDFile in systemd unit files
{ 'CentOS' => ['8'], 'AlmaLinux' => ['8'], 'OracleLinux' => ['7', '8'], 'Rocky' => ['8'], }.freeze
Class Method Summary collapse
-
.adjusted_os(os) ⇒ String
modifies the operating system name to suit beaker-hostgenerator.
-
.os_release_to_setfile(os, release, pidfile_workaround: false, domain: nil, puppet_version: nil, hosts: nil) ⇒ nil, Array<(String, String)>
Convert an Operating System name with a release to a Beaker setfile.
-
.os_supported?(os) ⇒ Boolean
Return whether a Beaker setfile can be generated for the given OS.
Class Method Details
.adjusted_os(os) ⇒ String
modifies the operating system name to suit beaker-hostgenerator
30 31 32 33 34 35 36 37 |
# File 'lib/puppet_metadata/beaker.rb', line 30 def adjusted_os(os) case os when 'OracleLinux' 'oracle' else os.downcase end end |
.os_release_to_setfile(os, release, pidfile_workaround: false, domain: nil, puppet_version: nil, hosts: nil) ⇒ nil, Array<(String, String)>
Convert an Operating System name with a release to a Beaker setfile
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 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 |
# File 'lib/puppet_metadata/beaker.rb', line 64 def os_release_to_setfile(os, release, pidfile_workaround: false, domain: nil, puppet_version: nil, hosts: nil) return unless os_supported?(os) aos = adjusted_os(os) name = "#{aos}#{release.tr('.', '')}-64" human_name = "#{os} #{release}" hosts_settings = [] if hosts hosts.each do |hostname, roles| hosts_settings << { 'name' => if roles name + roles elsif hosts.size > 1 hosts_settings.empty? ? "#{name}.ma" : "#{name}.a" else name end, 'hostname' => ((puppet_version.nil? || puppet_version == 'none') ? hostname : "#{hostname}-#{puppet_version}") + (domain ? ".#{domain}" : ''), } end else hosts_settings << { 'name' => name, 'hostname' => if puppet_version && puppet_version != 'none' "#{name}-#{puppet_version}" + (domain ? ".#{domain}" : '') elsif domain name + (domain ? ".#{domain}" : '') else '' end, } end = {} # Docker messes up cgroups and some systemd versions can't deal with # that when PIDFile is used. image_to_use = nil if pidfile_workaround?(pidfile_workaround, os) return if PIDFILE_INCOMPATIBLE[os]&.include?(release) if (image = PIDFILE_COMPATIBLE_IMAGES.dig(os, release)) image_to_use = image end end setfile_parts = [] hosts_settings.each do |host_settings| [:hostname] = host_settings['hostname'] unless host_settings['hostname'].empty? [:image] = image_to_use if image_to_use setfile_parts << build_setfile(host_settings['name'], ) end [setfile_parts.join('-'), human_name] end |
.os_supported?(os) ⇒ Boolean
Return whether a Beaker setfile can be generated for the given OS
122 123 124 |
# File 'lib/puppet_metadata/beaker.rb', line 122 def os_supported?(os) %w[Archlinux CentOS Fedora Debian Ubuntu Rocky AlmaLinux OracleLinux].include?(os) end |