Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for pure yaml in is_master.rb #741

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions lib/facter/is_master.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ def mongod_conf_file
def get_options_from_hash_config(config)
result = []

result << "--port #{config['net.port']}" unless config['net.port'].nil?
# use --tls and --host if:
# - tlsMode is "requireTLS"
# - Parameter --tlsCertificateKeyFile is set
# - Parameter --tlsCAFile is set
result << "--tls --host #{Facter.value(:fqdn)}" if config['net.tls.mode'] == 'requireTLS' || !config['net.tls.certificateKeyFile'].nil? || !config['net.tls.CAFile'].nil?
result << "--tlsCertificateKeyFile #{config['net.tls.certificateKeyFile']}" unless config['net.tls.certificateKeyFile'].nil?
result << "--tlsCAFile #{config['net.tls.CAFile']}" unless config['net.tls.CAFile'].nil?

result << '--ipv6' unless config['net.ipv6'].nil?
port = config['net.port'] || config.fetch('net', {}).fetch('port', nil)
ipv6 = config['net.ipv6'] || config.fetch('net', {}).fetch('ipv6', nil)
tls_mode = config['net.tls.mode'] || config.fetch('net', {}).fetch('tls', {}).fetch('mode', nil)
tls_cert_key = config['net.tls.certificateKeyFile'] || config.fetch('net', {}).fetch('tls', {}).fetch('certificateKeyFile', nil)
tls_ca = config['net.tls.CAFile'] || config.fetch('net', {}).fetch('tls', {}).fetch('CAFile', nil)

result << "--port #{port}" unless port.nil?
result << '--ipv6' if ipv6
unless tls_mode.nil? || tls_mode == 'diabled'
result << "--tls --host #{Facter.value(:fqdn)}"
result << "--tlsCertificateKeyFile #{tls_cert_key}" unless tls_cert_key.nil?
result << "--tlsCAFile #{tls_ca}" unless tls_ca.nil?
end

result.join(' ')
end
Expand Down