diff --git a/facts/get_facts.sh b/facts/get_facts.sh index 469003df..ac16bf2f 100755 --- a/facts/get_facts.sh +++ b/facts/get_facts.sh @@ -2,6 +2,17 @@ export PATH=/opt/puppetlabs/bin:$PATH +puppetAgentVersionList='/vagrant/versions.txt' +if test ! -f $puppetAgentVersionList; then + echo 'Missing version list' >&2 + exit 1 +fi +puppet8_agent_versions=$(grep --only-matching --perl-regexp '^\d+\.\d+\.\d+' $puppetAgentVersionList) +if test -z "$puppet8_agent_versions"; then + echo 'Version list is empty' >&2 + exit 1 +fi + apt_install() { DEBIAN_FRONTEND=noninteractive \ apt-get --option Dpkg::Options::="--force-confdef" \ @@ -42,7 +53,6 @@ elif test -f '/etc/os-release' && grep -q 'Amazon' '/etc/os-release'; then else osfamily=$(uname) fi -puppet8_agent_versions='8.0.0 8.1.0 8.2.0 8.3.1 8.4.0 8.5.0 8.5.1 8.6.0' case "${osfamily}" in 'RedHat') . /etc/os-release diff --git a/facts/versions.txt b/facts/versions.txt new file mode 100644 index 00000000..f29e193c --- /dev/null +++ b/facts/versions.txt @@ -0,0 +1,16 @@ +# This is a list of all Puppet Agent versions to use to collect facts +# Each line can have a single string which is a version number or can be a comment +# Version information from Facter release notes: https://www.puppet.com/docs/puppet/8/release_notes_facter.htm +# FacterDB only cares about the x.y, and drops .z - Please keep versions in order by Facter version + +# Facter 4.7.0 - Released April 2024 and shipped with Puppet 8.6.0. +8.6.0 + +# Facter 4.6.1 - Released March 2024 and shipped with Puppet 8.5.1. +8.5.1 + +# Facter 4.5.2 - Released January 2023 and shipped with Puppet 8.4.0. +8.4.0 + +# Facter 4.4.2 - Released August 2023 and shipped with Puppet 8.2.0. +8.2.0 diff --git a/facts/windows_get_facts.ps1 b/facts/windows_get_facts.ps1 index 5ddd4203..77cbd28e 100644 --- a/facts/windows_get_facts.ps1 +++ b/facts/windows_get_facts.ps1 @@ -1,5 +1,5 @@ param( - [array]$puppetAgentVersions = ('7.24.0','8.0.0','8.5.1','8.6.0'), + [string]$puppetAgentVersionList = 'X:\versions.txt', [string]$baseUrl = 'https://downloads.puppetlabs.com/windows/puppet{0}/puppet-agent-{1}-{2}.msi', [string]$fqdn = 'foo.example.com' ) @@ -25,6 +25,18 @@ net use X: \\VBOXSVR\vagrant $VagrantDataPath = 'X:\' $WorkingDirectory = 'C:\vagrant_working_directory\' +# Check if version list is available and load it +if (!(Test-Path $puppetAgentVersionList)) { + Write-Host -ForegroundColor Red "Can't find Puppet Agent Version list." + Exit 1 +} + +$puppetAgentVersions = Select-String -Path $puppetAgentVersionList '^\d+\.\d+\.\d+' -AllMatches | Foreach-Object {$_.Line} +if ($puppetAgentVersions.Count -eq 0) { + Write-Host -ForegroundColor Red "Puppet Agent version list seems to be empty." + Exit 1 +} + # Make sure we have enough privs to install the things. $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) if (! ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))) { @@ -40,6 +52,7 @@ if (!(Test-Path $WorkingDirectory)) { # Install each puppet version & collect facts. foreach ($pupAgentVer in $puppetAgentVersions) { + write-Host "Generating facts with `'$pupAgentVer`'" $agentUrl = $baseUrl -f $pupAgentVer[0], $pupAgentVer, "x64" $agentName = "puppet-agent-{1}-{2}.msi" -f $pupAgentVer[0], $pupAgentVer, "x64"