From 22e3a48e345a76ec2918b7e77ee9f1df4da621d7 Mon Sep 17 00:00:00 2001 From: Mike Smith Date: Wed, 1 Nov 2017 15:24:29 -0700 Subject: [PATCH] Confine NGINX version fact to exclude Cisco Nexus 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. --- lib/facter/nginx_version.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/facter/nginx_version.rb b/lib/facter/nginx_version.rb index 5a4de0ca9..6509d774b 100644 --- a/lib/facter/nginx_version.rb +++ b/lib/facter/nginx_version.rb @@ -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]