0
votes

I am trying to override my default attributes set in the attributes file in my cookbook with ones set in the environments of my chef server.

This is my attributes file:

default['app']                  = 'tomcat_app' 
default['environment']          = 'env'
default['instance']             = 'tier'
default['application_name']     = "#{default['environment']}/#{default['app']}"
default['environment_instance'] = "#{default['environment']}/#{default['app']}/#{default['instance']}"
default['app_owner']            = 'app_user'
default['app_owner_group']      = 'app_group'

My environment it is configured as follows:

 {
    "app": {
        "tomcat_app": "NGS"
    },
    "environment": {
        "env": "/Test/Apps"
    },
    "instance": {
        "tier": "tst"
    },
    "app_owner": {
        "app_user": "ngsint"
    },
    "app_owner_group": {
        "app_group": "batchdev"
    },
    "override_attributes": {}
}

However during chef-client run these values are not replaced. I have set this in the default attributes of the environments.

1

1 Answers

1
votes

Attributes should be in default_attributes Hash/Object, it should look like:

  "default_attributes": {
    "app": {
        "tomcat_app": "NGS"
    },
    "environment": {
        "env": "/Test/Apps"
    },
    "instance": {
        "tier": "tst"
    },
    "app_owner": {
        "app_user": "ngsint"
    },
    "app_owner_group": {
        "app_group": "batchdev"
    }
  }

As explained in the documentation.