88class Puppet ::Provider ::Mongodb < Puppet ::Provider
99 # Without initvars commands won't work.
1010 initvars
11- commands mongo : 'mongo '
11+ commands mongosh : 'mongosh '
1212
1313 # Optional defaults file
14- def self . mongorc_file
15- "load('#{ Facter . value ( :root_home ) } /.mongorc .js'); " if File . file? ( "#{ Facter . value ( :root_home ) } /.mongorc .js" )
14+ def self . mongoshrc_file
15+ "load('#{ Facter . value ( :root_home ) } /.mongoshrc .js'); " if File . file? ( "#{ Facter . value ( :root_home ) } /.mongoshrc .js" )
1616 end
1717
18- def mongorc_file
19- self . class . mongorc_file
18+ def mongoshrc_file
19+ self . class . mongoshrc_file
2020 end
2121
2222 def self . mongod_conf_file
@@ -74,7 +74,7 @@ def self.tls_invalid_hostnames(config = nil)
7474 config [ 'tlsallowInvalidHostnames' ]
7575 end
7676
77- def self . mongo_cmd ( db , host , cmd )
77+ def self . mongosh_cmd ( db , host , cmd )
7878 config = mongo_conf
7979
8080 args = [ db , '--quiet' , '--host' , host ]
@@ -101,7 +101,7 @@ def self.mongo_cmd(db, host, cmd)
101101 end
102102
103103 args += [ '--eval' , cmd ]
104- mongo ( args )
104+ mongosh ( args )
105105 end
106106
107107 def self . conn_string
@@ -137,9 +137,9 @@ def self.conn_string
137137
138138 def self . db_ismaster
139139 cmd_ismaster = 'db.isMaster().ismaster'
140- cmd_ismaster = mongorc_file + cmd_ismaster if mongorc_file
140+ cmd_ismaster = mongoshrc_file + cmd_ismaster if mongoshrc_file
141141 db = 'admin'
142- res = mongo_cmd ( db , conn_string , cmd_ismaster ) . to_s . split ( %r{\n } ) . last . chomp
142+ res = mongosh_cmd ( db , conn_string , cmd_ismaster ) . to_s . split ( %r{\n } ) . last . chomp
143143 res . eql? ( 'true' )
144144 end
145145
@@ -156,14 +156,14 @@ def self.auth_enabled(config = nil)
156156 def self . mongo_eval ( cmd , db = 'admin' , retries = 10 , host = nil )
157157 retry_count = retries
158158 retry_sleep = 3
159- cmd = mongorc_file + cmd if mongorc_file
159+ cmd = mongoshrc_file + cmd if mongoshrc_file
160160
161161 out = nil
162162 begin
163163 out = if host
164- mongo_cmd ( db , host , cmd )
164+ mongosh_cmd ( db , host , cmd )
165165 else
166- mongo_cmd ( db , conn_string , cmd )
166+ mongosh_cmd ( db , conn_string , cmd )
167167 end
168168 rescue StandardError => e
169169 retry_count -= 1
0 commit comments