3

This is the cookbook I downloaded: https://github.com/edelight/chef-mongodb

I installed Chef server, Chef workstation, and have a testnode ready to bootstrap.

A role I created:

$ knife role create mongodb_standalone_testproj

JSON format:

{
  "name": "mongodb_standalone_testproj",
  "description": "Deploy MongoDB standalone with override attributes",
  "json_class": "Chef::Role",
  "default_attributes": {
  },
  "override_attributes": {
    "mongodb::default": {
      "port": "27060",
      "dbpath": "/data/"
    }
  },
  "chef_type": "role",
  "run_list": [
    "recipe[mongodb::default]"
  ],
  "env_run_lists": {
  }
}

However, when I bootstrap the testnode with this role:

knife bootstrap testnode --sudo -x <omit> -P <omit> -N testnode -r 'role[mongodb_standalone_testproj]'

log here: http://pastebin.com/DWxY3vNV

Problem is, MongoDB installed and ran on testnode but the override attributes (port and dbpath) did not get applied, any clues?

Christian P
  • 12,032
  • 6
  • 60
  • 71
Howard Lee
  • 977
  • 1
  • 11
  • 20

2 Answers2

58

Those attributes are not correct:

"override_attributes": {
  "mongodb::default": {
    "port": "27060",
    "dbpath": "/data/"
  }
},

I'm willing to bet you want:

"override_attributes": {
  "mongodb": {
    "config": {
      "port": "27060",
      "dbpath": "/data/"
    }
  }
},
Kevin Panko
  • 8,356
  • 19
  • 50
  • 61
sethvargo
  • 26,739
  • 10
  • 86
  • 156
3

I think you're just overriding the wrong attribute (not the full attribute). Looking at the defaults for the mongodb cookbook they list:

default['mongodb']['config']['port'] = 27017

But you are using the equivalent of:

['mongodb']['port']
Display Name is missing
  • 6,197
  • 3
  • 34
  • 46
  • 31
    Why didn't you just edit the answer by @sethvargo to fix what readily appears to be a simply oversight? – Lawrence Dol Jun 06 '14 at 17:37
  • 6
    @LawrenceDol because that's an invalid edit. Every user should post the relevant code for the answer and it should work as is or almost as is, and before the edit, that was **a wrong answer**, while this was the right one. – Luiggi Mendoza Jun 09 '14 at 20:30