Skip to content
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

adding client.rb rubygems_url if exists in knife.rb or Chef::Config[:… #418

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/chef/knife/core/windows_bootstrap_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ def config_content
CONFIG
end

# For setting up Chef::Config[:rubygems_url]
# in client.rb for windows runs outside user profile C:\ProgramData

if @chef_config[:rubygems_url]
client_rb << %Q{rubygems_url "#{@chef_config[:rubygems_url]}"}
end

escape_and_echo(client_rb)
end

Expand All @@ -171,7 +178,7 @@ def get_log_location
def start_chef
bootstrap_environment_option = bootstrap_environment.nil? ? '' : " -E #{bootstrap_environment}"
start_chef = "SET \"PATH=%PATH%;C:\\ruby\\bin;C:\\opscode\\chef\\bin;C:\\opscode\\chef\\embedded\\bin\"\n"
start_chef << "chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json#{bootstrap_environment_option}\n"
start_chef << "chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json#{bootstrap_environment_option}"
end

def latest_current_windows_chef_version_query
Expand Down Expand Up @@ -394,4 +401,4 @@ def fallback_install_task_command
end
end
end
end
end
205 changes: 102 additions & 103 deletions spec/assets/win_template_rendered_with_bootstrap_install_command.txt
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
@rem
@rem Author:: Seth Chisamore (<schisamo@opscode.com>)
@rem Copyright:: Copyright (c) 2011 Opscode, Inc.
@rem License:: Apache License, Version 2.0
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@rem Use delayed environment expansion so that ERRORLEVEL can be evaluated with the
@rem !ERRORLEVEL! syntax which evaluates at execution of the line of script, not when
@rem the line is read. See help for the /E switch from cmd.exe /? .
@setlocal ENABLEDELAYEDEXPANSION


@set BOOTSTRAP_DIRECTORY=C:\chef
@echo Checking for existing directory "%BOOTSTRAP_DIRECTORY%"...
@if NOT EXIST %BOOTSTRAP_DIRECTORY% (
@echo Existing directory not found, creating.
@mkdir %BOOTSTRAP_DIRECTORY%
) else (
@echo Existing directory found, skipping creation.
)

> C:\chef\wget.vbs (
@rem
@rem Author:: Seth Chisamore (<schisamo@opscode.com>)
@rem Copyright:: Copyright (c) 2011 Opscode, Inc.
@rem License:: Apache License, Version 2.0
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@rem Use delayed environment expansion so that ERRORLEVEL can be evaluated with the
@rem !ERRORLEVEL! syntax which evaluates at execution of the line of script, not when
@rem the line is read. See help for the /E switch from cmd.exe /? .
@setlocal ENABLEDELAYEDEXPANSION



@set BOOTSTRAP_DIRECTORY=C:\chef
@echo Checking for existing directory "%BOOTSTRAP_DIRECTORY%"...
@if NOT EXIST %BOOTSTRAP_DIRECTORY% (
@echo Existing directory not found, creating.
@mkdir %BOOTSTRAP_DIRECTORY%
) else (
@echo Existing directory found, skipping creation.
)

> C:\chef\wget.vbs (
echo.url = WScript.Arguments.Named^("url"^)
echo.path = WScript.Arguments.Named^("path"^)
echo.proxy = null
Expand Down Expand Up @@ -95,10 +95,10 @@ echo.Set objADOStream = Nothing
echo.End If
echo.Set objXMLHTTP = Nothing
echo.End If

)

> C:\chef\wget.ps1 (
)

> C:\chef\wget.ps1 (
echo.param^(
echo. [String] $remoteUrl,
echo. [String] $localPath
Expand All @@ -113,92 +113,92 @@ echo. $WebClient.Proxy = $WebProxy
echo.}
echo.
echo.$webClient.DownloadFile^($remoteUrl, $localPath^);

)

@rem Determine the version and the architecture
)

@rem Determine the version and the architecture

@FOR /F "usebackq tokens=1-8 delims=.[] " %%A IN (`ver`) DO (
@set WinMajor=%%D
@set WinMinor=%%E
@set WinBuild=%%F
)
@FOR /F "usebackq tokens=1-8 delims=.[] " %%A IN (`ver`) DO (
@set WinMajor=%%D
@set WinMinor=%%E
@set WinBuild=%%F
)

@echo Detected Windows Version %WinMajor%.%WinMinor% Build %WinBuild%
@echo Detected Windows Version %WinMajor%.%WinMinor% Build %WinBuild%

@set LATEST_OS_VERSION_MAJOR=6
@set LATEST_OS_VERSION_MINOR=3
@set LATEST_OS_VERSION_MAJOR=6
@set LATEST_OS_VERSION_MINOR=3

@if /i %WinMajor% GTR %LATEST_OS_VERSION_MAJOR% goto VersionUnknown
@if /i %WinMajor% EQU %LATEST_OS_VERSION_MAJOR% (
@if /i %WinMinor% GTR %LATEST_OS_VERSION_MINOR% goto VersionUnknown
)
@if /i %WinMajor% GTR %LATEST_OS_VERSION_MAJOR% goto VersionUnknown
@if /i %WinMajor% EQU %LATEST_OS_VERSION_MAJOR% (
@if /i %WinMinor% GTR %LATEST_OS_VERSION_MINOR% goto VersionUnknown
)

goto Version%WinMajor%.%WinMinor%
goto Version%WinMajor%.%WinMinor%

:VersionUnknown
@rem If this is an unknown version of windows set the default
@set MACHINE_OS=2008r2
@echo Warning: Unknown version of Windows, assuming default of Windows %MACHINE_OS%
goto architecture_select
:VersionUnknown
@rem If this is an unknown version of windows set the default
@set MACHINE_OS=2008r2
@echo Warning: Unknown version of Windows, assuming default of Windows %MACHINE_OS%
goto architecture_select

:Version6.0
@set MACHINE_OS=2008
goto architecture_select
:Version6.0
@set MACHINE_OS=2008
goto architecture_select

:Version5.2
@set MACHINE_OS=2003r2
goto architecture_select
:Version5.2
@set MACHINE_OS=2003r2
goto architecture_select

:Version6.1
@set MACHINE_OS=2008r2
goto architecture_select
:Version6.1
@set MACHINE_OS=2008r2
goto architecture_select

:Version6.2
@set MACHINE_OS=2012
goto architecture_select
:Version6.2
@set MACHINE_OS=2012
goto architecture_select

@rem Currently Windows Server 2012 R2 is treated as equivalent to Windows Server 2012
:Version6.3
goto Version6.2
@rem Currently Windows Server 2012 R2 is treated as equivalent to Windows Server 2012
:Version6.3
goto Version6.2

:architecture_select
goto Architecture%PROCESSOR_ARCHITEW6432%
:architecture_select
goto Architecture%PROCESSOR_ARCHITEW6432%

:Architecture
goto Architecture%PROCESSOR_ARCHITECTURE%
:Architecture
goto Architecture%PROCESSOR_ARCHITECTURE%

@rem If this is an unknown architecture set the default
@set MACHINE_ARCH=i686
goto install
@rem If this is an unknown architecture set the default
@set MACHINE_ARCH=i686
goto install

:Architecturex86
@set MACHINE_ARCH=i686
goto install
:Architecturex86
@set MACHINE_ARCH=i686
goto install

:Architectureamd64
@set MACHINE_ARCH=x86_64
goto install
:Architectureamd64
@set MACHINE_ARCH=x86_64
goto install

:install
@rem If user has provided the custom installation command for chef-client then execute it
chef-client -o recipe[cbk1::rec2]
:install
@rem If user has provided the custom installation command for chef-client then execute it
chef-client -o recipe[cbk1::rec2]

@endlocal
@endlocal

@echo off
@echo off


echo Writing validation key...
echo Writing validation key...


echo Validation key written.
@echo on
echo Validation key written.
@echo on




> C:\chef\client.rb (
> C:\chef\client.rb (
echo.chef_server_url "https://localhost:443"
echo.validation_client_name "chef-validator"
echo.file_cache_path "c:/chef/cache"
Expand All @@ -207,14 +207,13 @@ echo.cache_options ^({:path =^> "c:/chef/cache/checksums", :skip_expires =^>
echo.# Using default node name ^(fqdn^)
echo.log_level :info
echo.log_location STDOUT
)
echo.rubygems_url "https://rubygems.org"
)

> C:\chef\first-boot.json (
echo.{"run_list":null}
)
> C:\chef\first-boot.json (
echo.{"run_list":null}
)

@echo Starting chef to bootstrap the node...
@echo Starting chef to bootstrap the node...
SET "PATH=%PATH%;C:\ruby\bin;C:\opscode\chef\bin;C:\opscode\chef\embedded\bin"
chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json