Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Why in all OpsCode's cookbooks there is a

default[:netkernel][:version] = "4.1.1"
default[:netkernel][:install_url] = "http://apposite.netkernel.org/dist/1060-NetKernel-SE/1060-NetKernel-SE-4.1.1.jar"

default[:netkernel][:frontend][:port] = 8080

default[:netkernel][:backend][:address] = "localhost"
default[:netkernel][:backend][:port] = 1060

default[:netkernel][:user] = "netkernel"
default[:netkernel][:log_path] = "/var/log/netkernel"

instead of

default[:netkernel] = {
  :version => "4.1.1",
  :install_url => "http://apposite.netkernel.org/dist/1060-NetKernel-SE/1060-NetKernel-SE-4.1.1.jar",
  :frontend => {
    :port => 8080
  },
  :backend => {
    :address => "localhost"
  },
  :backend => {
    :port => 1060
  },
  :user => "netkernel",
  :log_path => "/var/log/netkernel"
}

Is this attributes definition equal to the first one?

Why first variant is prefered?

share|improve this question

1 Answer 1

These are identical. The only advantage I can see with the first example is that it's possible to create attributes based on the values of other attributes. e.g.

default[:foo][:a] = "a"
default[:foo][:b] = "b"
default[:foo][:ab] = "#{foo[:a]}#{foo[:b]}"
share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.