summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2017-02-01 21:42:50 -0500
committerMicah Anderson <micah@riseup.net>2017-02-01 21:42:50 -0500
commit0cd2a305f7fd9ba830a1fa3de25428ffa71d39f7 (patch)
tree1fb0b8dbe2bb034d46bd455eac713cbcbac42783
parentb140aabf7c4e0a0ded0a69368c4fce354c1f96e8 (diff)
Fix fact for when shorewall is not yet installed.
When a node has puppet run for the first time, shorewall may not be installed. In that case there are a few problems that appear in puppet4: 1. Warning: Facter: Could not retrieve fact='shorewall_major_version', resolution='<anonymous>': undefined method `split' for nil:NilClass This is because running 'shorewall version' fails and so results in a nil, and the split cannot be done on a nil. That is solved by first running the 'shorewall version' and setting a variable. If that variable is not nil, then we can split off of that 2. Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, 'versioncmp' parameter 'a' expects a String value, got Undef This happens because the shorewall_version is set to Undef, but we need to have it set to a String. So we set the variable to '-1' if it is not installed.
-rw-r--r--lib/facter/shorewall_major_version.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/facter/shorewall_major_version.rb b/lib/facter/shorewall_major_version.rb
index 0068b48..9c53ec2 100644
--- a/lib/facter/shorewall_major_version.rb
+++ b/lib/facter/shorewall_major_version.rb
@@ -1,5 +1,10 @@
Facter.add("shorewall_major_version") do
setcode do
- Facter::Util::Resolution.exec('shorewall version').split('.').first || nil
+ shorewall_version = Facter::Util::Resolution.exec('shorewall version')
+ if shorewall_version != nil
+ shorewall_major_version = shorewall_version.split('.').first
+ else
+ shorewall_major_version = '-1'
+ end
end
end