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

Add Windows support for Sensu Go agent #1108

Merged
merged 2 commits into from
May 18, 2019
Merged

Add Windows support for Sensu Go agent #1108

merged 2 commits into from
May 18, 2019

Conversation

treydock
Copy link
Collaborator

Pull Request Checklist

Description

Add Windows support for agent

Related Issue

Fixes #1106

Motivation and Context

Sensu Go 5.7 added better support for Windows, this PR adds that support.

@treydock
Copy link
Collaborator Author

Added to travis and appveyor configs limit on what builds. Previously if I pushed to this repo a branch then open a PR there would be two sets of builds. Now PRs, master and tags are what build so if I open a PR there is only going to be one set of builds and not two.

@treydock
Copy link
Collaborator Author

@ghoneycutt Was contemplating simplifying parameters and just have package_source and if it starts with http or https then download with archive.

@treydock
Copy link
Collaborator Author

I am working on adding acceptance tests for facts on Windows to ensure they work but not having much luck. It works with Vagrant image but having issues getting stdout to return actual output with serverspec.

@treydock
Copy link
Collaborator Author

Got commit added that tests sensu_agent fact for Windows.

README.md Outdated Show resolved Hide resolved
Rakefile Show resolved Hide resolved
README.md Show resolved Hide resolved
appveyor.yml Outdated
matrix:
- PUPPET_GEM_VERSION: '~>5.x'
PUPPET_REPO: puppet5
PUPPET_VERSION: 5.5.14
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this have to be hard coded? we can't just pull the latest minor version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puppetlabs doesn't provide a latest type MSI path so what we have are exact versions: https://downloads.puppetlabs.com/windows/puppet5/. We also can't use one installed via Gem, we are testing real Puppet install that gets installed into system locations like one would do when dealing with real Windows server. That value for PUPPET_VERSION gets added to MSI download URL, not something coming from rubygems.org.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea how I missed that, I updated appveyor configs to use those latest URLs.

REFERENCE.md Outdated Show resolved Hide resolved
@ghoneycutt
Copy link
Collaborator

Vagrant is failing due to Puppet re-organizing their repo's.

@ghoneycutt
Copy link
Collaborator

This is failing vagrant with

==> win2012r2-agent: Configuring proxy environment variables...
The following WinRM command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mkdir "/" -force

Stdout from the command:



Stderr from the command:

The path is not of a legal form.
At line:1 char:1
+ mkdir "/" -force
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (C:\:String) [New-Item], ArgumentException
    + FullyQualifiedErrorId : CreateDirectoryArgumentError,Microsoft.PowerShell.Commands.NewItemCommand

@treydock
Copy link
Collaborator Author

I used win2012r2-agent to build the Windows logic so worked on my end. I'd check plugins that might be present and causing extra logic to get executed that is Linux specific. I think only plugins I have are one for adding guest additions and maybe the reload plugin.

@ghoneycutt
Copy link
Collaborator

Removing vagrant-proxyconf plugin got past that error. Now though I'm seeing this.

==> win2012r2-agent: Running provisioner: shell...
    win2012r2-agent: Running: tests/provision_basic_win.ps1 as c:\tmp\vagrant-shell.ps1
    win2012r2-agent: Installing Puppet from https://downloads.puppetlabs.com/windows/puppet5/puppet-agent-5.5.6-x64.msi
    win2012r2-agent: Log will be written to C:/vagrant/puppet-agent.log
    win2012r2-agent: symbolic link created for C:\ProgramData\PuppetLabs\code\environments\production\modules\sensu <<===>> C:\vagrant
    win2012r2-agent: Out-File : Could not find a part of the path
    win2012r2-agent: 'C:\ProgramData\PuppetLabs\puppet\etc\hiera.yaml'.
    win2012r2-agent: At C:\tmp\vagrant-shell.ps1:36 char:18
    win2012r2-agent: + $hiera_content | Out-File -FilePath "$hiera_file" -Encoding ascii
    win2012r2-agent: +                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    win2012r2-agent:     + CategoryInfo          : OpenError: (:) [Out-File], DirectoryNotFoundExce
    win2012r2-agent:    ption
    win2012r2-agent:     + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.Ou
    win2012r2-agent:    tFileCommand
    win2012r2-agent: puppet : The term 'puppet' is not recognized as the name of a cmdlet,
    win2012r2-agent: function, script file, or operable program. Check the spelling of the name, or
    win2012r2-agent: if a path was included, verify that the path is correct and try again.
    win2012r2-agent: At line:1 char:1
    win2012r2-agent: + puppet module install puppetlabs-stdlib
    win2012r2-agent: + ~~~~~~
    win2012r2-agent:     + CategoryInfo          : ObjectNotFound: (puppet:String) [], CommandNotFo
    win2012r2-agent:    undException
    win2012r2-agent:     + FullyQualifiedErrorId : CommandNotFoundException
    win2012r2-agent: puppet : The term 'puppet' is not recognized as the name of a cmdlet,
    win2012r2-agent: function, script file, or operable program. Check the spelling of the name, or
    win2012r2-agent: if a path was included, verify that the path is correct and try again.
    win2012r2-agent: At line:1 char:1
    win2012r2-agent: + puppet module install puppet-archive
    win2012r2-agent: + ~~~~~~
    win2012r2-agent:     + CategoryInfo          : ObjectNotFound: (puppet:String) [], CommandNotFo
    win2012r2-agent:    undException
    win2012r2-agent:     + FullyQualifiedErrorId : CommandNotFoundException
    win2012r2-agent: Copy-Item : Cannot find path 'C:\vagrant\tests\ssl' because it does not exist.
    win2012r2-agent: At C:\tmp\vagrant-shell.ps1:45 char:1
    win2012r2-agent: + Copy-Item -Path "C:\vagrant\tests\ssl\*" -Destination
    win2012r2-agent: "C:\ProgramData\PuppetLabs ...
    win2012r2-agent: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    win2012r2-agent: ~~~
    win2012r2-agent:     + CategoryInfo          : ObjectNotFound: (C:\vagrant\tests\ssl:String) [C
    win2012r2-agent:    opy-Item], ItemNotFoundException
    win2012r2-agent:     + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyI
    win2012r2-agent:    temCommand
    win2012r2-agent: puppet : The term 'puppet' is not recognized as the name of a cmdlet,
    win2012r2-agent: function, script file, or operable program. Check the spelling of the name, or
    win2012r2-agent: if a path was included, verify that the path is correct and try again.
    win2012r2-agent: At line:1 char:1
    win2012r2-agent: + puppet resource host sensu-backend.example.com ensure=present
    win2012r2-agent: ip=192.168.52.10
    win2012r2-agent: + ~~~~~~
    win2012r2-agent:     + CategoryInfo          : ObjectNotFound: (puppet:String) [], CommandNotFo
    win2012r2-agent:    undException
    win2012r2-agent:     + FullyQualifiedErrorId : CommandNotFoundException
==> win2012r2-agent: Running provisioner: shell...
    win2012r2-agent: Running: inline PowerShell script
    win2012r2-agent: puppet : The term 'puppet' is not recognized as the name of a cmdlet,
    win2012r2-agent: function, script file, or operable program. Check the spelling of the name, or
    win2012r2-agent: if a path was included, verify that the path is correct and try again.
    win2012r2-agent: At line:1 char:1
    win2012r2-agent: + puppet apply -v C:/vagrant/tests/sensu-agent.pp
    win2012r2-agent: + ~~~~~~
    win2012r2-agent:     + CategoryInfo          : ObjectNotFound: (puppet:String) [], CommandNotFo
    win2012r2-agent:    undException
    win2012r2-agent:     + FullyQualifiedErrorId : CommandNotFoundException
==> win2012r2-agent: Running provisioner: shell...
    win2012r2-agent: Running: inline PowerShell script
    win2012r2-agent: facter : The term 'facter' is not recognized as the name of a cmdlet,
    win2012r2-agent: function, script file, or operable program. Check the spelling of the name, or
    win2012r2-agent: if a path was included, verify that the path is correct and try again.
    win2012r2-agent: At C:\tmp\vagrant-shell.ps1:1 char:1
    win2012r2-agent: + facter --custom-dir=C:
                                             agrantlib
                                                      acter sensu_agent
    win2012r2-agent: + ~~~~~~
    win2012r2-agent:     + CategoryInfo          : ObjectNotFound: (facter:String) [], CommandNotFo
    win2012r2-agent:    undException
    win2012r2-agent:     + FullyQualifiedErrorId : CommandNotFoundException

@treydock
Copy link
Collaborator Author

Try destroying and then re-running vagrant up win2012r2-agent to see if that solves your issue. I destroyed my instance and ran into no problems:

==> win2012r2-agent: Running provisioner: shell...
    win2012r2-agent: Running: tests/provision_basic_win.ps1 as c:\tmp\vagrant-shell.ps1
    win2012r2-agent: Installing Puppet from https://downloads.puppetlabs.com/windows/puppet5/puppet-agent-5.5.6-x64.msi
    win2012r2-agent: Log will be written to C:/vagrant/puppet-agent.log
    win2012r2-agent: symbolic link created for C:\ProgramData\PuppetLabs\code\environments\production\modules\sensu <<===>> C:\vagrant
    win2012r2-agent: Notice: Preparing to install into C:/ProgramData/PuppetLabs/code/environments/production/modules ...
    win2012r2-agent: Notice: Downloading from https://forgeapi.puppet.com ...
    win2012r2-agent: Notice: Installing -- do not interrupt ...
    win2012r2-agent: C:/ProgramData/PuppetLabs/code/environments/production/modules
    win2012r2-agent: └── puppetlabs-stdlib (v5.2.0)
    win2012r2-agent: Notice: Preparing to install into C:/ProgramData/PuppetLabs/code/environments/production/modules ...
    win2012r2-agent: Notice: Downloading from https://forgeapi.puppet.com ...
    win2012r2-agent: Notice: Installing -- do not interrupt ...
    win2012r2-agent: C:/ProgramData/PuppetLabs/code/environments/production/modules
    win2012r2-agent: └─┬ puppet-archive (v3.2.1)
    win2012r2-agent:   └── puppetlabs-stdlib (v5.2.0)
    win2012r2-agent: Notice: /Host[sensu-backend.example.com]/ensure: created
    win2012r2-agent: host { 'sensu-backend.example.com':
    win2012r2-agent:   ensure => 'present',
    win2012r2-agent:   ip     => '192.168.52.10',
    win2012r2-agent:   target => 'C:/Windows/System32/drivers/etc/hosts',
    win2012r2-agent: }
==> win2012r2-agent: Running provisioner: shell...
    win2012r2-agent: Running: inline PowerShell script
    win2012r2-agent: Info: Loading facts
    win2012r2-agent: Info: Loading facts
    win2012r2-agent: Info: Loading facts
    win2012r2-agent: Notice: Compiled catalog for win2012r2-agent in environment production in 1.31 seconds
    win2012r2-agent: Info: Applying configuration version '1558049378'
    win2012r2-agent: Notice: /Stage[main]/Sensu::Agent/Archive[sensu-go-agent.msi]/ensure: download archive from https://s3-us-west-2.amazonaws.com/sensu.io/sensu-go/5.7.0/sensu-go-agent_5.7.0.2380_en-US.x64.msi to C:\\sensu-go-agent_5.7.0.2380_en-US.x64.msi  without cleanup
    win2012r2-agent: Notice: /Stage[main]/Sensu::Agent/Package[sensu-go-agent]/ensure: created
    win2012r2-agent: Info: Computing checksum on file C:/ProgramData/Sensu/config/agent.yml.example
    win2012r2-agent: Info: /Stage[main]/Sensu/File[C:/ProgramData/Sensu/config/agent.yml.example]: Filebucketed C:/ProgramData/Sensu/config/agent.yml.example to puppet with sum 97e32c0f771b215986e8851de517171e
    win2012r2-agent: Notice: /Stage[main]/Sensu/File[C:/ProgramData/Sensu/config/agent.yml.example]/ensure: removed
    win2012r2-agent: Notice: /Stage[main]/Sensu::Ssl/File[sensu_ssl_dir]/ensure: created
    win2012r2-agent: Notice: /Stage[main]/Sensu::Ssl/File[sensu_ssl_ca]/ensure: defined content as '{md5}cd478579a6abb9f24ee3035bb1cdbc19'
    win2012r2-agent: Info: Class[Sensu::Ssl]: Scheduling refresh of Service[sensu-agent]
    win2012r2-agent: Notice: /Stage[main]/Sensu::Agent/File[sensu_agent_config]/ensure: defined content as '{md5}7f14d98043a5df0e1c69749d2bc1c681'
    win2012r2-agent: Info: /Stage[main]/Sensu::Agent/File[sensu_agent_config]: Scheduling refresh of Service[sensu-agent]
    win2012r2-agent: Notice: /Stage[main]/Sensu::Agent/Exec[install-agent-service]/returns: executed successfully
    win2012r2-agent: Notice: /Stage[main]/Sensu::Agent/Service[sensu-agent]: Triggered 'refresh' from 2 events
    win2012r2-agent: Notice: Applied catalog in 22.12 seconds
==> win2012r2-agent: Running provisioner: shell...
    win2012r2-agent: Running: inline PowerShell script
    win2012r2-agent: {
    win2012r2-agent:   version => "5.7.1",
    win2012r2-agent:   build => "5bf304b4e215f46cbcf30c7d5e73486d570dfaf6",
    win2012r2-agent:   built => "2019-05-06T20:53:02Z"
    win2012r2-agent: }

@treydock
Copy link
Collaborator Author

Modified windows provisioning for vagrant to use latest windows URL for 5.x of Puppet.

@ghoneycutt
Copy link
Collaborator

Success with all the windows versions in vagrant. Waiting on Travis then good to merge.

@ghoneycutt ghoneycutt merged commit 7fa00a0 into master May 18, 2019
@ghoneycutt ghoneycutt deleted the windows branch May 18, 2019 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Windows for agent
2 participants