-
Notifications
You must be signed in to change notification settings - Fork 289
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
Fix Package[sensu] on windows #699
Fix Package[sensu] on windows #699
Conversation
6d8fc94
to
be06678
Compare
I'm looking into changing the package version from This issue with sensu_gem also needs to be addressed on Windows:
|
Looking at http://repositories.sensuapp.org/msi/, there is no sensu-latest.msi, so I see two options:
|
$sensu_plugin_provider = $::osfamily ? { | ||
'windows' => 'gem', | ||
default => undef, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This avoids Provider sensu_gem is not functional
on windows. Considered moving the behavior to package.pp, put it here to make it clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it not embedded on windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gem is embedded on windows, e.g. https://github.com/sensu/sensu-puppet/blob/30fe995/lib/puppet/provider/package/sensu_gem.rb#L16
It seems the parent gem
provider in puppet has a confinement preventing it from working on Windows. My guess is sensu_gem is inheriting this. I'll see if I can override and sensu_gem works.
manifests/package.pp
Outdated
$pkg_url_version = $::sensu::version ? { | ||
installed => 'latest', | ||
default => $pkg_version, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes http://repositories.sensuapp.org/msi/sensu-latest.msi exists, but it does not at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cwjohnston @agoddard could you please create this link
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The specific links will be based on the OS architecture and Major release. For example, the default computed links look like:
https://repositories.sensuapp.org/msi/2012r2/sensu-latest-x86.msi
https://repositories.sensuapp.org/msi/2012r2/sensu-latest-x64.msi
https://repositories.sensuapp.org/msi/2012/sensu-latest-x86.msi
https://repositories.sensuapp.org/msi/2012/sensu-latest-x64.msi
https://repositories.sensuapp.org/msi/2008r2/sensu-latest-x86.msi
https://repositories.sensuapp.org/msi/2008r2/sensu-latest-x64.msi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agoddard said he would create it manually and talk to the dev team to get it part of the release process
tests/sensu-client-windows.pp
Outdated
@@ -0,0 +1,9 @@ | |||
# Note: Check http://repositories.sensuapp.org/msi/ for the latest version. | |||
class { '::sensu': | |||
version => '0.26.5-1', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this back to WIP, this still doesn't work with Vagrant, getting a 404.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we want 0.29.0-7
at http://repositories.sensuapp.org/msi/2012r2/sensu-0.29.0-7-x86.msi
You might be having troubles with such an old version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the catch, I noticed newer releases are in the 2012r2 directory. Updating it to https://repositories.sensuapp.org/msi/2012r2/sensu-0.29.0-11-x64.msi
manifests/package.pp
Outdated
default => $pkg_version, | ||
} | ||
$pkg_title = 'sensu' | ||
$pkg_name = 'sensu' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why two variables here? why not just pkg_name ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, this behavior existed prior to the patch. I'll look into if they're necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tl;dr $pkg_name should be Sensu on windows to match Add/Remove Programs, $pkg_title should be sensu to match internal catalog relationships.
$pkg_name and $pkg_title are both necessary because the title is for internal Puppet references and relationships. This provides Package[sensu] consistently across platforms. On windows, the name of the MSI in Add/Remove programs is Sensu (capitalized). The MSI provider needs the name parameter to line up with Add/Remove programs, otherwise it will always report the package as absent.
b413eeb
to
b5611c1
Compare
manifests/init.pp
Outdated
# [*windows_pkg_url*] | ||
# String. If specified, override the behavior of computing the package source | ||
# URL from windows_repo_prefix and os major release fact. This parameter is | ||
# intended to provide an escape hatch to the situation where the package URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs should not reflect a problem with computing the URL incorrectly and should instead allow a user to use their own URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Updated to:
# [*windows_pkg_url*]
# String. If specified, override the behavior of computing the package source
# URL from windows_repo_prefix and os major release fact. This parameter is
# intended to allow the end user to override the source URL used to install
# the Windows package. For example:
# `"https://repositories.sensuapp.org/msi/2012r2/sensu-0.29.0-11-x64.msi"`
# Default: undef
manifests/package.pp
Outdated
# The OS Release specific sub-folder | ||
$os_release = $facts['os']['release']['major'] | ||
# e.g. '2012 R2' => '2012r2' | ||
$pkg_url_dir = inline_template("<%= @os_release.sub(/^(\\d+)\s*[rR](\\d+)/, '\\1r\\2') %>") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please convert this to use an .erb file, that it can be validated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Converted to an erb for validation.
b1b125b
to
987d04e
Compare
tests/sensu-client-windows.pp
Outdated
class { '::sensu': | ||
version => '0.29.0-11', | ||
windows_pkg_url => "${pkg_repo}/2012r2/sensu-0.29.0-11-x64.msi", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is great for testing, though we should use the default of just specifying the version and see that the module does the right thing and figures out how to build the url appropriately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, changed back to use version.
975f6ab
to
d8b6fb1
Compare
@ghoneycutt FYI, for the |
rabbitmq_host => '192.168.56.10', | ||
rabbitmq_vhost => '/sensu', | ||
subscriptions => 'all', | ||
client_address => $facts['networking']['ip'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In your vagrant, this should use the 192. IP and not the 10.
I check in http://localhost:3000/#/clients
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This must be non-deterministic behavior in the networking fact. Joy. In my vagrant vm $facts['networking']['ip'] resolves to 192.168.56.15. I assume this resolves to 10.0.2.15 for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghoneycutt Please LMK if $facts['networking']['ip']
is resolving to the incorrect 10.0.2.15
address for you. Digging into this, the networking fact returns the IP of the primary interface, and the opentable wind2012r2 VM has the second network interface marked as primary. With this information I expect $facts['networking']['ip']
to be robust.
I've also confirmed the IP shows up as 192.168.56.15 at http://localhost:3000/#/clients
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can also check with curl -s http://admin:[email protected]:4567/clients | jq .
Warning is a lot scarier than a notice.
Without this patch there is no test coverage for Package[sensu] when the client is a windows node. This patch adds test coverage to fix the bug reported in sensuGH-646.
Without this patch there isn't a Vagrant VM for Win2012r2. Windows is necessary to reproduce the issue in sensuGH-646 and smoke test the fix. Using opentable/win-2012r2 Vagrant vm client RDP port is exposed. Login is vagrant / vagrant. Relates to sensu#681
I've manually created symlinks for sensu-latest-x86.msi and sensu-latest-x64.msi in each windows platform version directory, e.g. https://repositories.sensuapp.org/msi/2012r2/sensu-latest-x64.msi |
Great, thanks!
|
d8b6fb1
to
3e503f3
Compare
Partially resolves sensu#646 Still running into this error: Error: Parameter ensure failed on Package[sensu]: Provider windows must have features 'upgradeable' to set 'ensure' to 'latest' at sensu/manifests/package.pp:64
Without this patch the default package version for sensu is `latest`. This is a problem for two reasons, first the package may be automatically upgraded on Linux systems, which is a burden for Operations when behavior changes. Second, Windows does not have a provider supporting the upgradable feature which results in an error in the default case. This path addresses both issues by defaulting the version to `installed`. For the Windows 2012r2 Vagrant box, the version is explicitly passed in tests/sensu-client-windows.pp because http://repositories.sensuapp.org/msi/ does not have sensu-latest.msi, which is used in the default case.
Without this patch the computation of the package source URL will inevitably be incorrect for some users. To avoid support issues, this patch adds an override as an escape hatch. The user may specific the specific package source URL which will override the computation.
Huzzah! Finally got a clean puppet run on Windows 2012r2 with 7c523c3 Needed to bump the VM memory up to 2048 MB otherwise Puppet just kept hanging indefinitely.
The resulting Vagrant VM shows up correctly with a 192.168.56.15 address at http://localhost:3000/#/clients |
0b20e39
to
d928ca6
Compare
The name parameter of Package[sensu] needs to match Add/Remove programs, which is `Sensu`
The OS expects version numbers to be dotted, e.g. 0.29.0.11, whereas the file paths have a hyphen denoting the release component. This patch maps the file version ID to the package version ID to allow the catalog to converge.
d928ca6
to
98513d0
Compare
@ghoneycutt This is finally ready for review / merge (hopefully). Provisioning win2012r2-client works, the puppet run converges in a single run, and the windows sensu client registers with sensu-server using 192.168.56.15 as the client IP. All other comments up to now have been addressed. |
Testing this now |
tests/provision_basic_win.ps1
Outdated
} else { | ||
Write-Output "Installing Puppet from $agent_url" | ||
Write-Output "Log will be written to $log" | ||
Remove-Item $log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the remove here? seems to be causing issues.
==> win2012r2-client: Log will be written to C:/vagrant/puppet-agent.log
==> win2012r2-client: Remove-Item : Cannot find path 'C:\vagrant\puppet-agent.log' because it does
==> win2012r2-client: not exist.
==> win2012r2-client: At C:\tmp\vagrant-shell.ps1:9 char:3
==> win2012r2-client: + Remove-Item $log
==> win2012r2-client: + ~~~~~~~~~~~~~~~~
==> win2012r2-client: + CategoryInfo : ObjectNotFound: (C:\vagrant\puppet-agent.log:Str
==> win2012r2-client: ing) [Remove-Item], ItemNotFoundException
==> win2012r2-client: + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.Remov
==> win2012r2-client: eItemCommand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the log because it was originally verbose, huge, and grew indefinitely. I'll add a test to remove only if present.
Vagrantfile
Outdated
client.vm.box = "opentable/win-2012r2-standard-amd64-nocm" | ||
client.vm.provider :virtualbox do |vb| | ||
vb.customize ["modifyvm", :id, "--memory", "2048"] | ||
vb.customize ["modifyvm", :id, "--cpus", "2"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use 1 cpu here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, will change.
This works, just need clarification on using 1 cpu and the remove log part in the windows provisioner |
Also, please change the port to use '3389'. The microsoft remote desktop client for osx doesnt allow you to specify a port. Also add |
Will change. As an FYI, I added the PC Name as |
Remove agent install log only if the log exists. Avoids this error: ==> win2012r2-client: Log will be written to C:/vagrant/puppet-agent.log ==> win2012r2-client: Remove-Item : Cannot find path 'C:\vagrant\puppet-agent.log' because it does ==> win2012r2-client: not exist. ==> win2012r2-client: At C:\tmp\vagrant-shell.ps1:9 char:3 ==> win2012r2-client: + Remove-Item $log ==> win2012r2-client: + ~~~~~~~~~~~~~~~~ ==> win2012r2-client: + CategoryInfo : ObjectNotFound: (C:\vagrant\puppet-agent.log:Str ==> win2012r2-client: ing) [Remove-Item], ItemNotFoundException ==> win2012r2-client: + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.Remov ==> win2012r2-client: eItemCommand
@ghoneycutt Updated with 1 CPU, remove puppet-agent.log if present, and RDP on 3389. |
Solves #646 |
Solves #681 |
Thanks @jeffmccune ! |
Released in v2.8.0 |
Seeking feedback on how to handle
ensure => latest
on Windows with this error:Partially resolves #646 (Need to overcome ensure => latest error)
Partially resolves #681 (Windows)
Todo
Remote_file[C:\Windows\Temp\sensu-latest.msi]
to handleversion => installed
Provider sensu_gem is not functional
on windows==> win2012r2-client: Error: /Stage[main]/Sensu::Client::Service/Exec[install-sensu-client]: Could not evaluate: Could not find command 'powershell.exe'
Stage[main]/Sensu::Package/Package[sensu]/ensure: created
Notice: /Stage[main]/Sensu::Package/Package[sensu]/ensure: ensure changed '0.29.0.11' to '0.29.0-11'
This explains the string substitution I removed and didn't understand.