Skip to content
Open
61 changes: 23 additions & 38 deletions .github/actions/presuite.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# frozen_string_literal: true

require 'etc'
require 'open3'
require 'fileutils'
require 'yaml'

def if_no_env_vars_set_defaults
ENV['FACTER_ROOT'] = __dir__.gsub('/.github/actions', '') unless ENV['FACTER_ROOT']
ENV['RELEASE_STREAM'] = 'puppet8' unless ENV['RELEASE_STREAM']
ENV['RELEASE_STREAM'] = 'openvox9' unless ENV['RELEASE_STREAM']
end

def install_facter_acceptance_dependencies
Expand All @@ -14,51 +16,34 @@ def install_facter_acceptance_dependencies
end

def initialize_beaker
beaker_platform_with_options = platform_with_options(beaker_platform)

message('BEAKER INITIALIZE')
run("beaker init -h #{beaker_platform_with_options} -o #{File.join('config', 'aio', 'options.rb')}")
File.write('hosts.yaml', { 'HOSTS' => { 'localhost' => beaker_host } }.to_yaml)
run("beaker init -h hosts.yaml -o #{File.join('config', 'aio', 'options.rb')}")

message('BEAKER PROVISION')
run('beaker provision')
end

def beaker_platform
{
'ubuntu-22.04' => 'ubuntu2204-64a',
'ubuntu-24.04' => 'ubuntu2404-64a',
'macos-13' => 'osx13-64a',
'macos-14' => 'osx14-64a',
'macos-15' => 'osx15-64a',
'windows-2016' => 'windows2016-64a',
'windows-2019' => 'windows2019-64a',
'windows-2022' => 'windows2022-64a',
}[HOST_PLATFORM]
end

def platform_with_options(platform)
return "\"#{platform}{hypervisor=none,hostname=localhost,is_cygwin=false}\"" if platform.include? 'windows'

"#{platform}{hypervisor=none\\,hostname=localhost}"
# The runner is the only host. Its platform comes from the runner's name, so a
# new runner needs no beaker-hostgenerator release that knows its OS version.
def beaker_host
os, version = HOST_PLATFORM.split('-')
host = case os
when 'macos'
{ 'platform' => "osx-#{version}-#{Etc.uname[:machine]}" }
when 'windows'
{ 'platform' => "windows-#{version}-64", 'packaging_platform' => 'windows-2012-x64',
'ruby_arch' => 'x64', 'is_cygwin' => false }
when 'ubuntu'
{ 'platform' => "ubuntu-#{version}-amd64" }
end
host.merge('hypervisor' => 'none', 'roles' => ['agent'])
end

def install_puppet_agent
message('INSTALL PUPPET AGENT')
def install_openvox_agent
message('INSTALL OPENVOX AGENT')

beaker_puppet_root = run('bundle info beaker-puppet --path')

# Bundler/Rubygems can sometimes give output other than the filepath (deprecation warnings, etc.)
begin
if File.exist?(beaker_puppet_root.chomp)
presuite_file_path = File.join(beaker_puppet_root.chomp, 'setup', 'aio', '010_Install_Puppet_Agent.rb')

run("beaker exec pre-suite --pre-suite #{presuite_file_path} --preserve-state", './', env_path_var)
else
exit
end
rescue SystemExit
puts "`bundle info beaker-puppet --path` produced unexpected output, please address this."
end
run('beaker exec pre-suite --pre-suite pre-suite/install_openvox_agent.rb --preserve-state', './', env_path_var)
end

def puppet_puppet_bin_dir
Expand Down Expand Up @@ -151,7 +136,7 @@ def verify_facter_standalone_exits_0
Dir.chdir(ACCEPTANCE_PATH) do
install_facter_acceptance_dependencies
initialize_beaker
install_puppet_agent
install_openvox_agent
install_facter
run_acceptance_tests
end
28 changes: 21 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,20 @@ jobs:
matrix:
os:
- windows-2022
- windows-2025
- ubuntu-22.04
- ubuntu-24.04
- ubuntu-26.04
- macos-15
- macos-15-intel
- macos-26
- macos-26-intel
fail-fast: false
runs-on: ${{ matrix.os }}
env:
BEAKER_debug: true
FACTER_ROOT: facter
RELEASE_STREAM: puppet8
RELEASE_STREAM: openvox9

steps:
- name: Checkout current PR
Expand All @@ -141,12 +147,6 @@ jobs:
sudo chmod a-w /home/runner /usr/share &&
sudo chmod -R a-w /home/runner/.config /home/linuxbrew

- name: Install dhclient for Linux
if: runner.os == 'Linux'
run: |
sudo apt install isc-dhcp-client
sudo dhclient

# IPv6 is missing on the GitHub macOS image and we need it for the networking facts tests
# https://github.com/actions/runner-images/issues/668
- name: Add IPv6 on macOS
Expand All @@ -155,6 +155,20 @@ jobs:
primary_interface=`route -n get default | awk '/interface: */{print $NF}'`
sudo ifconfig $primary_interface inet6 add ::1/64

# beaker_puppet_helpers can't install on macOS, so this installs the
Comment thread
nmburgan marked this conversation as resolved.
Resolved
# newest release DMG of the collection, as the openvox suite does
- name: Install openvox-agent on macOS
if: runner.os == 'macOS'
shell: bash
run: |
url="https://downloads.voxpupuli.org/mac/${RELEASE_STREAM}"
dmg=$(curl --fail --silent --show-error "${url}/" |
grep -o "openvox-agent-[0-9.]*-1\.macos\.all\.$(uname -m)\.dmg" | sort -u -V | tail -n 1)
curl --fail --silent --show-error --location --output "${RUNNER_TEMP}/openvox-agent.dmg" "${url}/${dmg}"
sudo hdiutil attach "${RUNNER_TEMP}/openvox-agent.dmg" -nobrowse -mountpoint /Volumes/openvox-agent
sudo installer -pkg /Volumes/openvox-agent/*.pkg -target /
/opt/puppetlabs/bin/puppet --version

- name: Run acceptance tests on Linux and MacOS platform
if: runner.os != 'Windows'
run: sudo -E "PATH=$PATH" ruby $FACTER_ROOT/.github/actions/presuite.rb ${{ matrix.os }}
Expand Down
1 change: 1 addition & 0 deletions acceptance/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ end

gem "beaker", *location_for(ENV['BEAKER_VERSION'] || "~> 7")
gem 'beaker-puppet', *location_for(ENV['BEAKER_PUPPET_VERSION'] || "~> 4")
gem 'beaker_puppet_helpers', *location_for(ENV['BEAKER_PUPPET_HELPERS_VERSION'] || "~> 3.3")
gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'] || "~> 3")
gem "beaker-vagrant", *location_for(ENV['BEAKER_VAGRANT_VERSION'] || "~> 2")
gem "rake", ">= 12.3.3"
Expand Down
12 changes: 4 additions & 8 deletions acceptance/lib/facter/acceptance/base_fact_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def ubuntu_expected_facts(agent)
if agent['platform'] =~ /x86_64|amd64/
os_arch = 'amd64'
os_hardware = 'x86_64'
processor_model_pattern = /(Intel\(R\).*)|(AMD.*)/
processor_model_pattern = /(Intel\(R\).*)|(AMD.*)/i
elsif agent['platform'] =~ /aarch64/
os_arch = 'aarch64'
os_hardware = 'aarch64'
Expand Down Expand Up @@ -431,12 +431,8 @@ def windows_expected_facts(agent)
os_version = '10'
elsif agent['platform'] =~ /-11/
os_version = '11'
elsif agent['platform'] =~ /2016/
os_version = '2016'
elsif agent['platform'] =~ /2019/
os_version = '2019'
elsif agent['platform'] =~ /2022/
os_version = '2022'
elsif agent['platform'] =~ /windows-(20\d\d)/
os_version = Regexp.last_match(1)
else
fail_test "Unknown Windows version #{agent['platform']}"
end
Expand All @@ -459,7 +455,7 @@ def windows_expected_facts(agent)
'processors.count' => /[1-9]/,
'processors.physicalcount' => /[1-9]/,
'processors.isa' => /x86|x64/,
'processors.models' => /(Intel\(R\).*)|(AMD.*)/,
'processors.models' => /(Intel\(R\).*)|(AMD.*)/i,
'kernel' => 'windows',
'kernelrelease' => /\d+\.\d+/,
'kernelversion' => /\d+\.\d+/,
Expand Down
29 changes: 29 additions & 0 deletions acceptance/pre-suite/install_openvox_agent.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

# beaker-puppet only installs Perforce's puppet-agent, so openvox-agent comes
# from voxpupuli's beaker_puppet_helpers. Only its install code is loaded,
# because its DSL would replace the beaker-puppet helpers of the same names.
require 'beaker_puppet_helpers/install_utils'
require 'beaker_puppet_helpers/windows_utils'

test_name('install openvox-agent') do
extend BeakerPuppetHelpers::WindowsUtils

collection = ENV.fetch('RELEASE_STREAM')

agents.each do |agent|
# beaker_puppet_helpers can't install on macOS, so the workflow does
next if agent['platform'].start_with?('osx')

if agent['platform'].include?('windows')
install_msi_on(agent, collection)
else
BeakerPuppetHelpers::InstallUtils.install_puppet_release_repo_on(agent, collection)
agent.install_package(BeakerPuppetHelpers::InstallUtils.collection2packagename(agent, collection))
end
end

# Puts the agent's bin directories on the PATH that Beaker gives to the
# commands of the tests.
configure_type_defaults_on(agents)
end
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def create_api_call_file(test_vars, facter_querry)
step "Agent #{agent}: Verify that an error is outputted when custom fact file has an error" do
create_api_call_file(test_vars, "Facter.value('custom_fact_1')")
on(agent, "#{ruby_command(agent)} #{test_vars[:test_script_path]}") do |ruby_result|
assert_match(/Facter.*error while resolving custom facts in .*file1.rb undefined local variable or method `nill'/,
assert_match(/Facter.*error while resolving custom facts in .*file1.rb undefined local variable or method [`']nill'/,
ruby_result.stdout)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def create_custom_fact_file(file_name, file_content, fact_dir, agent)

step "Agent #{agent}: Verify that an error is outputted when custom fact file has an error" do
on(agent, facter('custom_fact_4', environment: env), acceptable_exit_codes: [1]) do |facter_output|
assert_match(/ERROR Facter.*error while resolving custom facts in .*file1.rb undefined local variable or method `nill'/,
assert_match(/ERROR Facter.*error while resolving custom facts in .*file1.rb undefined local variable or method [`']nill'/,
facter_output.stderr.chomp)
end
end
Expand Down
4 changes: 3 additions & 1 deletion acceptance/tests/facts/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
puppet_version = on(agent, puppet("--version")).stdout.chomp
ruby_version = if puppet_version =~ /^7\./
/2\.\d+\.\d+/
elsif puppet_version =~ /^9\./
/4\.\d+\.\d+/
else
/3\.\d+\.\d+/
end

case agent['platform']
when /windows/
ruby_platform = agent['ruby_arch'] == 'x64' ? 'x64-mingw32' : 'i386-mingw32'
ruby_platform = agent['ruby_arch'] == 'x64' ? /x64-mingw(32|-ucrt)/ : 'i386-mingw32'
when /osx/
if agent['platform'] =~ /arm64/
if puppet_version =~ /^7\./ && agent['platform'].split('-')[1].to_i < 13
Expand Down
12 changes: 12 additions & 0 deletions lib/schema/facter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1036,12 +1036,21 @@ networking:
bindings6:
type: array
description: The array of IPv6 address bindings for the interface.
description:
type: string
description: The description of the network interface, as reported by ifconfig.
dhcp:
type: ip
description: The DHCP server for the network interface.
duplex:
type: string
description: The duplex settings for physical network interfaces on Linux using /sys/class/net.
flags:
type: array
description: The flags of the network interface, as reported by ifconfig.
groups:
type: array
description: The interface groups that the network interface belongs to, as reported by ifconfig.
ip:
type: ip
description: The IPv4 address for the network interface.
Expand Down Expand Up @@ -1072,6 +1081,9 @@ networking:
physical:
type: boolean
description: Return whether network interface is a physical device on Linux based systems.
rdomain:
type: integer
description: The routing domain of the network interface, as reported by ifconfig.
scope6:
type: string
description: The IPv6 scope for the network interface.
Expand Down
Loading