Skip to content

Commit

Permalink
Merge pull request #929 from puppetlabs/maint-docker-pipeline
Browse files Browse the repository at this point in the history
(MAINT) Fixing pipeline for Windows
  • Loading branch information
jordanbreen28 authored Jul 5, 2023
2 parents 66ba893 + d37fc76 commit 00aae9a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 27 deletions.
1 change: 1 addition & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
provider => powershell,
unless => template('docker/windows/check_powershell_provider.ps1.erb'),
logoutput => true,
timeout => 1800,
notify => Exec['service-restart-on-failure'],
}
}
Expand Down
11 changes: 7 additions & 4 deletions spec/spec_helper_acceptance_local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,13 @@ def fetch_puppet_version
@windows_ip = ip
end
apply_manifest("class { 'docker': docker_ee => true, extra_parameters => '\"insecure-registries\": [ \"#{@windows_ip}:5000\" ]' }", catch_failures: true)
sleep 300
retry_on_error_matching(120, 5, %r{.*}) do
puts 'waiting for VM to restart..'
run_shell('ls') # random command to check connectivity to litmus host
end
docker_path = 'C:\\Program Files\\Docker'
run_shell("set PATH \"%PATH%;C:\\Users\\Administrator\\AppData\\Local\\Temp;#{docker_path}\"")
puts 'Waiting for box to come online'
sleep 300
retry_on_error_matching(120, 5, %r{.*}) do
run_shell("set PATH \"%PATH%;C:\\Users\\Administrator\\AppData\\Local\\Temp;#{docker_path}\"")
end
end
end
4 changes: 2 additions & 2 deletions templates/windows/check_docker.ps1.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# this file checks the status of the Windows Docker package using the DockerMsftProvider powershell provider
$dockerProviderName="DockerMsftProvider"
# this file checks the status of the Windows Docker package using the DockerProvider powershell provider
$dockerProviderName="DockerProvider"

Write-Information "Checking Docker package."
$package=Get-Package <%= @docker_ee_package_name %> -ProviderName $dockerProviderName -ErrorAction Ignore
Expand Down
11 changes: 6 additions & 5 deletions templates/windows/check_powershell_provider.ps1.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# this file checks the status of the Windows Docker package using the DockerMsftProvider powershell provider
# this file checks the status of the Windows Docker package using the DockerProvider powershell provider
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$dockerProviderName="DockerMsftProvider"
$dockerProviderName="DockerProvider"

Write-Information "Checking Package Provider"
$module = Get-PackageProvider NuGet
$module = Get-PackageProvider NuGet -ErrorAction SilentlyContinue
If ($module -eq $null) {
Write-Error "NuGet PackagePrivider is not installed."
Exit 1
}

<% if @nuget_package_provider_version -%>
Write-Information "Checking Package provider version"
if ($module.Version.ToString() -ne "<%= @nuget_package_provider_version %>" ) {
Expand All @@ -18,7 +19,7 @@ if ($module.Version.ToString() -ne "<%= @nuget_package_provider_version %>" ) {


Write-Information "Checking Docker Provider"
$provider = Get-Module -ListAvailable -Name $dockerProviderName
$provider = Get-Module -ListAvailable -Name $dockerProviderName -ErrorAction SilentlyContinue
If ($provider -eq $null) {
Write-Error "Docker Microsoft Docker provider is not installed."
Exit 1
Expand All @@ -33,7 +34,7 @@ if ($provider.Version.ToString() -ne "<%= @docker_msft_provider_version %>" ) {
<% end -%>

Write-Information "Checking Docker package."
$package=Get-Package <%= @docker_ee_package_name %> -ProviderName $dockerProviderName
$package=Get-Package <%= @docker_ee_package_name %> -ProviderName $dockerProviderName -ErrorAction SilentlyContinue
If ($package -eq $null) {
Write-Error "Docker package is not installed."
Exit 1
Expand Down
1 change: 1 addition & 0 deletions templates/windows/download_docker.ps1.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$dockerLocation = Join-Path $env:TEMP "docker.zip"

Invoke-webrequest -UseBasicparsing -Outfile $dockerLocation "<%= @docker_download_url %>"
Expand Down
19 changes: 5 additions & 14 deletions templates/windows/install_powershell_provider.ps1.erb
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
# this file install the Windows Docker package using the DockerMsftProvider powershell provider
# this file install the Windows Docker package using the DockerProvider powershell provider
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$dockerProviderName="DockerMsftProvider"
$dockerProviderName="DockerProvider"

Write-Information "Installing Package Provider"
$module = Install-PackageProvider NuGet -Force `
<% if @nuget_package_provider_version -%>
-RequiredVersion <%= @nuget_package_provider_version %>
<% end -%>
$module = Install-PackageProvider NuGet -Force <%= "-RequiredVersion #{@nuget_package_provider_version}" if @nuget_package_provider_version %>

If ($module -eq $null) {
Write-Error "Failed to install NuGet Package Provider"
Exit 1
}

Write-Information "Installing Docker Provider"
Install-Module $dockerProviderName -Force `
<% if @docker_msft_provider_version -%>
-RequiredVersion <%= @docker_msft_provider_version %>
<% end -%>
Install-Module $dockerProviderName -Force <%= "-RequiredVersion #{@docker_msft_provider_version}" if @docker_msft_provider_version %>

$provider = Get-Module -ListAvailable -Name $dockerProviderName
If ($provider -eq $null) {
Expand All @@ -26,10 +20,7 @@ If ($provider -eq $null) {
}

Write-Information "Installing Docker Package"
$package=Install-Package <%= @docker_ee_package_name %> -ProviderName $dockerProviderName -Force `
<% if @version -%>
-RequiredVersion <%= @version %>
<% end -%>
$package=Install-Package Docker -ProviderName $dockerProviderName -Force <%= "-RequiredVersion #{@version}" if @version %>

If ($package -eq $null) {
Write-Error "Failed to install Docker Package"
Expand Down
4 changes: 2 additions & 2 deletions templates/windows/remove_docker.ps1.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# this file install the Windows Docker package using the DockerMsftProvider powershell provider
$dockerProviderName="DockerMsftProvider"
# this file install the Windows Docker package using the DockerProvider powershell provider
$dockerProviderName="DockerProvider"

$package=Get-Package <%= @docker_ee_package_name %> -ProviderName $dockerProviderName -ErrorAction Ignore
If ($package -ne $null) {
Expand Down

0 comments on commit 00aae9a

Please sign in to comment.