简体   繁体   中英

How to override “not default” attribute by vagrant with chef-solo?

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM