Skip to content

Commit

Permalink
Merge pull request #573 from pecharmin/fix_facter_allowSSL
Browse files Browse the repository at this point in the history
fix(is_master-fact): use --ssl if --sslPEMKeyFile or --sslCAFile is s…
  • Loading branch information
bastelfreak authored Feb 10, 2020
2 parents 68480fb + 473b602 commit 24072a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions lib/facter/is_master.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ def get_options_from_hash_config(config)
result = []

result << "--port #{config['net.port']}" unless config['net.port'].nil?
result << "--ssl --host #{Facter.value(:fqdn)}" if config['net.ssl.mode'] == 'requireSSL'
# use --ssl and --host if:
# - sslMode is "requireSSL"
# - Parameter --sslPEMKeyFile is set
# - Parameter --sslCAFile is set
result << "--ssl --host #{Facter.value(:fqdn)}" if config['net.ssl.mode'] == 'requireSSL' || !config['net.ssl.PEMKeyFile'].nil? || !config['net.ssl.CAFile'].nil?
result << "--sslPEMKeyFile #{config['net.ssl.PEMKeyFile']}" unless config['net.ssl.PEMKeyFile'].nil?
result << "--sslCAFile #{config['net.ssl.CAFile']}" unless config['net.ssl.CAFile'].nil?
result << '--ipv6' unless config['net.ipv6'].nil?
Expand All @@ -28,7 +32,11 @@ def get_options_from_keyvalue_config(file)
result = []

result << "--port #{config['port']}" unless config['port'].nil?
result << "--ssl --host #{Facter.value(:fqdn)}" if config['ssl'] == 'requireSSL'
# use --ssl and --host if:
# - sslMode is "requireSSL"
# - Parameter --sslPEMKeyFile is set
# - Parameter --sslCAFile is set
result << "--ssl --host #{Facter.value(:fqdn)}" if config['ssl'] == 'requireSSL' || !config['sslcert'].nil? || !config['sslca'].nil?
result << "--sslPEMKeyFile #{config['sslcert']}" unless config['sslcert'].nil?
result << "--sslCAFile #{config['sslca']}" unless config['sslca'].nil?
result << '--ipv6' unless config['ipv6'].nil?
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/provider/mongodb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def self.conn_string
first_ip_in_list = bindip.split(',').first
ip_real = case first_ip_in_list
when '0.0.0.0'
'127.0.0.1'
Facter.value(:fqdn)
when %r{\[?::0\]?}
'::1'
Facter.value(:fqdn)
else
first_ip_in_list
end
Expand Down

0 comments on commit 24072a9

Please sign in to comment.