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 sensu service DSC error for starting #33

Closed
StuartMcManus opened this issue Jul 14, 2020 · 13 comments · Fixed by #35
Closed

Windows sensu service DSC error for starting #33

StuartMcManus opened this issue Jul 14, 2020 · 13 comments · Fixed by #35

Comments

@StuartMcManus
Copy link

Description of problem

  • What did you do? Stopped the Windows sensu-client service and ran puppet
  • What happened? The puppet run threw a DSC error about creation of the service as it already existed and skipped starting the service
  • What did you expect to happen? Puppet to start the Windows sensu-client service which does happen on Linux clients correctly
  • How can someone reproduce the problem? Stop the Windows sensu-client service and run puppet

Command used and debugging output

  • What does your puppet config look like (including any hiera config)
  • Is this a masterless or master based puppet setup? Master based

Platform and version information

Your OS: Redhat 7.8 (Maipo)
Your Ruby version: ruby 2.0.0.648-36.el7.x86_64
Your version of Puppet: 5.5.20 open source
Your version of Sensu: 1.8.0.1 (Windows client)
Your version of this module: 3.4.1
DSC module version: 1.9.3

Anything else to add that you think will be helpful?

I have attached the Puppet run below but the main part of the error is:

Error: Could not set 'present' on ensure: PowerShell DSC resource MSFT_ServiceResource failed to execute Set-TargetResource functionality with error message: The service 'sensu-client' to create alre ady exists with path 'c:\opt\sensu\bin\sensu-client.exe' (file: /etc/puppetlabs/code/environments/test/modules/external/sensuclassic/manifests/client.pp, line: 75) Error: Could not set 'present' on ensure: PowerShell DSC resource MSFT_ServiceResource failed to execute Set-TargetResource functionality with error message: The service 'sensu-client' to create alre ady exists with path 'c:\opt\sensu\bin\sensu-client.exe' (file: /etc/puppetlabs/code/environments/test/modules/external/sensuclassic/manifests/client.pp, line: 75) Wrapped exception: PowerShell DSC resource MSFT_ServiceResource failed to execute Set-TargetResource functionality with error message: The service 'sensu-client' to create already exists with path 'c:\opt\sensu\bin\sen su-client.exe'

Puppet_Run_Service_Start_Issue.txt

@StuartMcManus
Copy link
Author

This looks very similar to the following error in:

sensu/sensu-puppet#1046

@treydock
Copy link
Collaborator

Can you provide your Puppet code where you setup the sensuclassic classes and any hiera data? Feel free to replace sensitive information with fake data. I would like to try and reproduce this issue locally.

What version of Windows is this happening on?

@StuartMcManus
Copy link
Author

Hello @treydock I have attached how we are calling the class for sensuclassic with params you can replace with required strings. I have stripped out some non-required params so have done my best to leave all you should need.

I have tested this issue on Windows Server 2012R2 and Windows Server 2016.
Sensu_Class.txt

@treydock
Copy link
Collaborator

Do you have something special configured for chocolatey to work? I am unable to install Sensu through Chocolatey. When I go to chocolatey website the only options for Sensu I see are for Sensu Go (sensu-agent and sensu-cli). Are you maybe using some kind of custom chocolately repo or custom chocolatey config? This is error I get:

Error: Execution of 'C:\ProgramData\chocolatey\choco.exe install Sensu -y  --ign
ore-package-exit-codes --no-progress' returned 1: Chocolatey v0.10.15
Installing the following packages:
Sensu
By installing you accept licenses for the packages.
Sensu not installed. The package was not found with the source(s) listed.
 Source(s): 'https://chocolatey.org/api/v2/'
 NOTE: When you specify explicit sources, it overrides default sources.
If the package version is a prerelease and you didn't specify `--pre`,
 the package may not be found.
Please see https://chocolatey.org/docs/troubleshooting for more
 assistance.

Chocolatey installed 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
 - Sensu - Sensu not installed. The package was not found with the source(s) lis
ted.
 Source(s): 'https://chocolatey.org/api/v2/'
 NOTE: When you specify explicit sources, it overrides default sources.
If the package version is a prerelease and you didn't specify `--pre`,
 the package may not be found.
Please see https://chocolatey.org/docs/troubleshooting for more

@StuartMcManus
Copy link
Author

Hello @treydock we internalise packages from chocolately into our internal repo whereby that repo is added as a source when the chocolately packages are installed.

I have just checked though and you are right there is only Sensu Go so we have downloaded the client from Sensu themselves from https://eol-repositories.sensuapp.org/msi/2016/ and created the chocolately package from their msi using the chocolately package builder gui. We used the default options within that GUI so just a right click, create, build package and then uploaded to our internal repo.

@ghoneycutt
Copy link
Collaborator

@StuartMcManus We just released v3.6.1. Could you give that a try and let us know if it addresses the issue.

@StuartMcManus
Copy link
Author

Hello @ghoneycutt sorry I have not had a chance to test yet but will pick Monday to test out.

@StuartMcManus
Copy link
Author

Hello @ghoneycutt I have tested using the new release 3.6.1 but it still comes up with the same error.

@treydock
Copy link
Collaborator

@StuartMcManus Based on the errors you got its almost as if the Chocolatey package is installing the needed service and then the DSC service in the Puppet module is failing to to properly install the service or detect the existence of the service in same puppet run. I don't have the ability to test with Chocolately packages so I'm not sure I can reproduce this issue. One thing we can do to troubleshoot is you can modify this module on your local system and see if commenting out the following lines solves the problem:

https://github.com/sensu/puppet-module-sensuclassic/blob/master/manifests/client.pp#L75-L88

Also:

Change these two lines to use Service['sensu-client'] instead of Dsc_service['sensu-client']:

https://github.com/sensu/puppet-module-sensuclassic/blob/master/manifests/client.pp#L57

https://github.com/sensu/puppet-module-sensuclassic/blob/master/manifests/client.pp#L68

If your able to share how you add the chocolately package and possibly make the chocolatey package available to me I can try debugging this locally.

@StuartMcManus
Copy link
Author

Hello @treydock this is happening after the service is installed correctly by DSC and working, whereby I then stop the service and run puppet to try and start it again. Chocolately just puts down the the files doing a standard msi install and puppet sensuclassic module creates the service using DSC.

Chocolatey for you doesn't need to be factored in as it just puts down the files you can just manually install and run puppet to setup the service for you. The problem is purely to do with the DSC_Service resource within the sensuclassic module not detecting the service correctly when the service is stopped which sounds a like it then sees it as absent but when the service is running it does not have an issue.

@StuartMcManus
Copy link
Author

Hello @treydock just checking if you have had a chance to test out with a standard install using the package resource and puppet trying to start the service?

@treydock
Copy link
Collaborator

treydock commented Aug 6, 2020

I can reproduce the issue and honestly have no idea how to fix the problem, it's likely a bug or misconfiguration with the DSC Puppet module. I think I may be able to come up with a way to get rid of the dsc_service resource all together and instead install the Windows service the way Sensu documents installing the service.

Thus far what I've observed is what I think you saw and that's if sensu-client service is stopped, the dsc_service resource throws errors. Manually starting the service and then running Puppet produces no errors but that's not a solution.

treydock added a commit that referenced this issue Aug 6, 2020
Replace dsc_service with Exec that installs the sensu-client service
Fixes #33
@treydock
Copy link
Collaborator

treydock commented Aug 6, 2020

@StuartMcManus Can you try the changes in #35 and let me know if that resolves your issue?

treydock added a commit that referenced this issue Aug 6, 2020
Replace dsc_service with Exec that installs the sensu-client service
Fixes #33
treydock added a commit that referenced this issue Aug 6, 2020
Replace dsc_service with Exec that installs the sensu-client service
Fixes #33
treydock added a commit that referenced this issue Aug 8, 2020
Replace dsc_service with Exec that installs the sensu-client service
Fixes #33
hobayoba pushed a commit to hobayoba/puppet-module-sensuclassic that referenced this issue Apr 27, 2021
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

Successfully merging a pull request may close this issue.

3 participants