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

Use mixlib-install to download and install chef supporting bootstrap on Windows Nano Server #399

Closed
wants to merge 1 commit into from

Conversation

mwrock
Copy link
Member

@mwrock mwrock commented Oct 1, 2016

This PR replaces the current download and install logic in the default knife-windows template with the install command from mixlib-install. There are two primary motivations here:

  1. Align download and install logic accross tooling ecosystem. This puts knife-windows on the same code path as test-kitchen and chef-provisioning.
  2. Enable the bootstrapping of Windows Nano Server nodes. Mixlib-Install supports nano

Currently this PR drops support for the :architecture knife config setting. Mixlib-Install will choose the architecture based on the architecture of the node. It would be straight forward to change mixlib-install to support this. However, 64bit has been out for nearly a year and I think its safe to remove that support.

This PR also drops support for --install-as-service introduced in 1.0.0. Mixlib-install does not support installing as a service. We could add it but we are currently encouraging customers to prefer a scheduled task over service and have removed the service recipie from the chef-client cookbook.

This also requires powershell 2.0 or greater be installed. This is satisfied by default on Windows 2008R2 and higher, but older versions will require the installation of WMF 2.0 or higher. I have added words to the readme to reflect this.

In light of the above two dropped feaures we may consider this a 2.0.

@mwrock
Copy link
Member Author

mwrock commented Oct 1, 2016

This PR "works" in bootstrapping nano and non-nano nodes.

@mwrock
Copy link
Member Author

mwrock commented Oct 2, 2016

image

@mwrock mwrock changed the title WIP: Use mixlib-install to download and install chef Use mixlib-install to download and install chef Oct 2, 2016
@mwrock mwrock changed the title Use mixlib-install to download and install chef Use mixlib-install to download and install chef supporting bootstrap on Windows Nano Server Oct 2, 2016
Signed-off-by: Matt Wrock <matt@mattwrock.com>
@@ -155,6 +149,18 @@ This knife plugins requires >= Chef 11.0.0. More details about Knife plugins can

## Nodes

### Bootstrapping Windows Nano Server

Windows Nano Server cannot install Chef via an MSI. Instead Nano supports the `appx` package format. Until Omnitruck strarts serving appx packages automatically to nano, you will need to provide an appx package URL to the `--msi-url` argument:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not clear to me as a non-chef employee if I have to create these packages or ask someone to build them for me

Windows Nano Server cannot install Chef via an MSI. Instead Nano supports the `appx` package format. Until Omnitruck strarts serving appx packages automatically to nano, you will need to provide an appx package URL to the `--msi-url` argument:

```
knife bootstrap windows winrm 192.168.137.3 -x vagrant -P vagrant -N nano1 --msi-url https://s3-us-west-2.amazonaws.com/nano-chef-client/chef-12.14.60.appx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I find out what these URLs are?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we do change --msi-url it should be something that would make sense once knife-windows is merged to core, e.g. --bootstrap-package-url.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider adding a warning/deprication notice about the --msi-url name


### Powershell version

The node must be running Powershell version 2.0 or higher. Windows 2008 R2 and greater come with a compatible version of Powershell installed by default. If you are trying to bootstrap Windows Server 2008 SP2 or lower, you must install the Windows Management Framework 2.0 or higher in order to succesfully use `knife bootstrap windows winrm`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ask in a slack room like #cft-discuss about 2008 usage?

I wonder if the Chef Version header includes Windows platform version?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib/chef/http/http_request.rb: @headers["X-Chef-Version"] = ::Chef::VERSION

There's more than that in the header. Still looking for where that comes from.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah, same file.

engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"

UA_COMMON = "/#{::Chef::VERSION} (#{engine}-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}; ohai-#{Ohai::VERSION}; #{RUBY_PLATFORM}; +https://chef.io)"
chef (12.14.70)> engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
 => "ruby"
chef (12.14.70)>
chef > UA_COMMON = "/#{::Chef::VERSION} (#{engine}-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}; ohai-#{Ohai::VERSION}; #{RUBY_PLATFORM}; +https://chef.io)"
 => "/12.14.70 (ruby-2.3.1-p112; ohai-8.20.0; x64-mingw32; +https://chef.io)"

So unfortunately the version of Windows isn't included in the User Agent header.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mwrock where did the powershell 2.0 requirement come from? mixlib-install?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2008 R@ EOL was 1/13/2015 for mainstream support. I would presume people are still using it though, which is unfortunate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"yes I did an enterprise workshop for $customer two weeks ago and they had a mix of 2008 R2 and 2012 R2"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS v2. is installed by default on 2k8R2. 2008 (R1) comes with v1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes mixlib-install has the v2 dependency -- it uses try/catch and perhaps other v2isms

option :install_as_service,
:long => "--install-as-service",
:description => "Install chef-client as a Windows service",
:default => false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we drop this feature, we need a clear message about what people should do instead and how they should get there. Maybe a blog post, and then keep this flag but have it raise a message about how this isn't supported that links to the blog post?

Should talk to @charlesjohnson about this. My gut feeling is that we're not ready to just drop this, and we need to pave a better road which will take some time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of Chef 12.18, released 1/23/2017, you can configure the chef-client to run as as scheduled task from the MSI. This is supported in mixlib install (chef/mixlib-install#167) but not yet in knife-windows.

https://blog.chef.io/2017/02/22/running-chef-in-the-background-on-windows/

else
"msiexec /qn /log #{executor_quote}%CHEF_CLIENT_MSI_LOG_PATH%#{executor_quote} /i #{executor_quote}%LOCAL_DESTINATION_MSI_PATH%#{executor_quote}"
end
"msiexec /qn /log #{executor_quote}%CHEF_CLIENT_MSI_LOG_PATH%#{executor_quote} /i #{executor_quote}%LOCAL_DESTINATION_MSI_PATH%#{executor_quote}"
end
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove all the other unused stuff

opts[:prerelease] = config[:prerelease] if config[:prerelease]
puts "opts #{opts}"
write_command_file(
Mixlib::Install::ScriptGenerator.new(Chef::Config[:knife][:bootstrap_version] || true, true, opts).install_command,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's likely not well documented, but Mixlib::Install::ScriptGenerator will be deprecated in a future version. This is the original logic created for Kitchen. You'll want to instantiate Mixlib::Install with the appropriate options then call #install_command.

@wrightp
Copy link

wrightp commented Jan 9, 2018

@mwrock I'm starting to looking into implementing mixlib-install in knife core. Hopefully they'll be enough work complete to make any changes to knife-windows for v1 support easy. My plan is to have windows bootstrap support for ps v2 work natively

@tas50 tas50 removed the Signed CLA label Jul 31, 2018
@tas50 tas50 closed this Oct 23, 2018
@tas50
Copy link
Contributor

tas50 commented Oct 23, 2018

Closing this out since things have drifted so much and windows nano isn't what it once was.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants