Skip to content

Commit 47ba144

Browse files
committed
Installer - Windows as Jump host support
1 parent 08d0668 commit 47ba144

File tree

8 files changed

+84
-11
lines changed

8 files changed

+84
-11
lines changed

plans/util/retrieve_and_upload.pp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@
2929
|-HEREDOC
3030
# lint:endignore
3131

32+
$operating_system = run_task('peadm::os_identification', 'local://localhost')
33+
$os_string = $operating_system.first.value['osfamily']
34+
35+
if os_string == 'windows'{
36+
37+
$exists = run_command("[System.IO.File]::Exists('${local_path}')", 'local://localhost')
38+
39+
if $exists.first['stdout'].chomp == 'false'{
40+
run_task('peadm::download', 'local://localhost',
41+
source => $source,
42+
path => $local_path,
43+
)
44+
}
45+
46+
} else {
3247
$exists = without_default_logging() || {
3348
run_command("test -e '${local_path}'", 'local://localhost',
3449
_catch_errors => true,
@@ -41,10 +56,18 @@
4156
path => $local_path,
4257
)
4358
}
59+
}
4460

61+
if os_string == 'windows'{
62+
$result_size = run_task('peadm::filesize', 'local://localhost',
63+
path => $local_path,
64+
)
65+
$local_size = $result_size['size']
66+
}else{
4567
$local_size = run_task('peadm::filesize', 'local://localhost',
4668
path => $local_path,
4769
).first['size']
70+
}
4871

4972
$targets_needing_file = run_task('peadm::filesize', $nodes,
5073
path => $upload_path,

tasks/download.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
"default": "hkp://keyserver.ubuntu.com:80"
2121
}
2222
},
23-
"input_method": "environment",
2423
"implementations": [
25-
{"name": "download.sh", "requirements": ["shell"]},
24+
{"name": "download.sh", "requirements": ["shell"], "input_method": "environment"},
2625
{"name": "download.ps1", "requirements": ["powershell"]}
2726
]
2827
}

tasks/download.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# dowload.ps1
22
Param(
3-
$source
3+
$source,
44
$path
55
)
6+
67
try {
7-
# Get the File and place in the path
8-
Invoke-WebRequest $source -OutFile $path
8+
[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}; $webClient = New-Object System.Net.WebClient; $webClient.DownloadFile($source, $path);
99
}catch {
1010
Write-Host "Installer failed with Exception: $_.Exception.Message"
1111
Exit 1

tasks/filesize.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
"description": "Path to the file to return the size of"
77
}
88
},
9-
"input_method": "environment",
109
"implementations": [
11-
{"name": "filesize.sh", "requirements": ["shell"]},
10+
{"name": "filesize.sh", "requirements": ["shell"], "input_method": "environment"},
1211
{"name": "filesize.ps1", "requirements": ["powershell"]}
1312
]
1413
}

tasks/filesize.ps1

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,25 @@
22
Param(
33
$path
44
)
5+
if ([string]::IsNullOrEmpty($path)){
6+
Write-Host "No path provided to filesize"
7+
Exit 1
8+
}
59
try {
10+
611
# Get the File
7-
$File = Get-Item $path
12+
$File = Get-Item -Path $path
813
# Get the File Size
914
$size = $File.Length
1015

1116
# Output a JSON result for ease of Task usage in Puppet Task Plans
12-
if (-eq $size "null") {
13-
echo '{ "size": null }'
17+
if ($size -eq $null) {
18+
Write-Host "{'size': '$null'}"
1419
}else{
15-
echo '{ "size": "'$size'" }'
20+
Write-Host "{'size': '$size'}"
1621
}
22+
23+
return @{ size = $size }
1724
}catch {
1825
Write-Host "Installer failed with Exception: $_.Exception.Message"
1926
Exit 1

tasks/os_identification.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"description": "Return the operating system runnin gon the target as a string",
3+
"parameters": { },
4+
"implementations": [
5+
{"name": "os_identification.sh", "requirements": ["shell"], "input_method": "environment"},
6+
{"name": "os_identification.ps1", "requirements": ["powershell"]}
7+
]
8+
}
9+

tasks/os_identification.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# os_identification.ps1
2+
try {
3+
4+
$os = [System.Environment]::OSVersion.Platform
5+
6+
if ($os -eq "Win32NT") {
7+
$osfamily = "windows"
8+
}elseif ($os -eq "Unix") {
9+
$osfamily = "unix"
10+
}else {
11+
$osfamily = "unknown"
12+
}
13+
14+
return @{ osfamily = $osfamily }
15+
}catch {
16+
Write-Host "Installer failed with Exception: $_.Exception.Message"
17+
Exit 1
18+
}

tasks/os_identification.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
2+
osfamily="linux"
3+
elif [[ "$OSTYPE" == "darwin"* ]]; then
4+
osfamily="macOS"
5+
elif [[ "$OSTYPE" == "cygwin" ]]; then
6+
osfamily="cygwin"
7+
elif [[ "$OSTYPE" == "msys" ]]; then
8+
osfamily="msys"
9+
elif [[ "$OSTYPE" == "win32" ]]; then
10+
osfamily="windows"
11+
elif [[ "$OSTYPE" == "freebsd"* ]]; then
12+
osfamily="freebsd"
13+
else
14+
osfamily="unknown"
15+
fi
16+
17+
echo '{ "osfamily": "'$osfamily'" }'
18+

0 commit comments

Comments
 (0)