Skip to content

Commit

Permalink
extended options
Browse files Browse the repository at this point in the history
  • Loading branch information
szelcsanyi committed Sep 9, 2015
1 parent 6794a57 commit 13c37a9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ Please note that this cookbook does not use the 10gen apt repository, and instea
## Usage
###Provider parameters:

* `url`: url for mongodb binary tgz
* `url`: url for mongodb binary tgz (default: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.1.tgz)
* `home`: directory for mongodb instance (default "/opt")
* `bind_ip`: listen address (default "127.0.0.1")
* `port`: listen port (default 27017)
* `default_instance`: creates symlink (default false)
* `replSet`: replica set name (default not set)
* `smallfiles`: use smallfile allocation (default false)
* `journal`: use durable journaling (default true)
* `notablescan`: disables queries using fts (default true)

#### A mongodb instance with custom parameters:
```ruby
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
description 'Installs/Configures mongodb, multi instance support'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
name 'L7-mongo'
version '1.0.3'
version '1.0.4'
source_url 'https://github.com/szelcsanyi/chef-mongo'
issues_url 'https://github.com/szelcsanyi/chef-mongo/issues'

Expand Down
11 changes: 7 additions & 4 deletions providers/db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def whyrun_supported?
system true
action :create
only_if do
File.readlines('/etc/passwd').grep(/^mongodb/).size <= 0
::File.readlines('/etc/passwd').grep(/^mongodb/).size <= 0
end
end

Expand Down Expand Up @@ -81,7 +81,10 @@ def whyrun_supported?
pidfile: base + '/var/mongodb.pid',
log: base + '/log/mongodb.log',
datadir: base + '/data',
replSet: new_resource.replSet
replSet: new_resource.replSet,
notablescan: new_resource.notablescan,
smallfiles: new_resource.smallfiles,
journal: new_resource.journal
)
end
new_resource.updated_by_last_action(t.updated_by_last_action?)
Expand All @@ -92,7 +95,7 @@ def whyrun_supported?
end
end

filename = File.basename(new_resource.url)
filename = ::File.basename(new_resource.url)
dirname = filename.sub(/(\.tar\.gz$|\.tgz$)/, '')

bash 'get_mongodb_binary' do
Expand All @@ -103,7 +106,7 @@ def whyrun_supported?
tar -zxf #{filename}
EOH
not_if do
File.exist?(base + '/' + filename)
::File.exist?(base + '/' + filename)
end
end

Expand Down
3 changes: 3 additions & 0 deletions resources/db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
attribute :port, kind_of: [Integer, String], default: '27017'
attribute :default_instance, kind_of: [FalseClass, TrueClass], default: false
attribute :replSet, kind_of: [NilClass, String], default: nil
attribute :notablescan, kind_of: [FalseClass, TrueClass], default: true
attribute :smallfiles, kind_of: [FalseClass, TrueClass], default: true
attribute :journal, kind_of: [FalseClass, TrueClass], default: true

def initialize(*args)
super
Expand Down
13 changes: 11 additions & 2 deletions templates/default/etc/mongodb.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ bind_ip = <%= Array(@bind_ip).join(',') %>
directoryperdb = true

# Disables write-ahead journaling
# nojournal = true
<% if @journal %>
journal = true
nojournal = false
<% else %>
journal = false
nojournal = true
<% end %>

# Enables periodic logging of CPU utilization and I/O wait
#cpu = true
Expand Down Expand Up @@ -56,7 +62,7 @@ directoryperdb = true
#noscripting = true

# Turns off table scans. Any query that would do a table scan fails.
#notablescan = true
notablescan = <%= @notablescan %>

# Disable data file preallocation.
#noprealloc = true
Expand All @@ -71,3 +77,6 @@ directoryperdb = true

# Unix socket
unixSocketPrefix = <%= @socket %>

# Smallfiles
smallfiles = <%= @smallfiles %>

0 comments on commit 13c37a9

Please sign in to comment.