4

Question

I'm using vagrant with chef-solo provision.

  1. How to override "not default" attribute?
  2. If I will create chef-recipe, When should I use "not default" attribute?

Description

I saw openldap['rootpw'] in attribute of openldap

I would like to override openldap['rootpw'] of attribute.

I tried to override configuration, following like

# Vagrantfile
Vagrant::Config.run do |config|
  config.vm.provision :chef_solo do |chef|

    #....

    chef.json = {
      'rootpw' => 'xxxx....',
      'openldap' => {
        'rootpw' => 'xxxx....'
      }
    }
  end
end

But, attribute was not overridden.

I think, it could override if attribute was default['openldap']['rootpw'].

How to override "not default" attribute?

niku
  • 363
  • 1
  • 3
  • 14

2 Answers2

1

Use override attributes. You can set them in different places (recipe, role, environment), perhaps you can find the suitable for you.

Draco Ater
  • 20,820
  • 8
  • 62
  • 86
1

You cannot override a "not default" attribute as easily as a default because it evaluates lower down the chain. Basically, the order is a continuum of default, force_default, normal,override, force_override, automatic. If you want something to be overridden just go further down the list. It's best practice to use defaults and override them.

http://docs.opscode.com/essentials_cookbook_attribute_files.html#attribute-precedence

jmontross
  • 3,533
  • 1
  • 21
  • 17