Domanda

I was reading the Roles page at Opscode, and from what I understand, my role file, a ruby DSL, should look like this:

name "role_zabbix_agent_corp"
description "Assigning Server IP's to the config for Corporate side."
run_list "recipe[zabbix_agent_corp]"
default_attributes "zabbix_agent_corp" => { 
    "Server" => [ "zabbix-server1.com" ],
    "ServerActive" => [ "zabbix-server1.com" ]
}

However, when I perform the chef-client run, the attributes specified above do not fill in the blank spots in the config file. The name of the cookbook is zabbix_agent_corp and the attributes file is the default.rb file. Below are the attributes that are supposed to be filled in:

default['zabbix']['agent']['conf']['Server'] = ""
default['zabbix']['agent']['conf']['ServerActive'] = ""

Is there something I need to do differently to call the attributes in the cookbook, or is my role file not written correctly?

È stato utile?

Soluzione

The hash you create in the role needs to match the definition of the attribute.

In this instance your role should look like:

default_attributes
  'zabbix' => {
    'agent' => {
      'conf' => {
        'Server' => 'zabbix-server1.com',
        'ServerActive' => 'zabbix-server1.com'
      }
    }
  }

See the Ruby DSL section of the Chef docs for a complete reference.

Note: the Chef convention is that attribute names should be all lower-case with underscores instead of Pascal/CamelCase. E.g. ServerActive should be server_active.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top