Skip to content

Commit

Permalink
Puppet_windows_url (#1)
Browse files Browse the repository at this point in the history
* add the ability to specify a puppet_windows_url
  • Loading branch information
shoddyguard authored Apr 13, 2023
1 parent 6064967 commit 5ce29dc
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions lib/kitchen/provisioner/puppet_apply.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class PuppetApply < Base
default_config :puppet_apt_repo, 'http://apt.puppetlabs.com/puppetlabs-release-precise.deb'
default_config :puppet_yum_repo, 'https://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm'
default_config :chef_bootstrap_url, 'https://www.chef.io/chef/install.sh'
default_config :puppet_windows_url, nil
default_config :puppet_logdest, nil
default_config :custom_install_command, nil
default_config :custom_pre_install_command, nil
Expand Down Expand Up @@ -251,13 +252,19 @@ def install_command
<<-INSTALL
#{custom_pre_install_command}
if(Get-Command puppet -ErrorAction 0) { return; }
$architecture = if( [Environment]::Is64BitOperatingSystem ) { 'x64' } else { 'x86' }
if( '#{puppet_windows_version}' -eq 'latest' ) {
$MsiUrl = "https://downloads.puppetlabs.com/windows/puppet-agent-${architecture}-latest.msi"
} elseif( '#{puppet_windows_version}' -match '(\\d)\\.' ) {
$MsiUrl = "https://downloads.puppetlabs.com/windows/puppet$($Matches[1])/puppet-agent-#{puppet_windows_version}-${architecture}.msi"
} else {
$MsiUrl = "https://downloads.puppetlabs.com/windows/puppet-#{puppet_windows_version}${architecture}.msi"
if( '#{puppet_windows_url}' -ne '') {
$MsiUrl = '#{puppet_windows_url}'
}
else
{
$architecture = if( [Environment]::Is64BitOperatingSystem ) { 'x64' } else { 'x86' }
if( '#{puppet_windows_version}' -eq 'latest' ) {
$MsiUrl = "https://downloads.puppetlabs.com/windows/puppet-agent-${architecture}-latest.msi"
} elseif( '#{puppet_windows_version}' -match '(\\d)\\.' ) {
$MsiUrl = "https://downloads.puppetlabs.com/windows/puppet$($Matches[1])/puppet-agent-#{puppet_windows_version}-${architecture}.msi"
} else {
$MsiUrl = "https://downloads.puppetlabs.com/windows/puppet-#{puppet_windows_version}${architecture}.msi"
}
}
Invoke-WebRequest $MsiUrl -UseBasicParsing -OutFile "C:/puppet.msi" #{posh_proxy_parm}
$process = Start-Process -FilePath msiexec.exe -Wait -PassThru -ArgumentList '/qn', '/norestart', '/i', 'C:\\puppet.msi'
Expand Down Expand Up @@ -352,13 +359,19 @@ def install_command_collections
<<-INSTALL
#{custom_pre_install_command}
if(Get-Command puppet -ErrorAction 0) { return; }
$architecture = if( [Environment]::Is64BitOperatingSystem ) { 'x64' } else { 'x86' }
if( '#{puppet_windows_version}' -eq 'latest' ) {
$MsiUrl = "https://downloads.puppetlabs.com/windows/puppet-agent-${architecture}-latest.msi"
} elseif( '#{puppet_windows_version}' -match '(\\d)\\.' ) {
$MsiUrl = "https://downloads.puppetlabs.com/windows/puppet$($Matches[1])/puppet-agent-#{puppet_windows_version}-${architecture}.msi"
} else {
$MsiUrl = "https://downloads.puppetlabs.com/windows/puppet-agent-#{puppet_windows_version}-${architecture}.msi"
if( '#{puppet_windows_url}' -ne '') {
$MsiUrl = '#{puppet_windows_url}'
}
else
{
$architecture = if( [Environment]::Is64BitOperatingSystem ) { 'x64' } else { 'x86' }
if( '#{puppet_windows_version}' -eq 'latest' ) {
$MsiUrl = "https://downloads.puppetlabs.com/windows/puppet-agent-${architecture}-latest.msi"
} elseif( '#{puppet_windows_version}' -match '(\\d)\\.' ) {
$MsiUrl = "https://downloads.puppetlabs.com/windows/puppet$($Matches[1])/puppet-agent-#{puppet_windows_version}-${architecture}.msi"
} else {
$MsiUrl = "https://downloads.puppetlabs.com/windows/puppet-agent-#{puppet_windows_version}-${architecture}.msi"
}
}
Invoke-WebRequest $MsiUrl -UseBasicParsing -OutFile "C:/puppet-agent.msi" #{posh_proxy_parm}
$process = Start-Process -FilePath msiexec.exe -Wait -PassThru -ArgumentList '/qn', '/norestart', '/i', 'C:\\puppet-agent.msi'
Expand Down Expand Up @@ -975,6 +988,10 @@ def puppet_windows_version
config[:puppet_version] ? config[:puppet_version].to_s : 'latest'
end

def puppet_windows_url
config[:puppet_windows_url]
end

def puppet_environment_flag
if config[:puppet_version] =~ /^2/
config[:puppet_environment] ? "--environment=#{puppet_environment}" : nil
Expand Down

0 comments on commit 5ce29dc

Please sign in to comment.