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 install on 64-bit fails #236

Closed
cobusbernard opened this issue Nov 17, 2015 · 28 comments · Fixed by #259
Closed

Windows install on 64-bit fails #236

cobusbernard opened this issue Nov 17, 2015 · 28 comments · Fixed by #259

Comments

@cobusbernard
Copy link

When installing on Windows 64-bit, the install fails as there is no 64-bit version for Windows available.

  ================================================================================
  Error executing action`enable` on resource 'consul_service[consul]'
  ================================================================================

  KeyError

---

  key not found: "0.5.2_windows_amd64"

  Resource Declaration:

---

  # In C:/chef/cache/cookbooks/consul/recipes/default.rb

   38: consul_service node['consul']['service_name'] do |r|
   39:   user node['consul']['service_user']
   40:   group node['consul']['service_group']
   41:   version node['consul']['version']
   42:   config_file config.path
   43:
   44:   node['consul']['service'].each_pair { |k, v| r.send(k, v) }
   45:   subscribes :restart, "consul_config[#{config.name}]", :delayed
   46: end

  Compiled Resource:

---

  # Declared in C:/chef/cache/cookbooks/consul/recipes/default.rb:38:in `from_file'

  consul_service("consul") do
    action [:enable]
    retries 0
    retry_delay 2
    default_guard_interpreter :default
    declared_type :consul_service
    cookbook_name "consul"
    recipe_name "default"
    user "consul"
    group "consul"
    version "0.5.2"
    config_file "/etc/consul.json"
    install_method "binary"
    config_dir "/etc/consul"
    binary_url "https://dl.bintray.com/mitchellh/consul/0.5.2_windows_amd64.zip"
    source_url "https://github.com/hashicorp/consul"
    package_name "consul"
    install_path "/srv"
  end

Running handlers:
[2015-11-17T11:34:23+02:00] ERROR: Running exception handlers
Running handlers complete
[2015-11-17T11:34:23+02:00] ERROR: Exception handlers complete
Chef Client failed. 2 resources updated in 26 seconds
[2015-11-17T11:34:23+02:00] FATAL: Stacktrace dumped to C:/chef/cache/chef-stacktrace.out
[2015-11-17T11:34:23+02:00] FATAL: KeyError: consul_service[consul](consul::default line 38) had an error: KeyError: key not found: "0.5.2_windows_amd64"```
@johnbellone
Copy link
Contributor

What is the behavior you would expect here?

@cobusbernard
Copy link
Author

The issue seems to be that there is no amd64 version of Consul, so have been working on a PR for this bug - fix doesn't seem to difficult. My current blocker is that I cannot run Test Kitchen - it doen't find the 'windows-2012r2' image, busy testing it with by specifying a different base image. That is also breaking as the poise_service part of the recipe tries to create a group and a user 'consul', which you can't do on Windows. Will revert back with more detail a bit later today.

@cobusbernard
Copy link
Author

I’ve picked up that it extracts the OS architecture via node['kernel']['machine'] on https://github.com/johnbellone/consul-cookbook/blob/master/libraries/consul_service.rb#L81 and for my windows server, this is amd64. There is no 64bit build for Consul 0.5.2 though, so I’ve tried to change the code to:

      def binary_filename
        arch = node['kernel']['machine'] =~ /x86_64/ ? 'amd64' : '386'
        if node['platform'] == 'windows'
          arch = '386'
        end
        [version, node['os'], arch].join('_')
      end

Want to submit a PR, but I can’t get Test Kitchen to run due to the missing base image, so I dumped in

  - name: windows-2012r2
    driver:
      box: opentable/win-2012r2-standard-amd64-nocm

That spins up the machine but then it falls over when trying to use poise_service to install the service, which again makes sense as it isn’t made to create Windows services - the user / group name restriction where a name has to be unique across both.

Possible to point me in the right direction w.r.t. getting Test Kitchen working? Or am I missing something about poise_service?

@johnbellone
Copy link
Contributor

I don't think that the poise-service library cookbook has a Windows provider.

@cobusbernard
Copy link
Author

So that would mean this cookbook can't be used for Windows?

@johnbellone
Copy link
Contributor

It looks like we need one to be written. It shouldn't be terribly hard since there is a Windows cookbook that the Chef folks maintain. I made a similar bridge using the AIX cookbook and poise-service-aix.

@gdavison
Copy link
Contributor

gdavison commented Dec 5, 2015

I can resurrect my Windows work from the 0.10 branch of this cookbook, if you'd like.

@johnbellone
Copy link
Contributor

@gdavison That may be helpful. I don't know how well it'll jive with the new format.

@gdavison
Copy link
Contributor

gdavison commented Dec 8, 2015

It would probably make sense to fork it, at least to start. There's no Windows support in Poise, so there would be two completely separate code paths.

@cobusbernard
Copy link
Author

Sounds good, could we get a new branch on the upstream to fork?

On Tue, 8 Dec 2015 at 04:10 Graham Davison notifications@github.com wrote:

It would probably make sense to fork it, at least to start. There's no
Windows support in Poise, so there would be two completely separate code
paths.


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

@johnbellone
Copy link
Contributor

@cobusbernard In poise or in this cookbook?

@cobusbernard
Copy link
Author

I think in this one - there are likely some other issues to take care of
w.r.t. Windows.

On Tue, 8 Dec 2015 at 16:51 John Bellone notifications@github.com wrote:

@cobusbernard https://github.com/cobusbernard In poise or in this
cookbook?


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

@Ginja
Copy link
Contributor

Ginja commented Dec 11, 2015

@cobusbernard how you were you able to get that far when attempting to use this cookbook on Windows? My chef runs are failing way before it even tries to install it (see below). The issue I'm seeing should be fixed when the next version of Chef comes out:

chef/chef#4046

             Error executing action `create` on resource 'user[consul]'
             ================================================================================

             TypeError
             ---------
             no implicit conversion of FFI::MemoryPointer into Integer

             Resource Declaration:
             ---------------------
             # In C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/poise-service/files/halite_gem/poise_service/resources/poise_service_user.rb

             112:           user new_resource.user do
             113:             comment "Service user for #{new_resource.name}"
             114:             gid new_resource.group if new_resource.group
             115:             home new_resource.home
             116:             shell '/bin/false'
             117:             system true
             118:             uid new_resource.uid
             119:           end
             120:         end

@Ginja
Copy link
Contributor

Ginja commented Dec 11, 2015

Also, it looks like chocolatey is running a bit behind on their Consul version. We probably shouldn't rely on them for fetching the right version.

https://chocolatey.org/packages?q=consul

Should we be fetching the binary and installing it manually? It's just an .exe inside the ZIP file. We do need to work on a service/task scheduler resource to run it.

@johnbellone
Copy link
Contributor

I started a little bit at working on a Poise Service Windows provider but need a little help there. I realized I don't have a test-kitchen box for that work.

@Ginja
Copy link
Contributor

Ginja commented Dec 12, 2015

@johnbellone playing devil's advocate; I wonder if we should be leveraging Chef's native Windows service (https://docs.chef.io/resource_windows_service.html), or the windows' cookbook windows_task resource (https://github.com/chef-cookbooks/windows/blob/d78c82e3a9d350d11b949f13528fdf820b9a62d7/providers/task.rb) instead of writing a poise-service bridge. Chocolatey does use NSSM (https://nssm.cc/) to manage the Consul service when it installs it, perhaps that is the way to go.

@cobusbernard, @johnbellone, @gdavison thoughts?

@cobusbernard
Copy link
Author

@Ginja I had made some changes to the cookbook after forking it, mainly forcing the Windows architecture to 386 and adding a password to the user portion in my wrapper cookbook.

I ended up installing it by hand on the 1 Windows node that needed Consul by using https://github.com/kohsuke/winsw. Fairly straightforward, but I like @Ginja's idea to leverage existing tools windows_task or NSSM.

@Ginja
Copy link
Contributor

Ginja commented Dec 12, 2015

Thanks for the info, @cobusbernard.

There is an existing NSSM cookbook (https://github.com/dhoer/chef-nssm) we could leverage if we went down that route. If anyone has had any experience with NSSM please share your thoughts. I'm inclined to suggest we drop chocolatey, un-zip the agent/ui ourselves, and use an NSSM resource to run the former.

@gdavison
Copy link
Contributor

Chocolatey has version 0.5.2 "in review", where it's been for months, and I have no idea where they're at with 0.6. The current cookbook has binary, package, and source install methods, so we could have binary and package for Windows as well, with package lagging. Not sure if there would be any benefit to that, though.

I've set up a service on Windows using NSSM using Chef. It works pretty well.

Are you hoping to run servers and/or UI on Windows, or just the agents?

@Ginja
Copy link
Contributor

Ginja commented Dec 14, 2015

My intention is just to run the agent on Windows. I believe that's what most people will want as well. So I say we accomplish that first, and then add the rest later or as people need/request them. I'm working on a windows-support branch now, but if someone already has one feel free to submit it.

@gdavison
Copy link
Contributor

https://github.com/paybyphone/consul-cookbook/tree/new_windows_support. It's based off the v0.11.1 branch, so the parameters will likely be different from the linux version. It installs the agent using Chocolatey, so it's only Consul 0.5.
Next steps for me are to install 0.6 from the HashiCorp binary. Then, if it's worthwhile, I'll integrate it with the current version of the cookbook, but it will likely be a completely different code path in the cookbook.

@Ginja
Copy link
Contributor

Ginja commented Dec 17, 2015

I've just pushed up a branch to my fork that adds Windows support. However, it is a major re-factor as I've used the provider syntax for Chef 12.5, and I'm using the compat_resource cookbook to back-port support for 12.0-12.4 clients (i.e. this cookbook will not support Chef 11 clients).

@cobusbernard, @johnbellone, @gdavison please take a look at the branch below. I still need to fix all the tests.

https://github.com/visioncritical/consul-cookbook/tree/provider-refactor

EDIT: I figured switching to the 12.5+ syntax was inevitable. I also had to change the way poise-service was used in the consul_service provider for Linux. Instead of using it as a Service Mixin, I changed it to just using the poise_service resource. I don't think the former method works with the 12.5+ provider syntax. If anyone knows how to do that part better, let me know.

ADDENDUM: I'm not convinced updating the syntax was the right move. I may just patch the Windows support into the existing providers. Updating the tests is proving... difficult :(

@gdavison
Copy link
Contributor

@Ginja I've been doing some work on the integration tests. I missed where you said the tests weren't updated.

It looks good, though it wipes out my day of coding yesterday :)

I have noticed that I run into a group problem for a lot of the resources. I'm not sure if that's a problem on my setup.

@Ginja
Copy link
Contributor

Ginja commented Dec 17, 2015

@gdavison I've opted to not configure a user or group on Windows machines. There's not a lot of benefit, and just adds more complexity.

I'm actually working on another branch which doesn't update the Provider syntax, and I think I'm going to recommend that we use it instead. Unless @johnbellone says otherwise.

@kamaradclimber
Copy link
Contributor

@Ginja your provider-refactor branch looks good.

@Ginja
Copy link
Contributor

Ginja commented Dec 30, 2015

Thanks, @kamaradclimber. I'm unhappy with it however because it attempts to use the compat_resource cookbook with Poise; they shouldn't be mixed. #259 adds Windows support and does so using just Poise, which is more in-keeping with how this cookbook is written.

@dlarr
Copy link

dlarr commented Apr 5, 2018

Hello,

I am trying to install consul on windows 10 64bits. This is not working. I have tried all later versions:

  • 1.0.6
  • 1.0.5
  • 1.0.3

All resulting in same effect, a window blink on my screen and nothing more happens :'(

Any idea how to fix this ? I really want to give a try to consul over ZooKeeper ;)

@lock
Copy link

lock bot commented Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants