Skip to content

Commit

Permalink
Confine NGINX version fact to exclude Cisco Nexus
Browse files Browse the repository at this point in the history
Cisco Nexus Switches may run older version of NGINX
internally in which the command 'nginx -v' disables
the nxapi socket (deletes sock file) on second or
later runs.  Tested on CIsco NXOS 9k. Refactor ruby
fact moving kernel/OS to confine block as well.
  • Loading branch information
murdok5 committed Nov 2, 2017
1 parent a1718db commit ac79eb6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/facter/nginx_version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Facter.add(:nginx_version) do
confine do
Facter.value(:kernel) != 'windows' && Facter.value(:operatingsystem) != 'nexus'
end
setcode do
if Facter.value('kernel') != 'windows' && (Facter::Util::Resolution.which('nginx') || Facter::Util::Resolution.which('openresty'))
if Facter::Util::Resolution.which('nginx') || Facter::Util::Resolution.which('openresty')
nginx_version_command = Facter::Util::Resolution.which('nginx') ? 'nginx -v 2>&1' : 'openresty -v 2>&1'
nginx_version = Facter::Util::Resolution.exec(nginx_version_command)
%r{nginx version: (nginx|openresty)\/([\w\.]+)}.match(nginx_version)[2]
Expand Down

0 comments on commit ac79eb6

Please sign in to comment.