From 7b5d2d9d16f6bb4482108e96cb054279f839d80b Mon Sep 17 00:00:00 2001 From: Ben O'Hara Date: Wed, 29 Jun 2016 23:48:20 +1000 Subject: [PATCH] Only check if master if mongod installed Stop the fact failing on machines that have the mongo client installed, but arn't running the server. --- lib/facter/is_master.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/facter/is_master.rb b/lib/facter/is_master.rb index f4eb3a478..a53f59b66 100644 --- a/lib/facter/is_master.rb +++ b/lib/facter/is_master.rb @@ -2,7 +2,7 @@ Facter.add('mongodb_is_master') do setcode do - if Facter::Core::Execution.which('mongo') + if ['mongo', 'mongod'].all? {|m| Facter::Util::Resolution.which m} e = File.exists?('/root/.mongorc.js') ? 'load(\'/root/.mongorc.js\'); ' : '' mongo_output = Facter::Core::Execution.exec("mongo --quiet --eval \"#{e}printjson(db.isMaster())\"") JSON.parse(mongo_output.gsub(/ISODate\((.+?)\)/, '\1 ').gsub(/ObjectId\(([^)]*)\)/, '\1'))['ismaster'] ||= false