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

Cookbook doesn't install service properly on Chef 13 #13

Closed
ivadim opened this issue Jun 15, 2017 · 13 comments · Fixed by #18
Closed

Cookbook doesn't install service properly on Chef 13 #13

ivadim opened this issue Jun 15, 2017 · 13 comments · Fixed by #18

Comments

@ivadim
Copy link
Member

ivadim commented Jun 15, 2017

log "Trigger service installation for agent #{new_resource.agent_name}" do
        notifies :enable, service_id, :immediately if new_resource.runasservice
      end

This code doesn't notify service creation when chef version 13.
Need investigations.

@americanhanko
Copy link
Contributor

Been looking at this for a while tonight. Seems like it has something to do with the way Resources are handled now in Chef 13.

I also noticed also that the service doesn't start properly on the macOS side of things either and I had to force it to start by running ./svc.sh install and ./svc.sh start with the execute resource.

Anyway, here's my log for this issue. It goes all the way down through every action in the vsts_agent_service resource.

log[Trigger service installation for agent vagrant-2012-r2-10.0.2.15] action write

           * vsts_agent_service[vagrant-2012-r2-10.0.2.15] action enable

             ================================================================================
             Error executing action `enable` on resource 'vsts_agent_service[vagrant-2012-r2-10.0.2.15]'
             ================================================================================

             Chef::Exceptions::ProviderNotFound
             ----------------------------------
             Cannot find a provider for vsts_agent_service[vagrant-2012-r2-10.0.2.15] on windows version 6.3.9600

             Resource Declaration:
             ---------------------
             # In C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/vsts_agent/providers/default.rb

             195:   vsts_agent_service "Restart service #{resource.agent_name}" do
             196:     name resource.agent_name
             197:     install_dir resource.install_dir
             198:     user resource.user
             199:     group resource.group
             200:     action [:stop, :disable]
             201:     only_if { service_exist?(resource.install_dir) }
             202:   end
             203:

             Compiled Resource:
             ------------------
             # Declared in C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/vsts_agent/providers/default.rb:195:in `remove_agent'

             vsts_agent_service("vagrant-2012-r2-10.0.2.15") do
        action [:stop, :disable]
        default_guard_interpreter :default
        declared_type :vsts_agent_service
        cookbook_name "inqry_build"
        install_dir "C:/Users/vagrant/vsts-agent"
        user "vagrant"
        group "vagrant"
        only_if { #code block }
             end

             System Info:
             ------------
             chef_version=13.3.42
             platform=windows
             platform_version=6.3.9600
             ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32]
             program_name=C:/opscode/chef/bin/chef-client
             executable=C:/opscode/chef/bin/chef-client

@lavahot
Copy link

lavahot commented Nov 6, 2017

Any movement on this?

@lavahot
Copy link

lavahot commented Nov 17, 2017

So I took a look at what @americanhanko was talking about re: having to manually install the service on macOS. Here added is the target user as a second argument to ./svc.sh install. AFAICT svc.sh does not accept such an argument, and never has. I think this additional argument should be removed unless there's something I'm missing.

@americanhanko
Copy link
Contributor

americanhanko commented Nov 17, 2017

$ ./config.sh --version
2.124.0

$ ./svc.sh --help

Usage:
./svc.sh [install, start, stop, status, uninstall]

@lavahot Indeed, svc.sh only one of those five arguments. I also started working on a macOS specific VSTS agent cookbook with the intent to eventually do a PR here, but I wanted to start with a greenfield.

@ivadim
Copy link
Member Author

ivadim commented Nov 27, 2017

@lavahot could you please validate if a new cookbook works for you?
@americanhanko could I ask you to test a new version against macos > 10.12? My old vagrant box stopped to work.

@americanhanko
Copy link
Contributor

americanhanko commented Nov 27, 2017

@ivadim Nice work on this! Will test on 10.12 as soon as I get a chance.

@lavahot
Copy link

lavahot commented Nov 27, 2017

@americanhanko I think you mean "@ivadim Nice work on this!" I am just the peanut gallery. ;)

@lavahot
Copy link

lavahot commented Dec 4, 2017

For me it still has the problem of not successfully starting and throwing 'Could not find domain for' on ./svc.sh start. Otherwise it seems to be working perfectly. It is installed successfully and seems to be running after a reboot.

@ivadim
Copy link
Member Author

ivadim commented Dec 4, 2017

What is OS used on the server which you are trying to bootstrap? Are you running against VSTS or TFS on prem?

@ivadim
Copy link
Member Author

ivadim commented Dec 4, 2017

I found you commented on microsoft/azure-pipelines-agent#147? Looks like problem in vsts-agent or macos itself.

@lavahot
Copy link

lavahot commented Dec 5, 2017

So the thing is that launchctl doesn't work over SSH (Chef's transport method) except for when the user is logged into the GUI. I've got autologin enabled and my build user is logged in, but for some reason I still cant get launchctl to work over SSH. When rebooted, the agent comes up just fine, but all stop and start calls to ./svc.sh break over SSH. Currently that means that every chef run will fail because even with "runasservice" set to false it calls on svc.sh to stop for some reason.

If you want, I can make another issue just for this problem as it seems to be divergent from this one.

@ivadim
Copy link
Member Author

ivadim commented Dec 5, 2017

@lavahot yes, please create a new issue.
@americanhanko could you please help with this issue? I don't have MacOS environment right now :(

@americanhanko
Copy link
Contributor

@ivadim @lavahot Sorry I have been absent from this guys. It is on my radar though. I will make time to troubleshoot this issue tonight.

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