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

后端 未结 12 1529
一生所求
一生所求 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:55

    apt-get update should be running first the way you have it. However, the recipe will only update once every 24 hours:

    execute "apt-get-update-periodic" do
      command "apt-get update"
      ignore_failure true
      only_if do
        File.exists?('/var/lib/apt/periodic/update-success-stamp') &&
        File.mtime('/var/lib/apt/periodic/update-success-stamp') < Time.now - 86400
      end
    end
    

提交回复
热议问题