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

windows-guest-support: wrong path for chef-client #565

Closed
btm opened this issue Dec 18, 2014 · 27 comments
Closed

windows-guest-support: wrong path for chef-client #565

btm opened this issue Dec 18, 2014 · 27 comments
Labels

Comments

@btm
Copy link
Contributor

btm commented Dec 18, 2014

the windows-guest-support branch doesn't appear to support looking for omnibus on a windows guest.

or maybe its that I'm using a windows host? not sure yet.

>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Failed to complete #converge action: [Transport WinRM exited (1) using shell [powershell] for command: [/opt/chef/bin/chef-client --local-mode --config /tmp/kitchen/client.rb --log_level auto --force-formatter --no-color --chef-zero-port 8889 --json-attributes /tmp/kitchen/dna.json]
REMOTE ERROR:
/opt/chef/bin/chef-client : The term '/opt/chef/bin/chef-client' is not
recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:42
+  $ProgressPreference='SilentlyContinue'; /opt/chef/bin/chef-client
--local-mode  ...
+                                          ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (/opt/chef/bin/chef-client:Strin
   g) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException]
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
@robcoward
Copy link

@btm I think this error got introduced by #381 - you can work around it by adding the following to your .kitchen.yml

provisioner:
  name: chef_zero
  require_chef_omnibus: true
  chef_client_path: "c:/opscode/chef/bin/chef-client.bat"

@afiune
Copy link
Contributor

afiune commented Feb 6, 2015

I've seen this! I think it is a problem on the way the new chef-client it's been install.. For some reason it was some troubles with ruby and how it is beating compile to create the .bat - I would ask into the windows hipchat channel -

Can you verify the version that it's installed on the windows guest please.

@mattstratton
Copy link

I'm getting this issue myself now. I tried the workaround proposed by @robcoward but it doesn't seem to help for me.

What's weird (or not weird I guess) is that after the first kitchen converge, which throws the error, the second time it works.

@afiune
Copy link
Contributor

afiune commented Feb 6, 2015

@mattstratton @btm what version of chef-client do you have on your windows_guest?

@mattstratton
Copy link

This occurs with both 11.16.4 and 12.0.3.

@mattstratton
Copy link

OK, so doing a bit more research, this is only happening on my win2k8r2 box. It's working on 2k12r2 (both client 11 and client 12)

@mattstratton
Copy link

FYI, @jdmundrawala pointed out that my particular issue #596 is not a dupe of this one, but it is a dupe of #601

@irabinovitch
Copy link

Confirmed on 2008r2 as well. Will try to test 2012 on Monday.

@tyler-ball
Copy link
Contributor

@fnichol just pushed a large refactoring to the windows-guest-support branch which should have made the default chef path on Windows point correctly (IE, C:\opscode\chef\bin\chef-client.bat). Can you try using the latest windows-guest-support branch and re-open this if it is still an issue?

@amaltson
Copy link

I'm still getting the same issue. If I provide the chef-client executable, it fails looking for cookbooks (it's looking in /tmp/kitchen for some reason).

$ KITCHEN_LOCAL_YAML=.kitchen.windows.yml bundle exec kitchen converge
-----> Starting Kitchen (v1.3.2.dev)
-----> Converging <default-win7>...
       Preparing files for transfer
       Preparing dna.json
       Resolving cookbook dependencies with Berkshelf 3.2.3...
       Removing non-cookbook files before transfer
       Preparing validation.pem
       Preparing client.rb
       /tmp/kitchen/cookbooks: -c: line 0: unexpected EOF while looking for matching `''
       /tmp/kitchen/cookbooks: -c: line 4: syntax error: unexpected end of file
       Transferring files to <default-win7>
       {:config_missing=>true}
       [2015-03-21T14:10:52-07:00] WARN: *****************************************
       [2015-03-21T14:10:52-07:00] WARN: Did not find config file: /tmp/kitchen/client.rb, using command line options.
       [2015-03-21T14:10:52-07:00] WARN: *****************************************
       [2015-03-21T14:10:52-07:00] WARN: No cookbooks directory found at or above current directory.  Assuming C:/Users/vagrant.
       [2015-03-21T14:10:52-07:00] FATAL: Cannot load configuration from /tmp/kitchen/dna.json
       Finished converging <default-win7> (0m8.88s).
-----> Kitchen is finished. (0m9.35s)

@fnichol
Copy link
Contributor

fnichol commented Mar 21, 2015

@amaltson it looks like Test Kitchen is assuming a unix instance here. At the moment, if your platform name starts with /^windows/, Test Kitchen will assume it's a Windows system (by default). If you renamed your platform name to windows-7 I suspect the correct thing will happen. Or you can set os_type and shell_type under your platform like this:

---
platforms:
  - name: win-7
    os_type: windows
    shell_type: powershell

I think I'm going to relax the platform name matching to allow /^win/ which would have caught your platform name. Seem reasonable?

@amaltson
Copy link

Thanks @fnichol, I kept trying guest: :windows but that seems to be deprecated. Either setting os_type or changing the name to windows-7 (as you said) gets the test-kitchen run further. Now it's failing with some syntax error:

$ KITCHEN_LOCAL_YAML=.kitchen.windows.yml bundle exec kitchen converge
-----> Starting Kitchen (v1.3.2.dev)
-----> Creating <default-windows-7>...
       Bringing machine 'default' up with 'virtualbox' provider...
       ==> default: Importing base box 'win7x64-enterprise-chef'...
==> default: Matching MAC address for NAT networking...
       ==> default: Setting the name of the VM: kitchen-otpp_websense_rm101-default-windows-7_default_1427059418096_50220
       ==> default: Fixed port collision for 22 => 2222. Now on port 2200.
       ==> default: Clearing any previously set network interfaces...
       ==> default: Preparing network interfaces based on configuration...
           default: Adapter 1: nat
       ==> default: Forwarding ports...
           default: 3389 => 3389 (adapter 1)
           default: 5985 => 5985 (adapter 1)
           default: 22 => 2200 (adapter 1)
       ==> default: Running 'pre-boot' VM customizations...
       ==> default: Booting VM...
       ==> default: Waiting for machine to boot. This may take a few minutes...
       ==> default: Machine booted and ready!
       ==> default: Checking for guest additions in VM...
       ==> default: Machine not provisioning because `--no-provision` is specified.
       [SSH] Established
       Vagrant instance <default-windows-7> created.
       Finished creating <default-windows-7> (1m22.84s).
-----> Converging <default-windows-7>...
       Preparing files for transfer
       Preparing dna.json
       Resolving cookbook dependencies with Berkshelf 3.2.3...
       Removing non-cookbook files before transfer
       Preparing validation.pem
       Preparing client.rb
       /bin/sh: -c: line 1: syntax error near unexpected token `('
       /bin/sh: -c: line 1: ` = @(:TEMPkitchenclients, :TEMPkitchencookbooks, :TEMPkitchendata, :TEMPkitchendata_bags, :TEMPkitchenenvironments, :TEMPkitchenroles)'
       Transferring files to <default-windows-7>
       /bin/sh: -c: line 1: syntax error near unexpected token `('
       /bin/sh: -c: line 1: `:PATH = [System.Environment]::GetEnvironmentVariable(PATH,Machine)'
       Finished converging <default-windows-7> (0m7.05s).
-----> Kitchen is finished. (1m30.32s)

Should I open a new issue for this?

@tyler-ball
Copy link
Contributor

@amaltson Can you post the output of your kitchen diagnose here? Check it for passwords or sensitive information first. It looks like it is still trying to use the bourne shell (/bin/sh) instead of powershell. Did you set shell_type: powershell in your .kitchen.yml? If it is a Windows instance it should default to powershell, but that may be another bug. The kitchen diagnose should help us troubleshoot this.

@amaltson
Copy link

@tyler-ball nevermind, I found the issue was I was using communicator: winrm instead of transport: name: winrm. With that change I actually have a converging Windows box 🎉 🎊! Here's my working .kitchen.windows.yml file:

---
driver:
  forward_agent: yes
  name: vagrant
  customize:
    cpus: 2
    memory: 4096

provisioner:
  name: chef_zero

platforms:
  - name: windows-7
    transport:
      name: winrm
    driver:
      box: win7x64-enterprise-chef
      require_chef_omnibus: false

suites:
  - name: default
    run_list:
      - recipe[<our recipe>]

Now onto getting ServerSpec to work 😄. Thanks @fnichol and @tyler-ball (and @mwrock for the working configs).

@fnichol
Copy link
Contributor

fnichol commented Mar 26, 2015

@amaltson Great, you beat me to it! We now have some very tempting pre-release gems out that should make all of this work out of the box: http://lists.opscode.com/sympa/arc/chef/2015-03/msg00442.html

@fnichol
Copy link
Contributor

fnichol commented Mar 26, 2015

@amaltson Oh, and as of the beta releases, your "win7" platform name should work as expected (we shorted the matching to /^win/i.

@amaltson
Copy link

@fnichol awesome! I'm already on the beta release and it works great. The only hiccup we've run into (generally) is, if you want to converge more than once, you need to change the MaxProcessesPerShell to something more than the default 15.

Once the Vagrant box is up, we executing the following:

> winrm set winrm/config/winrs '@{MaxProcessesPerShell="100"}'

Is that something that can go into kitchen-vagrant?

@fnichol
Copy link
Contributor

fnichol commented Mar 26, 2015

@amaltson oh what version of Windows was this--Windows 7 I take it? That could be a bug in the CommandExecutor which should recycle remote shells. Think you could a add new issue for tracking?

@amaltson
Copy link

Sure thing, filed in #656. Thanks again!

@Marusya82
Copy link

is it possible to spin up windows with test kitchen but using docker as a driver? works perfectly for centOS, but not for windows. I keep getting "Unknown platform 'windows'" error. tried different variations of .kitchen.yml, no success. sorry if my question is not in the right place. couldn't find any relevant information on SO, git or anywhere else.

@amaltson
Copy link

@Marusya82 have you tried the .kitchen.yml I posted up there? Did it not work?

@Marusya82
Copy link

@amaltson I have, the modified version though (driver: docker). Didn't work, same error:

-----> Starting Kitchen (v1.3.1)
-----> Creating <default-windows-7>...
>>>>>> Create failed on instance <default-windows-7>.
>>>>>> Please see .kitchen/logs/default-windows-7.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Unknown platform 'windows'
>>>>>> ----------------------

@mattstratton
Copy link

@Marusya82 I apologize if I'm exposing my general ignorance, but I didn't think it was possible to run a Windows environment inside a Docker container in general? I freely admit that I could be totally missing some magic.

@amaltson
Copy link

I don't believe you can, you'll have to use the kitchen-vagrant driver
instead of Docker. I currently have two configs, one for Linux and one for
Windows. You can vary them with the KITCHEN_LOCAL_YAML environment
variable.
On Thu, Mar 26, 2015 at 5:48 PM Matt Stratton notifications@github.com
wrote:

@Marusya82 https://github.com/Marusya82 I apologize if I'm exposing my
general ignorance, but I didn't think it was possible to run a Windows
environment inside a Docker container in general? I freely admit that I
could be totally missing some magic.


Reply to this email directly or view it on GitHub
#565 (comment)
.

@mwrock
Copy link
Member

mwrock commented Mar 26, 2015

yup. not possible to run windows inside docker but that will be a fine day when it happens. I know the windows server team is working on that and the current word is its slated for late this year. Here is a blog that covers that work: http://azure.microsoft.com/blog/2014/10/15/new-windows-server-containers-and-azure-support-for-docker/

@smurawski
Copy link
Contributor

@mattstratton @mwrock So eager for containers on Windows, but they will need to run on a base Windows image, you won't be able to run a Windows container on a Linux OS for example.

@Marusya82
Copy link

@mattstratton @mwrock @amaltson (facepalm) thank you everyone, you put an end to my painful and worthless efforts to make it work. will have two configs and long for the day when windows&docker become possible.

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

No branches or pull requests