-
-
Notifications
You must be signed in to change notification settings - Fork 883
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
Confine nginx_version fact #815
Conversation
@@ -1,4 +1,5 @@ | |||
Facter.add(:nginx_version) do | |||
confine :kernel => [ 'Linux' , 'SunOS' , 'FreeBSD' ] |
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 theory, nginx can run on Windows: http://nginx.org/en/download.html
Given the operating system support listed in https://github.com/jfryman/puppet-nginx/blob/master/metadata.json#L25-L59, this seems like a sane approach to me! |
I'd rather have special behavior for Windows than white list individual *nix kernels, since some will inevitably be missed. Can you please try the following on your Windows box? If you can also check the fact on any *nix boxes to make sure it still works that would be great. I don't have access to either at the moment. I'm not sure if the Windows fact will be ignored because it returns Facter.add(:nginx_version) do
confine :kernel => 'Windows'
setcode do
return nil
end
end
Facter.add(:nginx_version) do
setcode do
if Facter::Util::Resolution.which('nginx')
nginx_version = Facter::Util::Resolution.exec('nginx -v 2>&1')
%r{^nginx version: nginx\/([\w\.]+)}.match(nginx_version)[1]
end
end
end |
I was hopeful, but returning nil continued on to the next resolution. |
This should work: Facter.add(:nginx_version) do
setcode do
if Facter.value(:kernel) == 'windows'
nginx_version = nil
elsif Facter::Util::Resolution.which('nginx')
nginx_version = Facter::Util::Resolution.exec('nginx -v 2>&1')
%r{^nginx version: nginx\/([\w\.]+)}.match(nginx_version)[1]
end
end
end |
@danzilio that works perfectly. Tested on Windows and CentOS 6. |
Edit: Ignore the below, solution was posted above already. Unfortunate - can you try this for me? If it works please rebase your branch on master since there are some fixes for tests in there, and hopefully the facter test will pass. Facter.add(:nginx_version) do
setcode do
kernel = Facter.value('kernel')
if kernel != 'windows' && Facter::Util::Resolution.which('nginx')
nginx_version = Facter::Util::Resolution.exec('nginx -v 2>&1')
%r{^nginx version: nginx\/([\w\.]+)}.match(nginx_version)[1]
end
end
end |
It did a combination of both your changes. I've tested on Windows and CentOS 6, with and without Nginx installed. It's working for me. I pushed the update to this patch. Facter.add(:nginx_version) do
setcode do
if Facter.value('kernel') != 'windows' && Facter::Util::Resolution.which('nginx')
nginx_version = Facter::Util::Resolution.exec('nginx -v 2>&1')
%r{^nginx version: nginx\/([\w\.]+)}.match(nginx_version)[1]
end
end
end |
One last request: can you please squash to a single commit? Once done I'll merge right away. Thank you! |
@3flex Done. Thanks! |
Confine nginx_version fact
Confine nginx_version fact
If this fact is not confined it will display a dialog on Windows which requires interaction. If puppet runs silently, it will hang.
Fixes #814