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

[870] Support Windows in sensu::handler #874

Merged
merged 1 commit into from
May 21, 2018

Conversation

treydock
Copy link
Collaborator

@treydock treydock commented Jan 20, 2018

Pull Request Checklist

Description

Support Windows in sensu::handler

Related Issue

Fixes #870 .

Motivation and Context

Add Windows support for sensu::handler

How Has This Been Tested?

Ran tests/sensu-client-windows.pp from within Windows Vagrant VM.

Initial with no changes:

Error: Parameter path failed on File[/etc/sensu/conf.d/handlers/operations.json]: File paths must be fully qualified, no
t '/etc/sensu/conf.d/handlers/operations.json' at C:/ProgramData/PuppetLabs/code/environments/production/modules/sensu/m
anifests/handler.pp:119

Without fixing owner/group:

Error: Could not set 'file' on ensure: Could not find user sensu at C:/ProgramData/PuppetLabs/code/environments/producti
on/modules/sensu/manifests/handler.pp:122
Error: Could not set 'file' on ensure: Could not find user sensu at C:/ProgramData/PuppetLabs/code/environments/producti
on/modules/sensu/manifests/handler.pp:122
Wrapped exception:
Could not find user sensu
Error: /Stage[main]/Main/Sensu::Handler[operations]/File[C:/opt/sensu/conf.d/handlers/operations.json]/ensure: change fr
om absent to file failed: Could not set 'file' on ensure: Could not find user sensu at C:/ProgramData/PuppetLabs/code/en
vironments/production/modules/sensu/manifests/handler.pp:122
Notice: /Stage[main]/Main/Sensu::Handler[operations]/Sensu_handler[operations]: Dependency File[C:/opt/sensu/conf.d/hand
lers/operations.json] has failures: true
Warning: /Stage[main]/Main/Sensu::Handler[operations]/Sensu_handler[operations]: Skipping because of failed dependencies

Current broken state, unable to write to handler JSON:

Notice: /Stage[main]/Main/Sensu::Handler[operations]/File[C:/opt/sensu/conf.d/handlers/operations.json]/owner: owner cha
nged 'BUILTIN\Administrators' to 'NT AUTHORITY\SYSTEM'
Info: Unknown failure using insync_values? on type: File[C:/opt/sensu/conf.d/handlers/operations.json] / property: group
 to compare values ["sensu"] and S-1-5-21-3541430928-2051711210-1391384369-513
Notice: /Stage[main]/Main/Sensu::Handler[operations]/File[C:/opt/sensu/conf.d/handlers/operations.json]/group: group cha
nged 'WIN2012R2-CLIEN\None' to 'BUILTIN\Administrators'
Notice: /Stage[main]/Main/Sensu::Handler[operations]/Sensu_handler[operations]/ensure: created
Error: /Stage[main]/Main/Sensu::Handler[operations]/Sensu_handler[operations]: Could not evaluate: Permission denied @ r
b_sysopen - C:/opt/sensu/conf.d/handlers/operations.json

General

  • Tests pass - bundle exec rake validate lint spec

@treydock
Copy link
Collaborator Author

@ghoneycutt The only failure is sensu_handler resource can't write to C:/opt/sensu/conf.d/handlers/operations.json. It's currently a 0 byte file

PS C:\tmp> ls C:\opt\sensu\conf.d\handlers\


    Directory: C:\opt\sensu\conf.d\handlers


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-ar--         1/20/2018  10:06 AM          0 operations.json

@treydock
Copy link
Collaborator Author

Issue resolved. I think applying broken code to Windows left the JSON file in weird state. I had to delete the file from GUI, removing with rm gave permission denied. I deleted the JSON file and re-ran Puppet and things are healthy:

PS C:\tmp> puppet apply -v C:/vagrant/tests/sensu-client-windows.pp
Info: Loading facts
Notice: Scope(Class[Sensu::Package]): Managing a local windows user is not implemented on windows
Notice: Compiled catalog for win2012r2-client in environment production in 2.63 seconds
Info: Applying configuration version '1516463652'
Notice: /Stage[main]/Main/Sensu::Handler[operations]/File[C:/opt/sensu/conf.d/handlers/operations.json]/ensure: created
Notice: /Stage[main]/Main/Sensu::Handler[operations]/Sensu_handler[operations]/ensure: created
Notice: Applied catalog in 6.06 seconds
PS C:\tmp> cat C:\opt\sensu\conf.d\handlers\operations.json
{
  "handlers": {
    "operations": {
      "command": "/opt/sensu/embedded/bin/handler-pagerduty.rb",
      "type": "pipe",
      "filters": [

      ],
      "severities": [
        "critical"
      ],
      "handle_flapping": false,
      "handle_silenced": false
    }
  }
}

@treydock treydock changed the title [WIP][870] Support Windows in sensu::handler [870] Support Windows in sensu::handler Jan 20, 2018
@ghoneycutt ghoneycutt merged commit 40b2ccf into sensu:master May 21, 2018
@ghoneycutt
Copy link
Collaborator

Released in v2.53.0

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 this pull request may close these issues.

Windows Handlers not handled by module
2 participants