A Chef cookbook for importing data into a mongodb database.
Add to your Berksfile or Cheffile:
cookbook 'mongodb-import', :git => 'git://github.com/gesinger/chef-mongodb-import.git'
Specify the attributes you want to use, and the mongodb-import::default recipe in your run list (this example uses the vagrant synced folder):
"mongodb_import": {
"db": "mydb",
"collection": "mycollection",
"file": "/vagrant/files/exported_data.json"
},
"run_list": [
"recipe[mongodb-import::default]"
]
See full documentation for mongoimport for all available parameters.
mongodb_import[:file]
- The location of the file to import on the remote hostmongodb_import[:db]
- The mongodb database namemongodb_import[:collection]
- The mongodb collection namemongodb_import[:host]
mongodb_import[:port]
mongodb_import[:dbpath]
mongodb_import[:use_journal]
mongodb_import[:ignore_blanks]
mongodb_import[:tail]
- Any additional parameters you want to pass to mongoimport
mongodb-import uses an internal cookbook for testing called mongodb-import-test. This does some file copying and external cookbook running in order to properly test that the data was imported.
In order to test everything yourself:
- Check out the repo
- Run
bundle install
- Run
berks install
- Run
kitchen test