Skip to content

Commit 0a80dee

Browse files
author
Morgan Haskel
committed
Merge pull request voxpupuli#212 from hunner/fix_nohttpinterface
Fix nohttpinterface on >= 2.6
2 parents 570a5c2 + f8721c5 commit 0a80dee

File tree

4 files changed

+125
-4
lines changed

4 files changed

+125
-4
lines changed

manifests/server/config.pp

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,92 @@
8787
if $config_content {
8888
$cfg_content = $config_content
8989
} elsif (versioncmp($mongodb::globals::version, '2.6.0') >= 0) {
90+
# Template uses:
91+
# - $auth
92+
# - $bind_ip
93+
# - $configsvr
94+
# - $dbpath
95+
# - $directoryperdb
96+
# - $fork
97+
# - $ipv6
98+
# - $jounal
99+
# - $keyfile
100+
# - $logappend
101+
# - $logpath
102+
# - $maxconns
103+
# - $nohttpinteface
104+
# - $nojournal
105+
# - $noprealloc
106+
# - $noscripting
107+
# - $nssize
108+
# - $objcheck
109+
# - $oplog_size
110+
# - $pidfilepath
111+
# - $port
112+
# - $profile
113+
# - $quota
114+
# - $quotafiles
115+
# - $replset
116+
# - $rest
117+
# - $set_parameter
118+
# - $shardsvr
119+
# - $slowms
120+
# - $smallfiles
121+
# - $syslog
122+
# - $verbose
123+
# - $verbositylevel
90124
$cfg_content = template('mongodb/mongodb.conf.2.6.erb')
91125
} else {
126+
# Template uses:
127+
# - $auth
128+
# - $bind_ip
129+
# - $configsvr
130+
# - $cpu
131+
# - $dbpath
132+
# - $diaglog
133+
# - $directoryperdb
134+
# - $fork
135+
# - $ipv6
136+
# - $jounal
137+
# - $keyfile
138+
# - $logappend
139+
# - $logpath
140+
# - $master
141+
# - $maxconns
142+
# - $mms_interval
143+
# - $mms_name
144+
# - $mms_token
145+
# - $noauth
146+
# - $nohints
147+
# - $nohttpinteface
148+
# - $nojournal
149+
# - $noprealloc
150+
# - $noscripting
151+
# - $notablescan
152+
# - $nssize
153+
# - $objcheck
154+
# - $only
155+
# - $oplog_size
156+
# - $pidfilepath
157+
# - $port
158+
# - $profile
159+
# - $quiet
160+
# - $quota
161+
# - $quotafiles
162+
# - $replset
163+
# - $rest
164+
# - $set_parameter
165+
# - $shardsvr
166+
# - $slave
167+
# - $slowms
168+
# - $smallfiles
169+
# - $source
170+
# - $ssl
171+
# - $ssl_ca
172+
# - $ssl_key
173+
# - $syslog
174+
# - $verbose
175+
# - $verbositylevel
92176
$cfg_content = template('mongodb/mongodb.conf.erb')
93177
}
94178

spec/classes/server_spec.rb

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,41 @@
2020
it { expect { is_expected.to raise_error(Puppet::Error) } }
2121
end
2222

23-
end
23+
context 'setting nohttpinterface' do
24+
it "isn't set when undef" do
25+
is_expected.to_not contain_file('/etc/mongodb.conf').with_content(/nohttpinterface/)
26+
end
27+
context "sets nohttpinterface to true when true" do
28+
let(:params) do
29+
{ :nohttpinterface => true, }
30+
end
31+
it { is_expected.to contain_file('/etc/mongodb.conf').with_content(/nohttpinterface = true/) }
32+
end
33+
context "sets nohttpinterface to false when false" do
34+
let(:params) do
35+
{ :nohttpinterface => false, }
36+
end
37+
it { is_expected.to contain_file('/etc/mongodb.conf').with_content(/nohttpinterface = false/) }
38+
end
39+
context "on >= 2.6" do
40+
let(:pre_condition) do
41+
"class { 'mongodb::globals': version => '2.6.6', }"
42+
end
43+
it "isn't set when undef" do
44+
is_expected.to_not contain_file('/etc/mongodb.conf').with_content(/net\.http\.enabled/)
45+
end
46+
context "sets net.http.enabled false when true" do
47+
let(:params) do
48+
{ :nohttpinterface => true, }
49+
end
50+
it { is_expected.to contain_file('/etc/mongodb.conf').with_content(/net\.http\.enabled: false/) }
51+
end
52+
context "sets net.http.enabled true when false" do
53+
let(:params) do
54+
{ :nohttpinterface => false, }
55+
end
56+
it { is_expected.to contain_file('/etc/mongodb.conf').with_content(/net\.http\.enabled: true/) }
57+
end
58+
end
59+
end
60+
end

templates/mongodb.conf.2.6.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ net.http.RESTInterfaceEnabled: true
9696
<% if @maxconns -%>
9797
net.maxIncomingConnections: <%= @maxconns %>
9898
<% end -%>
99-
<% if @nohttpinterface -%>
100-
net.http.enabled: <%= @nohttpinterface %>
99+
<% if ! @nohttpinterface.nil? -%>
100+
net.http.enabled: <%= ! @nohttpinterface %>
101101
<% end -%>
102102

103103
#Replication

templates/mongodb.conf.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ oplogSize = <%= @oplog_size %>
8787
# Ignore query hints
8888
nohints = <%= @nohints %>
8989
<% end -%>
90-
<% if @nohttpinterface -%>
90+
<% if ! @nohttpinterface.nil? -%>
9191
# Disable the HTTP interface (Defaults to localhost:27018).
9292
nohttpinterface = <%= @nohttpinterface %>
9393
<% end -%>

0 commit comments

Comments
 (0)