How can I get Chef to run apt-get update before running other recipes

后端 未结 12 1513
一生所求
一生所求 2021-01-31 02:01

Right now I have the following in my Vagrantfile:

config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = \"cookbooks\"
    chef.add_recipe \"apt\"
           


        
12条回答
  •  既然无缘
    2021-01-31 02:43

    Without patching, this is a generic approach to the problem that will update on every run:

    bash "update-apt-repository" do
      user "root"
      code <<-EOH
      apt-get update
      EOH
    end
    

    It may be worth considering that such a run, on every run, ties up a fair bit of system resources for about 30 seconds; you may want to have a special recipe named recipe::update_apt that you have run via cron or via some other event i.e.

    chef-client -o "recipe[yourrecipe::update_apt]"
    

提交回复
热议问题