We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents d6141b5 + 35190a4 commit d149acaCopy full SHA for d149aca
lib/facter/is_master.rb
@@ -0,0 +1,12 @@
1
+require 'json';
2
+
3
+Facter.add('mongodb_is_master') do
4
+ setcode do
5
+ if Facter::Core::Execution.which('mongo')
6
+ mongo_output = Facter::Core::Execution.exec('mongo --quiet --eval "load(\'/root/.mongorc.js\'); printjson(db.isMaster())"')
7
+ JSON.parse(mongo_output.gsub(/ISODate\((.+?)\)/, '\1 '))['ismaster'] ||= false
8
+ else
9
+ 'not_installed'
10
+ end
11
12
+end
0 commit comments