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 3, 2017
1 parent c2ccdf2 commit 22e3a48
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/facter/nginx_version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Facter.add(:nginx_version) do
confine { Facter.value(:kernel) != 'windows' }
confine { Facter.value(:operatingsystem) != 'nexus' }
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 22e3a48

Please sign in to comment.