knife-windows 1.7.1 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +4 -0
 - data/RELEASE_NOTES.md +9 -2
 - data/lib/chef/knife/core/windows_bootstrap_context.rb +28 -9
 - data/lib/knife-windows/version.rb +1 -1
 - data/spec/assets/win_template_rendered_with_bootstrap_install_command.txt +3 -6
 - data/spec/assets/win_template_rendered_with_bootstrap_install_command_on_12_5_client.txt +3 -6
 - data/spec/assets/win_template_rendered_without_bootstrap_install_command.txt +3 -6
 - data/spec/assets/win_template_rendered_without_bootstrap_install_command_on_12_5_client.txt +3 -6
 - data/spec/assets/win_template_unrendered.txt +246 -246
 - data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +81 -2
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 8279bbe56fa21988d0b384236c8a1b49251c012a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 86cbdeec5397452f1390935e5c0b54a6af1d2755
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 2da11a8fc34ac1ae4f610d0e1ca6fba2ebe71ab0a028aa0cb1d876eb1364ff46fb7c7c42c4fe1927b8f45b0d4c3083a82be7994bf6f4a9ffc4465b01e53b69c0
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 39fa105069c0f3b16dcd28d666aaf4822e6f62151e505b8e4ece04202a1d8ffade932b1e8a80bfa0bebbccb89c0f91e8753663b215a9b3fc522ff18e10399b1c
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,5 +1,9 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # knife-windows Change Log
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            ## Release 1.8.0
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            * [knife-windows #407](https://github.com/chef/knife-windows/pull/407) Added value for config_log_level and config_log_location
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
       3 
7 
     | 
    
         
             
            ## Release 1.7.1
         
     | 
| 
       4 
8 
     | 
    
         | 
| 
       5 
9 
     | 
    
         
             
            * [knife-windows #409](https://github.com/chef/knife-windows/pull/409) Fix trusted_cert copy script generation on windows
         
     | 
    
        data/RELEASE_NOTES.md
    CHANGED
    
    | 
         @@ -6,5 +6,12 @@ Example Note: 
     | 
|
| 
       6 
6 
     | 
    
         
             
            ## Example Heading
         
     | 
| 
       7 
7 
     | 
    
         
             
            Details about the thing that changed that needs to get included in the Release Notes in markdown.
         
     | 
| 
       8 
8 
     | 
    
         
             
            -->
         
     | 
| 
       9 
     | 
    
         
            -
            # knife-windows 1. 
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 9 
     | 
    
         
            +
            # knife-windows 1.8.0 release notes:
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            This release allows user to specify `config_log_location` and `config_log_level` options in config.rb/knife.rb. This sets the default `log_location` and `log_level` in the `client.rb` file of the node being bootstrapped.
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            This is how you can pass the values in config.rb/knife.rb:
         
     | 
| 
      
 14 
     | 
    
         
            +
            ```
         
     | 
| 
      
 15 
     | 
    
         
            +
            chef_log_level  :debug
         
     | 
| 
      
 16 
     | 
    
         
            +
            chef_log_location "C:/chef.log"    #please make sure that the path exists
         
     | 
| 
      
 17 
     | 
    
         
            +
            ```
         
     | 
| 
         @@ -17,12 +17,10 @@ 
     | 
|
| 
       17 
17 
     | 
    
         
             
            #
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
            require 'chef/knife/core/bootstrap_context'
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
20 
     | 
    
         
             
            # Chef::Util::PathHelper in Chef 11 is a bit juvenile still
         
     | 
| 
       22 
21 
     | 
    
         
             
            require 'knife-windows/path_helper'
         
     | 
| 
       23 
22 
     | 
    
         
             
            # require 'chef/util/path_helper'
         
     | 
| 
       24 
23 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
24 
     | 
    
         
             
            class Chef
         
     | 
| 
       27 
25 
     | 
    
         
             
              class Knife
         
     | 
| 
       28 
26 
     | 
    
         
             
                module Core
         
     | 
| 
         @@ -70,23 +68,26 @@ class Chef 
     | 
|
| 
       70 
68 
     | 
    
         | 
| 
       71 
69 
     | 
    
         
             
                    def config_content
         
     | 
| 
       72 
70 
     | 
    
         
             
                      client_rb = <<-CONFIG
         
     | 
| 
       73 
     | 
    
         
            -
            log_level        :info
         
     | 
| 
       74 
     | 
    
         
            -
            log_location     STDOUT
         
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
71 
     | 
    
         
             
            chef_server_url  "#{@chef_config[:chef_server_url]}"
         
     | 
| 
       77 
72 
     | 
    
         
             
            validation_client_name "#{@chef_config[:validation_client_name]}"
         
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
73 
     | 
    
         
             
            file_cache_path   "c:/chef/cache"
         
     | 
| 
       80 
74 
     | 
    
         
             
            file_backup_path  "c:/chef/backup"
         
     | 
| 
       81 
75 
     | 
    
         
             
            cache_options     ({:path => "c:/chef/cache/checksums", :skip_expires => true})
         
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
            CONFIG
         
     | 
| 
      
 76 
     | 
    
         
            +
                      CONFIG
         
     | 
| 
       84 
77 
     | 
    
         
             
                      if @config[:chef_node_name]
         
     | 
| 
       85 
78 
     | 
    
         
             
                        client_rb << %Q{node_name "#{@config[:chef_node_name]}"\n}
         
     | 
| 
       86 
79 
     | 
    
         
             
                      else
         
     | 
| 
       87 
80 
     | 
    
         
             
                        client_rb << "# Using default node name (fqdn)\n"
         
     | 
| 
       88 
81 
     | 
    
         
             
                      end
         
     | 
| 
       89 
82 
     | 
    
         | 
| 
      
 83 
     | 
    
         
            +
                      if @chef_config[:config_log_level]
         
     | 
| 
      
 84 
     | 
    
         
            +
                        client_rb << %Q{log_level :#{@chef_config[:config_log_level]}\n}
         
     | 
| 
      
 85 
     | 
    
         
            +
                      else
         
     | 
| 
      
 86 
     | 
    
         
            +
                        client_rb << "log_level        :info\n"
         
     | 
| 
      
 87 
     | 
    
         
            +
                      end
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                      client_rb << "log_location       #{get_log_location}"
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
       90 
91 
     | 
    
         
             
                      # We configure :verify_api_cert only when it's overridden on the CLI
         
     | 
| 
       91 
92 
     | 
    
         
             
                      # or when specified in the knife config.
         
     | 
| 
       92 
93 
     | 
    
         
             
                      if !@config[:node_verify_api_cert].nil? || knife_config.has_key?(:verify_api_cert)
         
     | 
| 
         @@ -149,6 +150,24 @@ CONFIG 
     | 
|
| 
       149 
150 
     | 
    
         
             
                      escape_and_echo(client_rb)
         
     | 
| 
       150 
151 
     | 
    
         
             
                    end
         
     | 
| 
       151 
152 
     | 
    
         | 
| 
      
 153 
     | 
    
         
            +
                    def get_log_location
         
     | 
| 
      
 154 
     | 
    
         
            +
                      if @chef_config[:config_log_location].equal?(:win_evt)
         
     | 
| 
      
 155 
     | 
    
         
            +
                        %Q{:#{@chef_config[:config_log_location]}\n}
         
     | 
| 
      
 156 
     | 
    
         
            +
                      elsif @chef_config[:config_log_location].equal?(:syslog)
         
     | 
| 
      
 157 
     | 
    
         
            +
                        raise "syslog is not supported for log_location on Windows OS\n"
         
     | 
| 
      
 158 
     | 
    
         
            +
                      elsif (@chef_config[:config_log_location].equal?(STDOUT))
         
     | 
| 
      
 159 
     | 
    
         
            +
                        "STDOUT\n"
         
     | 
| 
      
 160 
     | 
    
         
            +
                      elsif (@chef_config[:config_log_location].equal?(STDERR))
         
     | 
| 
      
 161 
     | 
    
         
            +
                        "STDERR\n"
         
     | 
| 
      
 162 
     | 
    
         
            +
                      elsif @chef_config[:config_log_location].nil? || @chef_config[:config_log_location].empty?
         
     | 
| 
      
 163 
     | 
    
         
            +
                        "STDOUT\n"
         
     | 
| 
      
 164 
     | 
    
         
            +
                      elsif @chef_config[:config_log_location]
         
     | 
| 
      
 165 
     | 
    
         
            +
                        %Q{"#{@chef_config[:config_log_location]}"\n}
         
     | 
| 
      
 166 
     | 
    
         
            +
                      else
         
     | 
| 
      
 167 
     | 
    
         
            +
                        "STDOUT\n"
         
     | 
| 
      
 168 
     | 
    
         
            +
                      end
         
     | 
| 
      
 169 
     | 
    
         
            +
                    end
         
     | 
| 
      
 170 
     | 
    
         
            +
             
     | 
| 
       152 
171 
     | 
    
         
             
                    def start_chef
         
     | 
| 
       153 
172 
     | 
    
         
             
                      bootstrap_environment_option = bootstrap_environment.nil? ? '' : " -E #{bootstrap_environment}"
         
     | 
| 
       154 
173 
     | 
    
         
             
                      start_chef = "SET \"PATH=%PATH%;C:\\ruby\\bin;C:\\opscode\\chef\\bin;C:\\opscode\\chef\\embedded\\bin\"\n"
         
     | 
| 
         @@ -375,4 +394,4 @@ EOH 
     | 
|
| 
       375 
394 
     | 
    
         
             
                  end
         
     | 
| 
       376 
395 
     | 
    
         
             
                end
         
     | 
| 
       377 
396 
     | 
    
         
             
              end
         
     | 
| 
       378 
     | 
    
         
            -
            end
         
     | 
| 
      
 397 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -199,17 +199,14 @@ echo Validation key written. 
     | 
|
| 
       199 
199 
     | 
    
         | 
| 
       200 
200 
     | 
    
         | 
| 
       201 
201 
     | 
    
         
             
            > C:\chef\client.rb ( 
         
     | 
| 
       202 
     | 
    
         
            -
             echo. 
     | 
| 
       203 
     | 
    
         
            -
            echo.log_location     STDOUT
         
     | 
| 
       204 
     | 
    
         
            -
            echo.
         
     | 
| 
       205 
     | 
    
         
            -
            echo.chef_server_url  "https://localhost:443"
         
     | 
| 
      
 202 
     | 
    
         
            +
             echo.chef_server_url  "https://localhost:443"
         
     | 
| 
       206 
203 
     | 
    
         
             
            echo.validation_client_name "chef-validator"
         
     | 
| 
       207 
     | 
    
         
            -
            echo.
         
     | 
| 
       208 
204 
     | 
    
         
             
            echo.file_cache_path   "c:/chef/cache"
         
     | 
| 
       209 
205 
     | 
    
         
             
            echo.file_backup_path  "c:/chef/backup"
         
     | 
| 
       210 
206 
     | 
    
         
             
            echo.cache_options     ^({:path =^> "c:/chef/cache/checksums", :skip_expires =^> true}^)
         
     | 
| 
       211 
     | 
    
         
            -
            echo.
         
     | 
| 
       212 
207 
     | 
    
         
             
            echo.# Using default node name ^(fqdn^)
         
     | 
| 
      
 208 
     | 
    
         
            +
            echo.log_level        :info
         
     | 
| 
      
 209 
     | 
    
         
            +
            echo.log_location       STDOUT
         
     | 
| 
       213 
210 
     | 
    
         | 
| 
       214 
211 
     | 
    
         
             
            ) 
         
     | 
| 
       215 
212 
     | 
    
         | 
| 
         @@ -199,17 +199,14 @@ echo Validation key written. 
     | 
|
| 
       199 
199 
     | 
    
         | 
| 
       200 
200 
     | 
    
         | 
| 
       201 
201 
     | 
    
         
             
            > C:\chef\client.rb ( 
         
     | 
| 
       202 
     | 
    
         
            -
             echo. 
     | 
| 
       203 
     | 
    
         
            -
            echo.log_location     STDOUT
         
     | 
| 
       204 
     | 
    
         
            -
            echo.
         
     | 
| 
       205 
     | 
    
         
            -
            echo.chef_server_url  "https://localhost:443"
         
     | 
| 
      
 202 
     | 
    
         
            +
             echo.chef_server_url  "https://localhost:443"
         
     | 
| 
       206 
203 
     | 
    
         
             
            echo.validation_client_name "chef-validator"
         
     | 
| 
       207 
     | 
    
         
            -
            echo.
         
     | 
| 
       208 
204 
     | 
    
         
             
            echo.file_cache_path   "c:/chef/cache"
         
     | 
| 
       209 
205 
     | 
    
         
             
            echo.file_backup_path  "c:/chef/backup"
         
     | 
| 
       210 
206 
     | 
    
         
             
            echo.cache_options     ^({:path =^> "c:/chef/cache/checksums", :skip_expires =^> true}^)
         
     | 
| 
       211 
     | 
    
         
            -
            echo.
         
     | 
| 
       212 
207 
     | 
    
         
             
            echo.# Using default node name ^(fqdn^)
         
     | 
| 
      
 208 
     | 
    
         
            +
            echo.log_level        :info
         
     | 
| 
      
 209 
     | 
    
         
            +
            echo.log_location       STDOUT
         
     | 
| 
       213 
210 
     | 
    
         | 
| 
       214 
211 
     | 
    
         
             
            ) 
         
     | 
| 
       215 
212 
     | 
    
         | 
| 
         @@ -311,17 +311,14 @@ echo Validation key written. 
     | 
|
| 
       311 
311 
     | 
    
         | 
| 
       312 
312 
     | 
    
         | 
| 
       313 
313 
     | 
    
         
             
            > C:\chef\client.rb ( 
         
     | 
| 
       314 
     | 
    
         
            -
             echo. 
     | 
| 
       315 
     | 
    
         
            -
            echo.log_location     STDOUT
         
     | 
| 
       316 
     | 
    
         
            -
            echo.
         
     | 
| 
       317 
     | 
    
         
            -
            echo.chef_server_url  "https://localhost:443"
         
     | 
| 
      
 314 
     | 
    
         
            +
             echo.chef_server_url  "https://localhost:443"
         
     | 
| 
       318 
315 
     | 
    
         
             
            echo.validation_client_name "chef-validator"
         
     | 
| 
       319 
     | 
    
         
            -
            echo.
         
     | 
| 
       320 
316 
     | 
    
         
             
            echo.file_cache_path   "c:/chef/cache"
         
     | 
| 
       321 
317 
     | 
    
         
             
            echo.file_backup_path  "c:/chef/backup"
         
     | 
| 
       322 
318 
     | 
    
         
             
            echo.cache_options     ^({:path =^> "c:/chef/cache/checksums", :skip_expires =^> true}^)
         
     | 
| 
       323 
     | 
    
         
            -
            echo.
         
     | 
| 
       324 
319 
     | 
    
         
             
            echo.# Using default node name ^(fqdn^)
         
     | 
| 
      
 320 
     | 
    
         
            +
            echo.log_level        :info
         
     | 
| 
      
 321 
     | 
    
         
            +
            echo.log_location       STDOUT
         
     | 
| 
       325 
322 
     | 
    
         | 
| 
       326 
323 
     | 
    
         
             
            ) 
         
     | 
| 
       327 
324 
     | 
    
         | 
| 
         @@ -311,17 +311,14 @@ echo Validation key written. 
     | 
|
| 
       311 
311 
     | 
    
         | 
| 
       312 
312 
     | 
    
         | 
| 
       313 
313 
     | 
    
         
             
            > C:\chef\client.rb ( 
         
     | 
| 
       314 
     | 
    
         
            -
             echo. 
     | 
| 
       315 
     | 
    
         
            -
            echo.log_location     STDOUT
         
     | 
| 
       316 
     | 
    
         
            -
            echo.
         
     | 
| 
       317 
     | 
    
         
            -
            echo.chef_server_url  "https://localhost:443"
         
     | 
| 
      
 314 
     | 
    
         
            +
             echo.chef_server_url  "https://localhost:443"
         
     | 
| 
       318 
315 
     | 
    
         
             
            echo.validation_client_name "chef-validator"
         
     | 
| 
       319 
     | 
    
         
            -
            echo.
         
     | 
| 
       320 
316 
     | 
    
         
             
            echo.file_cache_path   "c:/chef/cache"
         
     | 
| 
       321 
317 
     | 
    
         
             
            echo.file_backup_path  "c:/chef/backup"
         
     | 
| 
       322 
318 
     | 
    
         
             
            echo.cache_options     ^({:path =^> "c:/chef/cache/checksums", :skip_expires =^> true}^)
         
     | 
| 
       323 
     | 
    
         
            -
            echo.
         
     | 
| 
       324 
319 
     | 
    
         
             
            echo.# Using default node name ^(fqdn^)
         
     | 
| 
      
 320 
     | 
    
         
            +
            echo.log_level        :info
         
     | 
| 
      
 321 
     | 
    
         
            +
            echo.log_location       STDOUT
         
     | 
| 
       325 
322 
     | 
    
         | 
| 
       326 
323 
     | 
    
         
             
            ) 
         
     | 
| 
       327 
324 
     | 
    
         | 
| 
         @@ -1,246 +1,246 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            @rem 
         
     | 
| 
       2 
     | 
    
         
            -
            @rem Author:: Seth Chisamore (<schisamo@opscode.com>) 
         
     | 
| 
       3 
     | 
    
         
            -
            @rem Copyright:: Copyright (c) 2011 Opscode, Inc. 
         
     | 
| 
       4 
     | 
    
         
            -
            @rem License:: Apache License, Version 2.0 
         
     | 
| 
       5 
     | 
    
         
            -
            @rem 
         
     | 
| 
       6 
     | 
    
         
            -
            @rem Licensed under the Apache License, Version 2.0 (the "License"); 
         
     | 
| 
       7 
     | 
    
         
            -
            @rem you may not use this file except in compliance with the License. 
         
     | 
| 
       8 
     | 
    
         
            -
            @rem You may obtain a copy of the License at 
         
     | 
| 
       9 
     | 
    
         
            -
            @rem 
         
     | 
| 
       10 
     | 
    
         
            -
            @rem     http://www.apache.org/licenses/LICENSE-2.0 
         
     | 
| 
       11 
     | 
    
         
            -
            @rem 
         
     | 
| 
       12 
     | 
    
         
            -
            @rem Unless required by applicable law or agreed to in writing, software 
         
     | 
| 
       13 
     | 
    
         
            -
            @rem distributed under the License is distributed on an "AS IS" BASIS, 
         
     | 
| 
       14 
     | 
    
         
            -
            @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
         
     | 
| 
       15 
     | 
    
         
            -
            @rem See the License for the specific language governing permissions and 
         
     | 
| 
       16 
     | 
    
         
            -
            @rem limitations under the License. 
         
     | 
| 
       17 
     | 
    
         
            -
            @rem 
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
            @rem Use delayed environment expansion so that ERRORLEVEL can be evaluated with the 
         
     | 
| 
       20 
     | 
    
         
            -
            @rem !ERRORLEVEL! syntax which evaluates at execution of the line of script, not when 
         
     | 
| 
       21 
     | 
    
         
            -
            @rem the line is read. See help for the /E switch from cmd.exe /? . 
         
     | 
| 
       22 
     | 
    
         
            -
            @setlocal ENABLEDELAYEDEXPANSION 
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
            <%= "SETX HTTP_PROXY \"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] %> 
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
            @set BOOTSTRAP_DIRECTORY=<%= bootstrap_directory %> 
         
     | 
| 
       27 
     | 
    
         
            -
            @echo Checking for existing directory "%BOOTSTRAP_DIRECTORY%"... 
         
     | 
| 
       28 
     | 
    
         
            -
            @if NOT EXIST %BOOTSTRAP_DIRECTORY% ( 
         
     | 
| 
       29 
     | 
    
         
            -
                @echo Existing directory not found, creating. 
         
     | 
| 
       30 
     | 
    
         
            -
                @mkdir %BOOTSTRAP_DIRECTORY% 
         
     | 
| 
       31 
     | 
    
         
            -
            ) else ( 
         
     | 
| 
       32 
     | 
    
         
            -
                @echo Existing directory found, skipping creation. 
         
     | 
| 
       33 
     | 
    
         
            -
            ) 
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
            > <%= bootstrap_directory %>\wget.vbs ( 
         
     | 
| 
       36 
     | 
    
         
            -
             <%= win_wget %> 
         
     | 
| 
       37 
     | 
    
         
            -
            ) 
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
            > <%= bootstrap_directory %>\wget.ps1 ( 
         
     | 
| 
       40 
     | 
    
         
            -
             <%= win_wget_ps %> 
         
     | 
| 
       41 
     | 
    
         
            -
            ) 
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
            @rem Determine the version and the architecture 
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
            @FOR /F "usebackq tokens=1-8 delims=.[] " %%A IN (`ver`) DO ( 
         
     | 
| 
       46 
     | 
    
         
            -
            @set WinMajor=%%D 
         
     | 
| 
       47 
     | 
    
         
            -
            @set WinMinor=%%E 
         
     | 
| 
       48 
     | 
    
         
            -
            @set WinBuild=%%F 
         
     | 
| 
       49 
     | 
    
         
            -
            ) 
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
            @echo Detected Windows Version %WinMajor%.%WinMinor% Build %WinBuild% 
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
            @set LATEST_OS_VERSION_MAJOR=6 
         
     | 
| 
       54 
     | 
    
         
            -
            @set LATEST_OS_VERSION_MINOR=3 
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
            @if /i %WinMajor% GTR %LATEST_OS_VERSION_MAJOR% goto VersionUnknown 
         
     | 
| 
       57 
     | 
    
         
            -
            @if /i %WinMajor% EQU %LATEST_OS_VERSION_MAJOR%  ( 
         
     | 
| 
       58 
     | 
    
         
            -
              @if /i %WinMinor% GTR %LATEST_OS_VERSION_MINOR% goto VersionUnknown 
         
     | 
| 
       59 
     | 
    
         
            -
            ) 
         
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
            goto Version%WinMajor%.%WinMinor% 
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
            :VersionUnknown 
         
     | 
| 
       64 
     | 
    
         
            -
            @rem If this is an unknown version of windows set the default 
         
     | 
| 
       65 
     | 
    
         
            -
            @set MACHINE_OS=2008r2 
         
     | 
| 
       66 
     | 
    
         
            -
            @echo Warning: Unknown version of Windows, assuming default of Windows %MACHINE_OS% 
         
     | 
| 
       67 
     | 
    
         
            -
            goto architecture_select 
         
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
            :Version6.0 
         
     | 
| 
       70 
     | 
    
         
            -
            @set MACHINE_OS=2008 
         
     | 
| 
       71 
     | 
    
         
            -
            goto architecture_select 
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
            :Version5.2 
         
     | 
| 
       74 
     | 
    
         
            -
            @set MACHINE_OS=2003r2 
         
     | 
| 
       75 
     | 
    
         
            -
            goto architecture_select 
         
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
            :Version6.1 
         
     | 
| 
       78 
     | 
    
         
            -
            @set MACHINE_OS=2008r2 
         
     | 
| 
       79 
     | 
    
         
            -
            goto architecture_select 
         
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
            :Version6.2 
         
     | 
| 
       82 
     | 
    
         
            -
            @set MACHINE_OS=2012 
         
     | 
| 
       83 
     | 
    
         
            -
            goto architecture_select 
         
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
            @rem Currently Windows Server 2012 R2 is treated as equivalent to Windows Server 2012 
         
     | 
| 
       86 
     | 
    
         
            -
            :Version6.3 
         
     | 
| 
       87 
     | 
    
         
            -
            goto Version6.2 
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
            :architecture_select 
         
     | 
| 
       90 
     | 
    
         
            -
            goto Architecture%PROCESSOR_ARCHITEW6432% 
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
            :Architecture 
         
     | 
| 
       93 
     | 
    
         
            -
            goto Architecture%PROCESSOR_ARCHITECTURE% 
         
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
            @rem If this is an unknown architecture set the default 
         
     | 
| 
       96 
     | 
    
         
            -
            @set MACHINE_ARCH=i686 
         
     | 
| 
       97 
     | 
    
         
            -
            goto install 
         
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
            :Architecturex86 
         
     | 
| 
       100 
     | 
    
         
            -
            @set MACHINE_ARCH=i686 
         
     | 
| 
       101 
     | 
    
         
            -
            goto install 
         
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
            :Architectureamd64 
         
     | 
| 
       104 
     | 
    
         
            -
            @set MACHINE_ARCH=x86_64 
         
     | 
| 
       105 
     | 
    
         
            -
            goto install 
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
            :install 
         
     | 
| 
       108 
     | 
    
         
            -
            @rem If user has provided the custom installation command for chef-client then execute it 
         
     | 
| 
       109 
     | 
    
         
            -
            <% if @chef_config[:knife][:bootstrap_install_command] %> 
         
     | 
| 
       110 
     | 
    
         
            -
              <%= @chef_config[:knife][:bootstrap_install_command] %> 
         
     | 
| 
       111 
     | 
    
         
            -
            <% else %> 
         
     | 
| 
       112 
     | 
    
         
            -
              @rem Install Chef using chef-client MSI installer 
         
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
              @set "LOCAL_DESTINATION_MSI_PATH=<%= local_download_path %>" 
         
     | 
| 
       115 
     | 
    
         
            -
              @set "CHEF_CLIENT_MSI_LOG_PATH=%TEMP%\chef-client-msi%RANDOM%.log" 
         
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
              @rem Clear any pre-existing downloads 
         
     | 
| 
       118 
     | 
    
         
            -
              @echo Checking for existing downloaded package at "%LOCAL_DESTINATION_MSI_PATH%" 
         
     | 
| 
       119 
     | 
    
         
            -
              @if EXIST "%LOCAL_DESTINATION_MSI_PATH%" ( 
         
     | 
| 
       120 
     | 
    
         
            -
                  @echo Found existing downloaded package, deleting. 
         
     | 
| 
       121 
     | 
    
         
            -
                  @del /f /q "%LOCAL_DESTINATION_MSI_PATH%" 
         
     | 
| 
       122 
     | 
    
         
            -
                  @if ERRORLEVEL 1 ( 
         
     | 
| 
       123 
     | 
    
         
            -
                      echo Warning: Failed to delete pre-existing package with status code !ERRORLEVEL! > "&2" 
         
     | 
| 
       124 
     | 
    
         
            -
                  ) 
         
     | 
| 
       125 
     | 
    
         
            -
              ) else ( 
         
     | 
| 
       126 
     | 
    
         
            -
                  echo No existing downloaded packages to delete. 
         
     | 
| 
       127 
     | 
    
         
            -
                ) 
         
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
              @rem If there is somehow a name collision, remove pre-existing log 
         
     | 
| 
       130 
     | 
    
         
            -
              @if EXIST "%CHEF_CLIENT_MSI_LOG_PATH%" del /f /q "%CHEF_CLIENT_MSI_LOG_PATH%" 
         
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
              @echo Attempting to download client package using PowerShell if available... 
         
     | 
| 
       133 
     | 
    
         
            -
              @set "REMOTE_SOURCE_MSI_URL=<%= msi_url('%MACHINE_OS%', '%MACHINE_ARCH%', 'PowerShell') %>" 
         
     | 
| 
       134 
     | 
    
         
            -
              @set powershell_download=powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File  <%= bootstrap_directory %>\wget.ps1 "%REMOTE_SOURCE_MSI_URL%" "%LOCAL_DESTINATION_MSI_PATH%" 
         
     | 
| 
       135 
     | 
    
         
            -
              @echo !powershell_download! 
         
     | 
| 
       136 
     | 
    
         
            -
              @call !powershell_download! 
         
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
       138 
     | 
    
         
            -
              @set DOWNLOAD_ERROR_STATUS=!ERRORLEVEL! 
         
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
       140 
     | 
    
         
            -
              @if ERRORLEVEL 1 ( 
         
     | 
| 
       141 
     | 
    
         
            -
                  @echo Failed PowerShell download with status code !DOWNLOAD_ERROR_STATUS! > "&2" 
         
     | 
| 
       142 
     | 
    
         
            -
                  @if !DOWNLOAD_ERROR_STATUS!==0 set DOWNLOAD_ERROR_STATUS=2 
         
     | 
| 
       143 
     | 
    
         
            -
              ) else ( 
         
     | 
| 
       144 
     | 
    
         
            -
                  @rem Sometimes the error level is not set even when the download failed, 
         
     | 
| 
       145 
     | 
    
         
            -
                  @rem so check for the file to be sure it is there -- if it is not, we will retry 
         
     | 
| 
       146 
     | 
    
         
            -
                  @if NOT EXIST "%LOCAL_DESTINATION_MSI_PATH%" ( 
         
     | 
| 
       147 
     | 
    
         
            -
                      echo Failed download: download completed, but downloaded file not found > "&2" 
         
     | 
| 
       148 
     | 
    
         
            -
                      set DOWNLOAD_ERROR_STATUS=2 
         
     | 
| 
       149 
     | 
    
         
            -
                  ) else ( 
         
     | 
| 
       150 
     | 
    
         
            -
                      echo Download via PowerShell succeeded. 
         
     | 
| 
       151 
     | 
    
         
            -
                    ) 
         
     | 
| 
       152 
     | 
    
         
            -
                ) 
         
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
              @if NOT %DOWNLOAD_ERROR_STATUS%==0 ( 
         
     | 
| 
       155 
     | 
    
         
            -
                  @echo Warning: Failed to download "%REMOTE_SOURCE_MSI_URL%" to "%LOCAL_DESTINATION_MSI_PATH%" 
         
     | 
| 
       156 
     | 
    
         
            -
                  @echo Warning: Retrying download with cscript ... 
         
     | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
       158 
     | 
    
         
            -
                  @if EXIST "%LOCAL_DESTINATION_MSI_PATH%" del /f /q "%LOCAL_DESTINATION_MSI_PATH%" 
         
     | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
       160 
     | 
    
         
            -
                  @set "REMOTE_SOURCE_MSI_URL=<%= msi_url('%MACHINE_OS%', '%MACHINE_ARCH%') %>" 
         
     | 
| 
       161 
     | 
    
         
            -
                  cscript /nologo <%= bootstrap_directory %>\wget.vbs /url:"%REMOTE_SOURCE_MSI_URL%" /path:"%LOCAL_DESTINATION_MSI_PATH%" 
         
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
       163 
     | 
    
         
            -
                  @if NOT ERRORLEVEL 1 ( 
         
     | 
| 
       164 
     | 
    
         
            -
                      @rem Sometimes the error level is not set even when the download failed, 
         
     | 
| 
       165 
     | 
    
         
            -
                      @rem so check for the file to be sure it is there. 
         
     | 
| 
       166 
     | 
    
         
            -
                      @if NOT EXIST "%LOCAL_DESTINATION_MSI_PATH%" ( 
         
     | 
| 
       167 
     | 
    
         
            -
                          echo Failed download: download completed, but downloaded file not found > "&2" 
         
     | 
| 
       168 
     | 
    
         
            -
                          echo Exiting without bootstrapping due to download failure. > "&2" 
         
     | 
| 
       169 
     | 
    
         
            -
                          exit /b 1 
         
     | 
| 
       170 
     | 
    
         
            -
                      ) else ( 
         
     | 
| 
       171 
     | 
    
         
            -
                          echo Download via cscript succeeded. 
         
     | 
| 
       172 
     | 
    
         
            -
                        ) 
         
     | 
| 
       173 
     | 
    
         
            -
                  ) else ( 
         
     | 
| 
       174 
     | 
    
         
            -
                      echo Failed to download "%REMOTE_SOURCE_MSI_URL%" with status code !ERRORLEVEL!. > "&2" 
         
     | 
| 
       175 
     | 
    
         
            -
                      echo Exiting without bootstrapping due to download failure. > "&2" 
         
     | 
| 
       176 
     | 
    
         
            -
                      exit /b 1 
         
     | 
| 
       177 
     | 
    
         
            -
                    ) 
         
     | 
| 
       178 
     | 
    
         
            -
              ) 
         
     | 
| 
       179 
     | 
    
         
            -
             
     | 
| 
       180 
     | 
    
         
            -
              @echo Installing downloaded client package... 
         
     | 
| 
       181 
     | 
    
         
            -
             
     | 
| 
       182 
     | 
    
         
            -
              <%= install_chef %> 
         
     | 
| 
       183 
     | 
    
         
            -
             
     | 
| 
       184 
     | 
    
         
            -
              @if ERRORLEVEL 1 ( 
         
     | 
| 
       185 
     | 
    
         
            -
                  echo Chef-client package failed to install with status code !ERRORLEVEL!. > "&2" 
         
     | 
| 
       186 
     | 
    
         
            -
                  echo See installation log for additional detail: %CHEF_CLIENT_MSI_LOG_PATH%. > "&2" 
         
     | 
| 
       187 
     | 
    
         
            -
              ) else ( 
         
     | 
| 
       188 
     | 
    
         
            -
                  @echo Installation completed successfully 
         
     | 
| 
       189 
     | 
    
         
            -
                  del /f /q "%CHEF_CLIENT_MSI_LOG_PATH%" 
         
     | 
| 
       190 
     | 
    
         
            -
                ) 
         
     | 
| 
       191 
     | 
    
         
            -
             
     | 
| 
       192 
     | 
    
         
            -
            <% end %> 
         
     | 
| 
       193 
     | 
    
         
            -
             
     | 
| 
       194 
     | 
    
         
            -
            @endlocal 
         
     | 
| 
       195 
     | 
    
         
            -
             
     | 
| 
       196 
     | 
    
         
            -
            @echo off 
         
     | 
| 
       197 
     | 
    
         
            -
             
     | 
| 
       198 
     | 
    
         
            -
            <% if client_pem -%> 
         
     | 
| 
       199 
     | 
    
         
            -
            > <%= bootstrap_directory %>\client.pem ( 
         
     | 
| 
       200 
     | 
    
         
            -
             <%= escape_and_echo(::File.read(::File.expand_path(client_pem))) %> 
         
     | 
| 
       201 
     | 
    
         
            -
            ) 
         
     | 
| 
       202 
     | 
    
         
            -
            <% end -%> 
         
     | 
| 
       203 
     | 
    
         
            -
             
     | 
| 
       204 
     | 
    
         
            -
            echo Writing validation key... 
         
     | 
| 
       205 
     | 
    
         
            -
             
     | 
| 
       206 
     | 
    
         
            -
            <% if validation_key -%> 
         
     | 
| 
       207 
     | 
    
         
            -
            > <%= bootstrap_directory %>\validation.pem ( 
         
     | 
| 
       208 
     | 
    
         
            -
             <%= escape_and_echo(validation_key) %> 
         
     | 
| 
       209 
     | 
    
         
            -
            ) 
         
     | 
| 
       210 
     | 
    
         
            -
            <% end -%> 
         
     | 
| 
       211 
     | 
    
         
            -
             
     | 
| 
       212 
     | 
    
         
            -
            echo Validation key written. 
         
     | 
| 
       213 
     | 
    
         
            -
            @echo on 
         
     | 
| 
       214 
     | 
    
         
            -
             
     | 
| 
       215 
     | 
    
         
            -
            <% if @config[:secret] -%> 
         
     | 
| 
       216 
     | 
    
         
            -
            > <%= bootstrap_directory %>\encrypted_data_bag_secret ( 
         
     | 
| 
       217 
     | 
    
         
            -
             <%= secret %> 
         
     | 
| 
       218 
     | 
    
         
            -
            ) 
         
     | 
| 
       219 
     | 
    
         
            -
            <% end -%> 
         
     | 
| 
       220 
     | 
    
         
            -
             
     | 
| 
       221 
     | 
    
         
            -
            <% unless trusted_certs_script.empty? -%> 
         
     | 
| 
       222 
     | 
    
         
            -
            mkdir <%= bootstrap_directory %>\trusted_certs 
         
     | 
| 
       223 
     | 
    
         
            -
            <%= trusted_certs_script %> 
         
     | 
| 
       224 
     | 
    
         
            -
            <% end -%> 
         
     | 
| 
       225 
     | 
    
         
            -
             
     | 
| 
       226 
     | 
    
         
            -
            <%# Generate Ohai Hints -%> 
         
     | 
| 
       227 
     | 
    
         
            -
            <% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%> 
         
     | 
| 
       228 
     | 
    
         
            -
            mkdir <%= bootstrap_directory %>\ohai\hints 
         
     | 
| 
       229 
     | 
    
         
            -
             
     | 
| 
       230 
     | 
    
         
            -
            <% @chef_config[:knife][:hints].each do |name, hash| -%> 
         
     | 
| 
       231 
     | 
    
         
            -
            > <%= bootstrap_directory %>\ohai\hints\<%= name %>.json ( 
         
     | 
| 
       232 
     | 
    
         
            -
              <%= escape_and_echo(hash.to_json) %> 
         
     | 
| 
       233 
     | 
    
         
            -
            ) 
         
     | 
| 
       234 
     | 
    
         
            -
            <% end -%> 
         
     | 
| 
       235 
     | 
    
         
            -
            <% end -%> 
         
     | 
| 
       236 
     | 
    
         
            -
             
     | 
| 
       237 
     | 
    
         
            -
            > <%= bootstrap_directory %>\client.rb ( 
         
     | 
| 
       238 
     | 
    
         
            -
             <%= config_content %> 
         
     | 
| 
       239 
     | 
    
         
            -
            ) 
         
     | 
| 
       240 
     | 
    
         
            -
             
     | 
| 
       241 
     | 
    
         
            -
            > <%= bootstrap_directory %>\first-boot.json ( 
         
     | 
| 
       242 
     | 
    
         
            -
             <%= first_boot %> 
         
     | 
| 
       243 
     | 
    
         
            -
            ) 
         
     | 
| 
       244 
     | 
    
         
            -
             
     | 
| 
       245 
     | 
    
         
            -
            @echo Starting chef to bootstrap the node... 
         
     | 
| 
       246 
     | 
    
         
            -
            <%= start_chef %> 
         
     | 
| 
      
 1 
     | 
    
         
            +
            @rem 
         
     | 
| 
      
 2 
     | 
    
         
            +
            @rem Author:: Seth Chisamore (<schisamo@opscode.com>) 
         
     | 
| 
      
 3 
     | 
    
         
            +
            @rem Copyright:: Copyright (c) 2011 Opscode, Inc. 
         
     | 
| 
      
 4 
     | 
    
         
            +
            @rem License:: Apache License, Version 2.0 
         
     | 
| 
      
 5 
     | 
    
         
            +
            @rem 
         
     | 
| 
      
 6 
     | 
    
         
            +
            @rem Licensed under the Apache License, Version 2.0 (the "License"); 
         
     | 
| 
      
 7 
     | 
    
         
            +
            @rem you may not use this file except in compliance with the License. 
         
     | 
| 
      
 8 
     | 
    
         
            +
            @rem You may obtain a copy of the License at 
         
     | 
| 
      
 9 
     | 
    
         
            +
            @rem 
         
     | 
| 
      
 10 
     | 
    
         
            +
            @rem     http://www.apache.org/licenses/LICENSE-2.0 
         
     | 
| 
      
 11 
     | 
    
         
            +
            @rem 
         
     | 
| 
      
 12 
     | 
    
         
            +
            @rem Unless required by applicable law or agreed to in writing, software 
         
     | 
| 
      
 13 
     | 
    
         
            +
            @rem distributed under the License is distributed on an "AS IS" BASIS, 
         
     | 
| 
      
 14 
     | 
    
         
            +
            @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
         
     | 
| 
      
 15 
     | 
    
         
            +
            @rem See the License for the specific language governing permissions and 
         
     | 
| 
      
 16 
     | 
    
         
            +
            @rem limitations under the License. 
         
     | 
| 
      
 17 
     | 
    
         
            +
            @rem 
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            @rem Use delayed environment expansion so that ERRORLEVEL can be evaluated with the 
         
     | 
| 
      
 20 
     | 
    
         
            +
            @rem !ERRORLEVEL! syntax which evaluates at execution of the line of script, not when 
         
     | 
| 
      
 21 
     | 
    
         
            +
            @rem the line is read. See help for the /E switch from cmd.exe /? . 
         
     | 
| 
      
 22 
     | 
    
         
            +
            @setlocal ENABLEDELAYEDEXPANSION 
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            <%= "SETX HTTP_PROXY \"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] %> 
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            @set BOOTSTRAP_DIRECTORY=<%= bootstrap_directory %> 
         
     | 
| 
      
 27 
     | 
    
         
            +
            @echo Checking for existing directory "%BOOTSTRAP_DIRECTORY%"... 
         
     | 
| 
      
 28 
     | 
    
         
            +
            @if NOT EXIST %BOOTSTRAP_DIRECTORY% ( 
         
     | 
| 
      
 29 
     | 
    
         
            +
                @echo Existing directory not found, creating. 
         
     | 
| 
      
 30 
     | 
    
         
            +
                @mkdir %BOOTSTRAP_DIRECTORY% 
         
     | 
| 
      
 31 
     | 
    
         
            +
            ) else ( 
         
     | 
| 
      
 32 
     | 
    
         
            +
                @echo Existing directory found, skipping creation. 
         
     | 
| 
      
 33 
     | 
    
         
            +
            ) 
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            > <%= bootstrap_directory %>\wget.vbs ( 
         
     | 
| 
      
 36 
     | 
    
         
            +
             <%= win_wget %> 
         
     | 
| 
      
 37 
     | 
    
         
            +
            ) 
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            > <%= bootstrap_directory %>\wget.ps1 ( 
         
     | 
| 
      
 40 
     | 
    
         
            +
             <%= win_wget_ps %> 
         
     | 
| 
      
 41 
     | 
    
         
            +
            ) 
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            @rem Determine the version and the architecture 
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            @FOR /F "usebackq tokens=1-8 delims=.[] " %%A IN (`ver`) DO ( 
         
     | 
| 
      
 46 
     | 
    
         
            +
            @set WinMajor=%%D 
         
     | 
| 
      
 47 
     | 
    
         
            +
            @set WinMinor=%%E 
         
     | 
| 
      
 48 
     | 
    
         
            +
            @set WinBuild=%%F 
         
     | 
| 
      
 49 
     | 
    
         
            +
            ) 
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            @echo Detected Windows Version %WinMajor%.%WinMinor% Build %WinBuild% 
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            @set LATEST_OS_VERSION_MAJOR=6 
         
     | 
| 
      
 54 
     | 
    
         
            +
            @set LATEST_OS_VERSION_MINOR=3 
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
            @if /i %WinMajor% GTR %LATEST_OS_VERSION_MAJOR% goto VersionUnknown 
         
     | 
| 
      
 57 
     | 
    
         
            +
            @if /i %WinMajor% EQU %LATEST_OS_VERSION_MAJOR%  ( 
         
     | 
| 
      
 58 
     | 
    
         
            +
              @if /i %WinMinor% GTR %LATEST_OS_VERSION_MINOR% goto VersionUnknown 
         
     | 
| 
      
 59 
     | 
    
         
            +
            ) 
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            goto Version%WinMajor%.%WinMinor% 
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
            :VersionUnknown 
         
     | 
| 
      
 64 
     | 
    
         
            +
            @rem If this is an unknown version of windows set the default 
         
     | 
| 
      
 65 
     | 
    
         
            +
            @set MACHINE_OS=2008r2 
         
     | 
| 
      
 66 
     | 
    
         
            +
            @echo Warning: Unknown version of Windows, assuming default of Windows %MACHINE_OS% 
         
     | 
| 
      
 67 
     | 
    
         
            +
            goto architecture_select 
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
            :Version6.0 
         
     | 
| 
      
 70 
     | 
    
         
            +
            @set MACHINE_OS=2008 
         
     | 
| 
      
 71 
     | 
    
         
            +
            goto architecture_select 
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
            :Version5.2 
         
     | 
| 
      
 74 
     | 
    
         
            +
            @set MACHINE_OS=2003r2 
         
     | 
| 
      
 75 
     | 
    
         
            +
            goto architecture_select 
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
            :Version6.1 
         
     | 
| 
      
 78 
     | 
    
         
            +
            @set MACHINE_OS=2008r2 
         
     | 
| 
      
 79 
     | 
    
         
            +
            goto architecture_select 
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
            :Version6.2 
         
     | 
| 
      
 82 
     | 
    
         
            +
            @set MACHINE_OS=2012 
         
     | 
| 
      
 83 
     | 
    
         
            +
            goto architecture_select 
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
            @rem Currently Windows Server 2012 R2 is treated as equivalent to Windows Server 2012 
         
     | 
| 
      
 86 
     | 
    
         
            +
            :Version6.3 
         
     | 
| 
      
 87 
     | 
    
         
            +
            goto Version6.2 
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
            :architecture_select 
         
     | 
| 
      
 90 
     | 
    
         
            +
            goto Architecture%PROCESSOR_ARCHITEW6432% 
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
            :Architecture 
         
     | 
| 
      
 93 
     | 
    
         
            +
            goto Architecture%PROCESSOR_ARCHITECTURE% 
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
            @rem If this is an unknown architecture set the default 
         
     | 
| 
      
 96 
     | 
    
         
            +
            @set MACHINE_ARCH=i686 
         
     | 
| 
      
 97 
     | 
    
         
            +
            goto install 
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
            :Architecturex86 
         
     | 
| 
      
 100 
     | 
    
         
            +
            @set MACHINE_ARCH=i686 
         
     | 
| 
      
 101 
     | 
    
         
            +
            goto install 
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
            :Architectureamd64 
         
     | 
| 
      
 104 
     | 
    
         
            +
            @set MACHINE_ARCH=x86_64 
         
     | 
| 
      
 105 
     | 
    
         
            +
            goto install 
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
            :install 
         
     | 
| 
      
 108 
     | 
    
         
            +
            @rem If user has provided the custom installation command for chef-client then execute it 
         
     | 
| 
      
 109 
     | 
    
         
            +
            <% if @chef_config[:knife][:bootstrap_install_command] %> 
         
     | 
| 
      
 110 
     | 
    
         
            +
              <%= @chef_config[:knife][:bootstrap_install_command] %> 
         
     | 
| 
      
 111 
     | 
    
         
            +
            <% else %> 
         
     | 
| 
      
 112 
     | 
    
         
            +
              @rem Install Chef using chef-client MSI installer 
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
              @set "LOCAL_DESTINATION_MSI_PATH=<%= local_download_path %>" 
         
     | 
| 
      
 115 
     | 
    
         
            +
              @set "CHEF_CLIENT_MSI_LOG_PATH=%TEMP%\chef-client-msi%RANDOM%.log" 
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
              @rem Clear any pre-existing downloads 
         
     | 
| 
      
 118 
     | 
    
         
            +
              @echo Checking for existing downloaded package at "%LOCAL_DESTINATION_MSI_PATH%" 
         
     | 
| 
      
 119 
     | 
    
         
            +
              @if EXIST "%LOCAL_DESTINATION_MSI_PATH%" ( 
         
     | 
| 
      
 120 
     | 
    
         
            +
                  @echo Found existing downloaded package, deleting. 
         
     | 
| 
      
 121 
     | 
    
         
            +
                  @del /f /q "%LOCAL_DESTINATION_MSI_PATH%" 
         
     | 
| 
      
 122 
     | 
    
         
            +
                  @if ERRORLEVEL 1 ( 
         
     | 
| 
      
 123 
     | 
    
         
            +
                      echo Warning: Failed to delete pre-existing package with status code !ERRORLEVEL! > "&2" 
         
     | 
| 
      
 124 
     | 
    
         
            +
                  ) 
         
     | 
| 
      
 125 
     | 
    
         
            +
              ) else ( 
         
     | 
| 
      
 126 
     | 
    
         
            +
                  echo No existing downloaded packages to delete. 
         
     | 
| 
      
 127 
     | 
    
         
            +
                ) 
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
              @rem If there is somehow a name collision, remove pre-existing log 
         
     | 
| 
      
 130 
     | 
    
         
            +
              @if EXIST "%CHEF_CLIENT_MSI_LOG_PATH%" del /f /q "%CHEF_CLIENT_MSI_LOG_PATH%" 
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
              @echo Attempting to download client package using PowerShell if available... 
         
     | 
| 
      
 133 
     | 
    
         
            +
              @set "REMOTE_SOURCE_MSI_URL=<%= msi_url('%MACHINE_OS%', '%MACHINE_ARCH%', 'PowerShell') %>" 
         
     | 
| 
      
 134 
     | 
    
         
            +
              @set powershell_download=powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File  <%= bootstrap_directory %>\wget.ps1 "%REMOTE_SOURCE_MSI_URL%" "%LOCAL_DESTINATION_MSI_PATH%" 
         
     | 
| 
      
 135 
     | 
    
         
            +
              @echo !powershell_download! 
         
     | 
| 
      
 136 
     | 
    
         
            +
              @call !powershell_download! 
         
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
      
 138 
     | 
    
         
            +
              @set DOWNLOAD_ERROR_STATUS=!ERRORLEVEL! 
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
              @if ERRORLEVEL 1 ( 
         
     | 
| 
      
 141 
     | 
    
         
            +
                  @echo Failed PowerShell download with status code !DOWNLOAD_ERROR_STATUS! > "&2" 
         
     | 
| 
      
 142 
     | 
    
         
            +
                  @if !DOWNLOAD_ERROR_STATUS!==0 set DOWNLOAD_ERROR_STATUS=2 
         
     | 
| 
      
 143 
     | 
    
         
            +
              ) else ( 
         
     | 
| 
      
 144 
     | 
    
         
            +
                  @rem Sometimes the error level is not set even when the download failed, 
         
     | 
| 
      
 145 
     | 
    
         
            +
                  @rem so check for the file to be sure it is there -- if it is not, we will retry 
         
     | 
| 
      
 146 
     | 
    
         
            +
                  @if NOT EXIST "%LOCAL_DESTINATION_MSI_PATH%" ( 
         
     | 
| 
      
 147 
     | 
    
         
            +
                      echo Failed download: download completed, but downloaded file not found > "&2" 
         
     | 
| 
      
 148 
     | 
    
         
            +
                      set DOWNLOAD_ERROR_STATUS=2 
         
     | 
| 
      
 149 
     | 
    
         
            +
                  ) else ( 
         
     | 
| 
      
 150 
     | 
    
         
            +
                      echo Download via PowerShell succeeded. 
         
     | 
| 
      
 151 
     | 
    
         
            +
                    ) 
         
     | 
| 
      
 152 
     | 
    
         
            +
                ) 
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
              @if NOT %DOWNLOAD_ERROR_STATUS%==0 ( 
         
     | 
| 
      
 155 
     | 
    
         
            +
                  @echo Warning: Failed to download "%REMOTE_SOURCE_MSI_URL%" to "%LOCAL_DESTINATION_MSI_PATH%" 
         
     | 
| 
      
 156 
     | 
    
         
            +
                  @echo Warning: Retrying download with cscript ... 
         
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
      
 158 
     | 
    
         
            +
                  @if EXIST "%LOCAL_DESTINATION_MSI_PATH%" del /f /q "%LOCAL_DESTINATION_MSI_PATH%" 
         
     | 
| 
      
 159 
     | 
    
         
            +
             
     | 
| 
      
 160 
     | 
    
         
            +
                  @set "REMOTE_SOURCE_MSI_URL=<%= msi_url('%MACHINE_OS%', '%MACHINE_ARCH%') %>" 
         
     | 
| 
      
 161 
     | 
    
         
            +
                  cscript /nologo <%= bootstrap_directory %>\wget.vbs /url:"%REMOTE_SOURCE_MSI_URL%" /path:"%LOCAL_DESTINATION_MSI_PATH%" 
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                  @if NOT ERRORLEVEL 1 ( 
         
     | 
| 
      
 164 
     | 
    
         
            +
                      @rem Sometimes the error level is not set even when the download failed, 
         
     | 
| 
      
 165 
     | 
    
         
            +
                      @rem so check for the file to be sure it is there. 
         
     | 
| 
      
 166 
     | 
    
         
            +
                      @if NOT EXIST "%LOCAL_DESTINATION_MSI_PATH%" ( 
         
     | 
| 
      
 167 
     | 
    
         
            +
                          echo Failed download: download completed, but downloaded file not found > "&2" 
         
     | 
| 
      
 168 
     | 
    
         
            +
                          echo Exiting without bootstrapping due to download failure. > "&2" 
         
     | 
| 
      
 169 
     | 
    
         
            +
                          exit /b 1 
         
     | 
| 
      
 170 
     | 
    
         
            +
                      ) else ( 
         
     | 
| 
      
 171 
     | 
    
         
            +
                          echo Download via cscript succeeded. 
         
     | 
| 
      
 172 
     | 
    
         
            +
                        ) 
         
     | 
| 
      
 173 
     | 
    
         
            +
                  ) else ( 
         
     | 
| 
      
 174 
     | 
    
         
            +
                      echo Failed to download "%REMOTE_SOURCE_MSI_URL%" with status code !ERRORLEVEL!. > "&2" 
         
     | 
| 
      
 175 
     | 
    
         
            +
                      echo Exiting without bootstrapping due to download failure. > "&2" 
         
     | 
| 
      
 176 
     | 
    
         
            +
                      exit /b 1 
         
     | 
| 
      
 177 
     | 
    
         
            +
                    ) 
         
     | 
| 
      
 178 
     | 
    
         
            +
              ) 
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
              @echo Installing downloaded client package... 
         
     | 
| 
      
 181 
     | 
    
         
            +
             
     | 
| 
      
 182 
     | 
    
         
            +
              <%= install_chef %> 
         
     | 
| 
      
 183 
     | 
    
         
            +
             
     | 
| 
      
 184 
     | 
    
         
            +
              @if ERRORLEVEL 1 ( 
         
     | 
| 
      
 185 
     | 
    
         
            +
                  echo Chef-client package failed to install with status code !ERRORLEVEL!. > "&2" 
         
     | 
| 
      
 186 
     | 
    
         
            +
                  echo See installation log for additional detail: %CHEF_CLIENT_MSI_LOG_PATH%. > "&2" 
         
     | 
| 
      
 187 
     | 
    
         
            +
              ) else ( 
         
     | 
| 
      
 188 
     | 
    
         
            +
                  @echo Installation completed successfully 
         
     | 
| 
      
 189 
     | 
    
         
            +
                  del /f /q "%CHEF_CLIENT_MSI_LOG_PATH%" 
         
     | 
| 
      
 190 
     | 
    
         
            +
                ) 
         
     | 
| 
      
 191 
     | 
    
         
            +
             
     | 
| 
      
 192 
     | 
    
         
            +
            <% end %> 
         
     | 
| 
      
 193 
     | 
    
         
            +
             
     | 
| 
      
 194 
     | 
    
         
            +
            @endlocal 
         
     | 
| 
      
 195 
     | 
    
         
            +
             
     | 
| 
      
 196 
     | 
    
         
            +
            @echo off 
         
     | 
| 
      
 197 
     | 
    
         
            +
             
     | 
| 
      
 198 
     | 
    
         
            +
            <% if client_pem -%> 
         
     | 
| 
      
 199 
     | 
    
         
            +
            > <%= bootstrap_directory %>\client.pem ( 
         
     | 
| 
      
 200 
     | 
    
         
            +
             <%= escape_and_echo(::File.read(::File.expand_path(client_pem))) %> 
         
     | 
| 
      
 201 
     | 
    
         
            +
            ) 
         
     | 
| 
      
 202 
     | 
    
         
            +
            <% end -%> 
         
     | 
| 
      
 203 
     | 
    
         
            +
             
     | 
| 
      
 204 
     | 
    
         
            +
            echo Writing validation key... 
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
            <% if validation_key -%> 
         
     | 
| 
      
 207 
     | 
    
         
            +
            > <%= bootstrap_directory %>\validation.pem ( 
         
     | 
| 
      
 208 
     | 
    
         
            +
             <%= escape_and_echo(validation_key) %> 
         
     | 
| 
      
 209 
     | 
    
         
            +
            ) 
         
     | 
| 
      
 210 
     | 
    
         
            +
            <% end -%> 
         
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
      
 212 
     | 
    
         
            +
            echo Validation key written. 
         
     | 
| 
      
 213 
     | 
    
         
            +
            @echo on 
         
     | 
| 
      
 214 
     | 
    
         
            +
             
     | 
| 
      
 215 
     | 
    
         
            +
            <% if @config[:secret] -%> 
         
     | 
| 
      
 216 
     | 
    
         
            +
            > <%= bootstrap_directory %>\encrypted_data_bag_secret ( 
         
     | 
| 
      
 217 
     | 
    
         
            +
             <%= secret %> 
         
     | 
| 
      
 218 
     | 
    
         
            +
            ) 
         
     | 
| 
      
 219 
     | 
    
         
            +
            <% end -%> 
         
     | 
| 
      
 220 
     | 
    
         
            +
             
     | 
| 
      
 221 
     | 
    
         
            +
            <% unless trusted_certs_script.empty? -%> 
         
     | 
| 
      
 222 
     | 
    
         
            +
            mkdir <%= bootstrap_directory %>\trusted_certs 
         
     | 
| 
      
 223 
     | 
    
         
            +
            <%= trusted_certs_script %> 
         
     | 
| 
      
 224 
     | 
    
         
            +
            <% end -%> 
         
     | 
| 
      
 225 
     | 
    
         
            +
             
     | 
| 
      
 226 
     | 
    
         
            +
            <%# Generate Ohai Hints -%> 
         
     | 
| 
      
 227 
     | 
    
         
            +
            <% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%> 
         
     | 
| 
      
 228 
     | 
    
         
            +
            mkdir <%= bootstrap_directory %>\ohai\hints 
         
     | 
| 
      
 229 
     | 
    
         
            +
             
     | 
| 
      
 230 
     | 
    
         
            +
            <% @chef_config[:knife][:hints].each do |name, hash| -%> 
         
     | 
| 
      
 231 
     | 
    
         
            +
            > <%= bootstrap_directory %>\ohai\hints\<%= name %>.json ( 
         
     | 
| 
      
 232 
     | 
    
         
            +
              <%= escape_and_echo(hash.to_json) %> 
         
     | 
| 
      
 233 
     | 
    
         
            +
            ) 
         
     | 
| 
      
 234 
     | 
    
         
            +
            <% end -%> 
         
     | 
| 
      
 235 
     | 
    
         
            +
            <% end -%> 
         
     | 
| 
      
 236 
     | 
    
         
            +
             
     | 
| 
      
 237 
     | 
    
         
            +
            > <%= bootstrap_directory %>\client.rb ( 
         
     | 
| 
      
 238 
     | 
    
         
            +
             <%= config_content %> 
         
     | 
| 
      
 239 
     | 
    
         
            +
            ) 
         
     | 
| 
      
 240 
     | 
    
         
            +
             
     | 
| 
      
 241 
     | 
    
         
            +
            > <%= bootstrap_directory %>\first-boot.json ( 
         
     | 
| 
      
 242 
     | 
    
         
            +
             <%= first_boot %> 
         
     | 
| 
      
 243 
     | 
    
         
            +
            ) 
         
     | 
| 
      
 244 
     | 
    
         
            +
             
     | 
| 
      
 245 
     | 
    
         
            +
            @echo Starting chef to bootstrap the node... 
         
     | 
| 
      
 246 
     | 
    
         
            +
            <%= start_chef %> 
         
     | 
| 
         @@ -17,7 +17,7 @@ 
     | 
|
| 
       17 
17 
     | 
    
         
             
            #
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
            require 'spec_helper'
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 20 
     | 
    
         
            +
            require 'chef/knife/core/windows_bootstrap_context'
         
     | 
| 
       21 
21 
     | 
    
         
             
            describe Chef::Knife::Core::WindowsBootstrapContext do
         
     | 
| 
       22 
22 
     | 
    
         
             
              let(:mock_bootstrap_context) { Chef::Knife::Core::WindowsBootstrapContext.new({ }, nil, { :knife => {} }) }
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
         @@ -99,6 +99,86 @@ describe Chef::Knife::Core::WindowsBootstrapContext do 
     | 
|
| 
       99 
99 
     | 
    
         
             
                end
         
     | 
| 
       100 
100 
     | 
    
         
             
              end
         
     | 
| 
       101 
101 
     | 
    
         | 
| 
      
 102 
     | 
    
         
            +
              describe "#get_log_location" do
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                context "when config_log_location value is nil" do
         
     | 
| 
      
 105 
     | 
    
         
            +
                  it "sets STDOUT in client.rb as default" do
         
     | 
| 
      
 106 
     | 
    
         
            +
                    mock_bootstrap_context.instance_variable_set(:@chef_config, Mash.new(:config_log_location => nil))
         
     | 
| 
      
 107 
     | 
    
         
            +
                    expect(mock_bootstrap_context.get_log_location).to eq("STDOUT\n")
         
     | 
| 
      
 108 
     | 
    
         
            +
                  end
         
     | 
| 
      
 109 
     | 
    
         
            +
                end
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
                context "when config_log_location value is empty" do
         
     | 
| 
      
 112 
     | 
    
         
            +
                  it "sets STDOUT in client.rb as default" do
         
     | 
| 
      
 113 
     | 
    
         
            +
                    mock_bootstrap_context.instance_variable_set(:@chef_config, Mash.new(:config_log_location => ""))
         
     | 
| 
      
 114 
     | 
    
         
            +
                    expect(mock_bootstrap_context.get_log_location).to eq("STDOUT\n")
         
     | 
| 
      
 115 
     | 
    
         
            +
                  end
         
     | 
| 
      
 116 
     | 
    
         
            +
                end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                context "when config_log_location value is STDOUT" do
         
     | 
| 
      
 119 
     | 
    
         
            +
                  it "sets STDOUT in client.rb" do
         
     | 
| 
      
 120 
     | 
    
         
            +
                    mock_bootstrap_context.instance_variable_set(:@chef_config, Mash.new(:config_log_location => STDOUT))
         
     | 
| 
      
 121 
     | 
    
         
            +
                    expect(mock_bootstrap_context.get_log_location).to eq("STDOUT\n")
         
     | 
| 
      
 122 
     | 
    
         
            +
                  end
         
     | 
| 
      
 123 
     | 
    
         
            +
                end
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
                context "when config_log_location value is STDERR" do
         
     | 
| 
      
 126 
     | 
    
         
            +
                  it "sets STDERR in client.rb" do
         
     | 
| 
      
 127 
     | 
    
         
            +
                    mock_bootstrap_context.instance_variable_set(:@chef_config, Mash.new(:config_log_location => STDERR))
         
     | 
| 
      
 128 
     | 
    
         
            +
                    expect(mock_bootstrap_context.get_log_location).to eq("STDERR\n")
         
     | 
| 
      
 129 
     | 
    
         
            +
                  end
         
     | 
| 
      
 130 
     | 
    
         
            +
                end
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
                context "when config_log_location value is path to a file" do
         
     | 
| 
      
 133 
     | 
    
         
            +
                  it "sets file path in client.rb" do
         
     | 
| 
      
 134 
     | 
    
         
            +
                    mock_bootstrap_context.instance_variable_set(:@chef_config, Mash.new(:config_log_location => "C:\\chef\\chef.log"))
         
     | 
| 
      
 135 
     | 
    
         
            +
                    expect(mock_bootstrap_context.get_log_location).to eq("\"C:\\chef\\chef.log\"\n")
         
     | 
| 
      
 136 
     | 
    
         
            +
                  end
         
     | 
| 
      
 137 
     | 
    
         
            +
                end
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                context "when config_log_location value is :win_evt" do
         
     | 
| 
      
 140 
     | 
    
         
            +
                  it "sets :win_evt in client.rb" do
         
     | 
| 
      
 141 
     | 
    
         
            +
                    mock_bootstrap_context.instance_variable_set(:@chef_config, Mash.new(:config_log_location => :win_evt))
         
     | 
| 
      
 142 
     | 
    
         
            +
                    expect(mock_bootstrap_context.get_log_location).to eq(":win_evt\n")
         
     | 
| 
      
 143 
     | 
    
         
            +
                  end
         
     | 
| 
      
 144 
     | 
    
         
            +
                end
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
                context "when config_log_location value is :syslog" do
         
     | 
| 
      
 147 
     | 
    
         
            +
                  it "raise error with message and exit" do
         
     | 
| 
      
 148 
     | 
    
         
            +
                    mock_bootstrap_context.instance_variable_set(:@chef_config, Mash.new(:config_log_location => :syslog))
         
     | 
| 
      
 149 
     | 
    
         
            +
                    expect { mock_bootstrap_context.get_log_location }.to raise_error("syslog is not supported for log_location on Windows OS\n")
         
     | 
| 
      
 150 
     | 
    
         
            +
                  end
         
     | 
| 
      
 151 
     | 
    
         
            +
                end
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
              end
         
     | 
| 
      
 154 
     | 
    
         
            +
             
     | 
| 
      
 155 
     | 
    
         
            +
              describe "#config_content" do
         
     | 
| 
      
 156 
     | 
    
         
            +
                before do
         
     | 
| 
      
 157 
     | 
    
         
            +
                  mock_bootstrap_context.instance_variable_set(:@chef_config, Mash.new(:config_log_level => :info,
         
     | 
| 
      
 158 
     | 
    
         
            +
                    :config_log_location => STDOUT,
         
     | 
| 
      
 159 
     | 
    
         
            +
                    :chef_server_url => "http://chef.example.com:4444",
         
     | 
| 
      
 160 
     | 
    
         
            +
                    :validation_client_name => "chef-validator-testing",
         
     | 
| 
      
 161 
     | 
    
         
            +
                    :file_cache_path => "c:/chef/cache",
         
     | 
| 
      
 162 
     | 
    
         
            +
                    :file_backup_path => "c:/chef/backup",
         
     | 
| 
      
 163 
     | 
    
         
            +
                    :cache_options => ({:path => "c:/chef/cache/checksums", :skip_expires => true})
         
     | 
| 
      
 164 
     | 
    
         
            +
                    ))
         
     | 
| 
      
 165 
     | 
    
         
            +
                end
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
                it "generates the config file data" do
         
     | 
| 
      
 168 
     | 
    
         
            +
                  expected = <<-EXPECTED
         
     | 
| 
      
 169 
     | 
    
         
            +
            echo.chef_server_url  "http://chef.example.com:4444"
         
     | 
| 
      
 170 
     | 
    
         
            +
            echo.validation_client_name "chef-validator-testing"
         
     | 
| 
      
 171 
     | 
    
         
            +
            echo.file_cache_path   "c:/chef/cache"
         
     | 
| 
      
 172 
     | 
    
         
            +
            echo.file_backup_path  "c:/chef/backup"
         
     | 
| 
      
 173 
     | 
    
         
            +
            echo.cache_options     ^({:path =^> "c:/chef/cache/checksums", :skip_expires =^> true}^)
         
     | 
| 
      
 174 
     | 
    
         
            +
            echo.# Using default node name ^(fqdn^)
         
     | 
| 
      
 175 
     | 
    
         
            +
            echo.log_level :info
         
     | 
| 
      
 176 
     | 
    
         
            +
            echo.log_location       STDOUT
         
     | 
| 
      
 177 
     | 
    
         
            +
            EXPECTED
         
     | 
| 
      
 178 
     | 
    
         
            +
                expect(mock_bootstrap_context.config_content).to eq expected
         
     | 
| 
      
 179 
     | 
    
         
            +
                end
         
     | 
| 
      
 180 
     | 
    
         
            +
              end
         
     | 
| 
      
 181 
     | 
    
         
            +
             
     | 
| 
       102 
182 
     | 
    
         
             
              describe "latest_current_windows_chef_version_query" do
         
     | 
| 
       103 
183 
     | 
    
         
             
                it "returns the major version of the current version of Chef" do
         
     | 
| 
       104 
184 
     | 
    
         
             
                  stub_const("Chef::VERSION", '11.1.2')
         
     | 
| 
         @@ -209,5 +289,4 @@ describe Chef::Knife::Core::WindowsBootstrapContext do 
     | 
|
| 
       209 
289 
     | 
    
         
             
                  end
         
     | 
| 
       210 
290 
     | 
    
         
             
                end
         
     | 
| 
       211 
291 
     | 
    
         
             
              end
         
     | 
| 
       212 
     | 
    
         
            -
             
     | 
| 
       213 
292 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: knife-windows
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.8.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Seth Chisamore
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2016- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-12-23 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: winrm
         
     |