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

Initial tentacle install is failing with error '100 Generating Cert for the machine' #100

Closed
bdevenney opened this issue Jun 29, 2017 · 7 comments

Comments

@bdevenney
Copy link

bdevenney commented Jun 29, 2017

Hi all, I am trying to provision some Windows 2012 servers but I can't get the Octopus Tentacle install step through.

If fails on the first Chef run with:

ERROR: Command returned
100 Generating Cert for the machine

Recipe
octopus_deploy_tentacle 'Tentacle' do
version node['octopus_server']['version']
trusted_cert node['tentacle']['trusted_cert']
configure_firewall true
action [:install, :configure]
end

Stack trace
Message=Failed Chef Client run eaba2e43-6477-49d4-b122-434cc56155c2 in 69.342504 seconds.
Exception type: Mixlib::ShellOut::ShellCommandFailed
Exception message: octopus_deploy_tentacle[Tentacle] (temp_octopus_deploy::tentacle line 19) had an error: Mixlib::ShellOut::ShellCommandFailed: powershell_script[generate-tentacle-cert-Tentacle] (C:/chef/cache/cookbooks/octopus-deploy/resources/tentacle.rb line 84) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -File "C:/Windows/Temp/chef-script20170629-3004-1c1mrwb.ps1" ----
STDOUT:
STDERR: C:\Windows\Temp\chef-script20170629-3004-1c1mrwb.ps1 : ERROR: Command returned
100 Generating Cert for the machine
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorExcep
tion
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio
n,chef-script20170629-3004-1c1mrwb.ps1
---- End output of "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -File "C:/Windows/Temp/chef-script20170629-3004-1c1mrwb.ps1" ----
Ran "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -File "C:/Windows/Temp/chef-script20170629-3004-1c1mrwb.ps1" returned 1
Exception backtrace: C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/mixlib-shellout-2.2.7-universal-mingw32/lib/mixlib/shellout.rb:289:in invalid!' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/mixlib-shellout-2.2.7-universal-mingw32/lib/mixlib/shellout.rb:276:in error!'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/mixin/shell_out.rb:120:in shell_out!' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/provider/execute.rb:58:in block in action_run'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/mixin/why_run.rb:52:in add_action' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/provider.rb:202:in converge_by'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/provider/execute.rb:56:in action_run' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/provider/script.rb:64:in action_run'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/provider/windows_script.rb:57:in action_run' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/provider/powershell_script.rb:35:in action_run'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/provider.rb:171:in run_action' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/resource.rb:591:in run_action'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/runner.rb:69:in run_action' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/runner.rb:97:in block (2 levels) in converge'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/runner.rb:97:in each' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/runner.rb:97:in block in converge'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/resource_collection/resource_list.rb:94:in block in execute_each_resource' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:114:in call_iterator_block'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:85:in step' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:103:in iterate'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:55:in each_with_index' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/resource_collection/resource_list.rb:92:in execute_each_resource'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/runner.rb:96:in converge' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/provider.rb:212:in compile_and_converge_action'
(eval):2:in action_configure' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/provider.rb:171:in run_action'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/resource.rb:591:in run_action' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/runner.rb:69:in run_action'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/runner.rb:97:in block (2 levels) in converge' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/runner.rb:97:in each'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/runner.rb:97:in block in converge' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/resource_collection/resource_list.rb:94:in block in execute_each_resource'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:114:in call_iterator_block' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:85:in step'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:103:in iterate' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:55:in each_with_index'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/resource_collection/resource_list.rb:92:in execute_each_resource' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/runner.rb:96:in converge'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/client.rb:715:in block in converge' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/client.rb:710:in catch'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/client.rb:710:in converge' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/client.rb:749:in converge_and_save'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/client.rb:286:in run' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/application.rb:273:in run_with_graceful_exit_option'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/application.rb:249:in block in run_chef_client' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/local_mode.rb:44:in with_server_connectivity'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/application.rb:232:in run_chef_client' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/application/client.rb:464:in sleep_then_run_chef_client'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/application/client.rb:451:in block in interval_run_chef_client' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/application/client.rb:450:in loop'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/application/client.rb:450:in interval_run_chef_client' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/application/client.rb:434:in run_application'
C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/lib/chef/application.rb:59:in run' C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.0.118-universal-mingw32/bin/chef-client:26:in <top (required)>'
C:/opscode/chef/bin/chef-client:69:in load' C:/opscode/chef/bin/chef-client:69:in

'

The other change I needed to make was to fork the octopus-deploy cookbook to change the installer_url so that it can pick up the file locally. (Our servers don't have access to the internet)

Any pointers appreciated. I noticed #32 but I am not using TestKitchen and wish to avoid running anything manually on the server itself.

Update: This is using version 0.12.0 of the octopus-deploy cookbook.

Cheers,
Barry.

@brentm5
Copy link
Member

brentm5 commented Jul 3, 2017

@bdevenney

You will need admin access in order to run these commands. Under the hood the tentacle will run the following in powershell to generate the cert:

.\\Tentacle.exe new-certificate -e "C:\Octopus\tentacle_cert.txt" --console

I would try running this from the same account and see what happens. I know the main issue is that non admin users / winrm users do not have certain dll's available to them. These dlls include the certificate libraries needed to add certs into windows. I do know we run 2012 and have used the cookbook to install tentacles but I would like to understand the full problem. How are you running this command ? Is it running as your user or as the system user in a scheduled task?

Hope this helps!

As for the the feature request for an offline installer approach I think that could be useful for others and have created #101 to track it. If you want to incorporate your code into the main repo I could help get it so you don't have to maintain your own fork, we love pull requests.

@bdevenney
Copy link
Author

Thanks @brentm5

When I get a bit of time, I'll look into the user permissions a bit more. We use PowerCLI to provision the server and use a specific user to call the first chef-client run remotely. Subsequent runs will use the local/system account so it will be interesting to see if the run is successful when the chef-client service runs normally.

For the forking, I pretty much just hacked the installer_url value to point to a local repository but, again, if I get the time to code this properly I'll send through a pull request.

Thanks for the pointers, much appreciated,
Barry.

@brentm5
Copy link
Member

brentm5 commented Jul 12, 2017

@bdevenney

Yup the remote user is going to be your problem. The issue is that remote sessions are treated differently and I do not know of a way to get around that. One hack is to setup a scheduled task via winrm and then kick that off via schtasks /run /TN <name> or something. We found a bunch of things that are just easier to run locally. This is essentially where this gem (which is used in test-kitchen I believe) originated from: https://github.com/WinRb/winrm-elevated

@jcuzzi
Copy link

jcuzzi commented Jul 24, 2017

I was running into a similar issue, but returning Error 1:

Running the command manually spits out the following message from Tentacle.exe:

.\Tentacle.exe new-certificate -e "C:\Octopus\tentacle_cert.txt" --console
The default instance of Tentacle has not been created. Either pass --instance INSTANCENAME when invoking this command, or run the setup wizard.
-------------------------------------------------------------------------------
Full error details are available in the log files at C:\Users\user\AppData\Local\Octopus\Logs
If you need help, please send these log files to https://octopus.com/support
-------------------------------------------------------------------------------

Not sure if the behavior of this command changed in a recent Tentacle.exe version, but this used to work for me. Using Tentacle 3.14.1 with this error.

@jcuzzi
Copy link

jcuzzi commented Jul 24, 2017

I updated to tentacle version 3.15.2 and it installed/configured without error.

@brentm5
Copy link
Member

brentm5 commented Jul 27, 2017

@jcuzzi I believe there was a bug before that was resolved. Anything before 3.2.X or something would require an instance.

I actually reported it here: OctopusDeploy/Issues#2143

@brentm5
Copy link
Member

brentm5 commented Mar 6, 2018

Closing because these seem related to known issues.

@brentm5 brentm5 closed this as completed Mar 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants