-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proxy support for Initial install and shell provisioners #229
base: main
Are you sure you want to change the base?
Changes from all commits
d2763ab
0920e78
ef7568f
f83ac26
bb1dffa
67c5e39
127035e
fa1181a
7a0a8db
28eb81e
c0565af
d1ce776
430386a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,3 @@ floppy/_packer_config_*.cmd | |
*.*.json | ||
floppy/*.*.* | ||
script/*.*.* | ||
|
||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This newline is also unnecessary. |
||
# Packer templates for Windows | ||
|
||
### Overview | ||
|
@@ -146,6 +147,19 @@ You can add additional `floppy/_packer_config_*.cmd` files. These files will be | |
|
||
`floppy/_packer_config*.cmd` will be executed in alpabetical order during initial install and at the beginning of each shell provisioner script if the script supports loading them. | ||
|
||
#### Proxy Configuration using `floppy/_packer_config_proxy.cmd` | ||
|
||
Create a file called `floppy/_packer_config_proxy.cmd` with the below contents: | ||
|
||
``` | ||
set http_proxy_user=[proxy_user] | ||
set http_proxy_password=[proxy_password] | ||
set ftp_proxy=http://[proxy_host]:[proxy_port] | ||
set http_proxy=http://[proxy_host]:[proxy_port] | ||
set https_proxy=http://[proxy_host]:[proxy_port] | ||
set no_proxy=127.0.0.1,localhost,[no_proxy_hosts] | ||
``` | ||
|
||
### Acknowledgments | ||
|
||
[Parallels](http://www.parallels.com/) provides a Business Edition license of | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,9 @@ | |
|
||
if not defined PACKER_SEARCH_PATHS set PACKER_SEARCH_PATHS="%USERPROFILE%" a: b: c: d: e: f: g: h: i: j: k: l: m: n: o: p: q: r: s: t: u: v: w: x: y: z: | ||
|
||
set url=%~1 | ||
set "url=%~1" | ||
|
||
set filename=%~2 | ||
set "filename=%~2" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for properly quoting these. It's good style. |
||
|
||
if not defined url echo ==^> ERROR: _download.cmd called without URL parameter. & goto exit1 | ||
|
||
|
@@ -31,8 +31,8 @@ echo ==^> Copying "%found%" to "%filename%", skipping download. | |
copy /y "%found%" "%filename%" && goto exit0 | ||
|
||
:download | ||
|
||
echo ==^> Downloading "%url%" to "%filename%" | ||
REM IT IS JUST CLEANER WITH THIS WGET IS REALLY PICKY. POWERSHELL - NOT SO MUCH | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to justify this with a comment.. Can be removed as well. |
||
if defined http_proxy goto powershell | ||
|
||
set wget= | ||
|
||
|
@@ -46,15 +46,37 @@ if defined wget goto wget | |
|
||
if not exist "%wget%" goto powershell | ||
|
||
echo ==^> Downloading "%url%" to "%filename%" using "%wget%"... | ||
|
||
if not defined PACKER_DEBUG set WGET_OPTS=--no-verbose | ||
|
||
if defined http_proxy ( | ||
if defined http_proxy_user if defined http_proxy_password ( | ||
set WGET_OPTS=%WGET_OPTS% --proxy-user='%http_proxy_user%' --proxy-passwd='%http_proxy_password%' | ||
) | ||
) | ||
|
||
"%wget%" --no-check-certificate %WGET_OPTS% -O "%filename%" "%url%" | ||
|
||
if not errorlevel 1 if exist "%filename%" goto exit0 | ||
|
||
:powershell | ||
echo ==^> Downloading "%url%" to "%filename%" using "Powershell"... | ||
|
||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%url%', '%filename%')" <NUL | ||
if defined http_proxy ( | ||
set "ps1_proxy=$wc.proxy = (new-object System.Net.WebProxy('%http_proxy%')) ;" | ||
if defined http_proxy_user if defined http_proxy_password ( | ||
set "ps1_proxy_auth=$wc.proxy.Credentials = (New-Object System.Net.NetworkCredential('%http_proxy_user%', '%http_proxy_password%')) ;" | ||
) | ||
|
||
if defined no_proxy ( | ||
set "ps1_no_proxy=$wc.proxy.BypassList = (('%no_proxy%').split(',')) ;" | ||
) | ||
) | ||
|
||
set ps1_script="$wc = (New-Object System.Net.WebClient) ; %ps1_proxy% %ps1_proxy_auth% %ps1_no_proxy% $wc.DownloadFile('%url%', '%filename%')" | ||
|
||
powershell -command %ps1_script% >nul | ||
|
||
if not errorlevel 1 if exist "%filename%" goto exit0 | ||
|
||
|
@@ -70,7 +92,9 @@ for %%i in (bitsadmin.exe) do set bitsadmin=%%~$PATH:i | |
|
||
if not defined bitsadmin set bitsadmin=%SystemRoot%\System32\bitsadmin.exe | ||
|
||
if not exist "%bitsadmin%" goto powershell | ||
if not exist "%bitsadmin%" goto exit 1 | ||
|
||
echo ==^> Downloading "%url%" to "%filename%" using "BITS"... | ||
|
||
for %%i in ("%filename%") do set jobname=%%~nxi | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,6 @@ pushd "%BITVISE_DIR%" | |
|
||
if exist "%SystemRoot%\_download.cmd" ( | ||
call "%SystemRoot%\_download.cmd" "%BITVISE_URL%" "%BITVISE_PATH%" | ||
) else ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These conditionals are used to detect if there's some kind of issue with the existence of the download script. If you're going to remove the "else" case, you might as well remove the whole conditional. Ideally, though, you could emit an error and terminate the script if the download.cmd script is not found. However, either way is fine. |
||
echo ==^> Downloading "%BITVISE_URL%" to "%BITVISE_PATH%" | ||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%BITVISE_URL%', '%BITVISE_PATH%')" <NUL | ||
) | ||
if not exist "%BITVISE_PATH%" goto exit1 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,9 +33,6 @@ pushd "%CYGWIN_DIR%" | |
|
||
if exist "%SystemRoot%\_download.cmd" ( | ||
call "%SystemRoot%\_download.cmd" "%CYGWIN_URL%" "%CYGWIN_PATH%" | ||
) else ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (See comment for |
||
echo ==^> Downloading "%CYGWIN_URL%" to "%CYGWIN_PATH%" | ||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%CYGWIN_URL%', '%CYGWIN_PATH%')" <NUL | ||
) | ||
if errorlevel 1 goto exit1 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,9 +29,6 @@ pushd "%HOTFIX_2842230_DIR%" | |
|
||
if exist "%SystemRoot%\_download.cmd" ( | ||
call "%SystemRoot%\_download.cmd" "%HOTFIX_2842230_URL%" "%HOTFIX_2842230_PATH%" | ||
) else ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (See comment for |
||
echo ==^> Downloading "%HOTFIX_2842230_URL%" to "%HOTFIX_2842230_PATH%" | ||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%HOTFIX_2842230_URL%', '%HOTFIX_2842230_PATH%')" <NUL | ||
) | ||
if errorlevel 1 goto exit1 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,6 @@ pushd "%OPENSSH_DIR%" | |
|
||
if exist "%SystemRoot%\_download.cmd" ( | ||
call "%SystemRoot%\_download.cmd" "%OPENSSH_URL%" "%OPENSSH_PATH%" | ||
) else ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (See comment for |
||
echo ==^> Downloading "%OPENSSH_URL%" to "%OPENSSH_PATH%" | ||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%OPENSSH_URL%', '%OPENSSH_PATH%')" <NUL | ||
) | ||
if not exist "%OPENSSH_PATH%" goto exit1 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,9 +22,6 @@ mkdir "%WUA_DIR%" | |
|
||
if exist "%SystemRoot%\_download.cmd" ( | ||
call "%SystemRoot%\_download.cmd" "%WUA_URL%" "%WUA_PATH%" | ||
) else ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (See comment for |
||
echo ==^> Downloading "%WUA_URL%" to "%WUA_PATH%" | ||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%WUA_URL%', '%WUA_PATH%')" <NUL | ||
) | ||
if not exist "%WUA_PATH%" goto exit1 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,6 @@ pushd "%HANDLE_DIR%" | |
|
||
if exist "%SystemRoot%\_download.cmd" ( | ||
call "%SystemRoot%\_download.cmd" "%HANDLE_URL%" "%HANDLE_PATH%" | ||
) else ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (See comment for |
||
echo ==^> Downloading "%HANDLE_URL%" to "%HANDLE_PATH%" | ||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%HANDLE_URL%', '%HANDLE_PATH%')" <NUL | ||
) | ||
if not exist "%HANDLE_PATH%" goto exit1 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,7 @@ set url="https://omnitruck.chef.io/%OMNITRUCK_CHANNEL%/%OMNITRUCK_PRODUCT%/metad | |
set filename="%TEMP%\omnitruck.txt" | ||
|
||
echo ==^> Using Chef Omnitruck API URL: !url! | ||
powershell -command "(New-Object System.Net.WebClient).DownloadFile('!url!', '!filename!')" | ||
call "%SystemRoot%\_download.cmd" !url! !filename! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As per my comment for |
||
|
||
if not exist "%TEMP%\omnitruck.txt" ( | ||
echo Unable to download metadata for %OMNITRUCK_PRODUCT% %OMNITRUCK_VERSION% on the %OMNITRUCK_CHANNEL% channel for %OMNITRUCK_PLATFORM% %OMNITRUCK_MACHINE_ARCH% | ||
|
@@ -136,9 +136,6 @@ pushd "%CHEF_DIR%" | |
|
||
if exist "%SystemRoot%\_download.cmd" ( | ||
call "%SystemRoot%\_download.cmd" "%CHEF_URL%" "%CHEF_PATH%" | ||
) else ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (See prior comment) |
||
echo ==^> Downloading %CHEF_URL% to %CHEF_PATH% | ||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile(\"%CHEF_URL%\", '%CHEF_PATH%')" <NUL | ||
) | ||
if not exist "%CHEF_PATH%" goto exit1 | ||
|
||
|
@@ -215,9 +212,6 @@ pushd "%PUPPET_DIR%" | |
:: todo support CM_VERSION variable | ||
if exist "%SystemRoot%\_download.cmd" ( | ||
call "%SystemRoot%\_download.cmd" "%PUPPET_URL%" "%PUPPET_PATH%" | ||
) else ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (See prior comment) |
||
echo ==^> Downloading %PUPPET_URL% to %PUPPET_PATH% | ||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%PUPPET_URL%', '%PUPPET_PATH%')" <NUL | ||
) | ||
if not exist "%PUPPET_PATH%" goto exit1 | ||
|
||
|
@@ -259,8 +253,9 @@ set SALT_URL=http://raw.githubusercontent.com/saltstack/salt-bootstrap/%SALT_REV | |
set SALT_PATH=%SALT_DIR%\bootstrap-salt.ps1 | ||
set SALT_DOWNLOAD=%SALT_DIR%\bootstrap-salt.download.ps1 | ||
|
||
echo ==^> Downloading %SALT_URL% to %SALT_DOWNLOAD% | ||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%SALT_URL%', '%SALT_DOWNLOAD%')" <NUL | ||
if exist "%SystemRoot%\_download.cmd" ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (See prior comment) |
||
call "%SystemRoot%\_download.cmd" "%SALT_URL%" "%SALT_DOWNLOAD%" | ||
) | ||
|
||
if not exist "%SALT_DOWNLOAD%" goto exit1 | ||
echo ==^> Patching bootstrap-salt.ps1 at %SALT_DOWNLOAD% | ||
|
@@ -301,7 +296,7 @@ if "%CM_VERSION%" == "latest" ( | |
set SALT_PATH=%SALT_DIR%\Salt-Minion-Setup.exe | ||
|
||
echo ==^> Downloading %SALT_URL% to %SALT_PATH% | ||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%SALT_URL%', '%SALT_PATH%')" <NUL | ||
call "%SystemRoot%\_download.cmd" %SALT_URL% %SALT_PATH% | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (See prior comment) |
||
|
||
echo ==^> Installing Salt minion %CM_VERSION%-%SALT_PYTHONVERSION% with %SALT_PATH% | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,6 @@ pushd "%SDELETE_DIR%" | |
|
||
if exist "%SystemRoot%\_download.cmd" ( | ||
call "%SystemRoot%\_download.cmd" "%SDELETE_URL%" "%SDELETE_PATH%" | ||
) else ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (See comment for |
||
echo ==^> Downloading "%SDELETE_URL%" to "%SDELETE_PATH%" | ||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%SDELETE_URL%', '%SDELETE_PATH%')" <NUL | ||
) | ||
if not exist "%SDELETE_PATH%" goto exit1 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,9 +53,6 @@ cd /d "%SEVENZIP_DIR%" | |
|
||
if exist "%SystemRoot%\_download.cmd" ( | ||
call "%SystemRoot%\_download.cmd" "%SEVENZIP_URL%" "%SEVENZIP_PATH%" | ||
) else ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (See comment for |
||
echo ==^> Downloading "%SEVENZIP_URL%" to "%SEVENZIP_PATH%" | ||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%SEVENZIP_URL%', '%SEVENZIP_PATH%')" <NUL | ||
) | ||
if not exist "%SEVENZIP_PATH%" goto return1 | ||
|
||
|
@@ -131,9 +128,6 @@ pushd "%ULTRADEFRAG_DIR%" | |
|
||
if exist "%SystemRoot%\_download.cmd" ( | ||
call "%SystemRoot%\_download.cmd" "%ULTRADEFRAG_URL%" "%ULTRADEFRAG_PATH%" | ||
) else ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (See comment for |
||
echo ==^> Downloading "%ULTRADEFRAG_URL%" to "%ULTRADEFRAG_PATH%" | ||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%ULTRADEFRAG_URL%', '%ULTRADEFRAG_PATH%')" <NUL | ||
) | ||
if not exist "%ULTRADEFRAG_PATH%" goto exit1 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,9 +15,6 @@ pushd "%VAGRANT_DIR%" | |
|
||
if exist "%SystemRoot%\_download.cmd" ( | ||
call "%SystemRoot%\_download.cmd" "%VAGRANT_PUB_URL%" "%VAGRANT_PATH%" | ||
) else ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (See comment for |
||
echo ==^> Downloading "%VAGRANT_PUB_URL%" to "%VAGRANT_PATH%" | ||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%VAGRANT_PUB_URL%', '%VAGRANT_PATH%')" <NUL | ||
) | ||
if not exist "%VAGRANT_PATH%" goto exit1 | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This stray new-line is unnecessary.