Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like the Chef cookbook network_interfaces to have dynamic values for ip addresses, netmasks and alike for each of my nodes. What works for me is the following:

db_role.rb (block1):

override_attributes(
  "network_interfaces" => {
      :device => 'eth0',
      :address => '123.123.123.123',
  }
)

But that is not very dynamic. My idea was to submit the ip address(, netmask, etc.) to each node on knife bootstrap.

The node would then look like so (block2):

{
    "normal": {
      "network_interfaces" => {
          "device" : "eth0",
          "address" : "123.123.123.123"
      }
    },
    "name": "foobar",
    "run_list": [
       "recipe[zsh]",
       "role[networking_interfaces]"
    ]
}

Unfortunately the network_interfaces cookbook does not pick up those values by default. My idea was to reference the node specific attributes shown in block2 in the roles definition like so:

override_attributes(
  "network_interfaces" => {
      :device => node['network_interfaces']['device'],
      :address => node['network_interfaces']['address'],
  }
)

This does not work I guess because Chef can not handle dynamically allocated values in roles files.

How can I achieve to run the network_interfaces recipe and pass my node specific values to it?

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.