- From: Sam Darwin <
>
- To: millisami r <
>
- Cc: chef <
>
- Subject: [chef] Re: How to configure apt to not hit the repo every time?
- Date: Sat, 18 May 2013 18:02:13 +0300
To answer a more general and generic question, which is not specific
to Vagrant or Berkshelf: "how do I prevent apt-get update from running
too often?", use this code in the recipe, in place of the line
calling "apt-get update":
if node['platform_family'] == "debian"
if node['platform_version'].to_f >= 12
x = execute "apt-get update" do
action :nothing
not_if do
::File.exists?('/var/lib/apt/periodic/update-success-stamp') &&
::File.mtime('/var/lib/apt/periodic/update-success-stamp') >
Time.now - 86400*7
end
end
else
x = execute "apt-get update" do
action :nothing
command "touch /tmp/apt-get-update ; /usr/bin/apt-get update"
not_if do
::File.exists?('/tmp/apt-get-update') &&
::File.mtime('/tmp/apt-get-update') > Time.now - 86400*7
end
end
end
x.run_action(:run)
end
On Sat, May 18, 2013 at 2:27 PM, millisami r
<
>
wrote:
>
Hi, I'm developing a cookbook using Berkshelf and Vagrant latest.
>
>
There is a place in the recipe that runs apt-get update frequently and other
>
dependent cookbooks too like the following:
>
>
[2013-05-18T11:21:48+00:00] INFO: Processing execute[apt-get update] action
>
run (mysql::ruby line 23)
>
>
Its fine on the production node, but in the vagrant provision way, every
>
time I run, it will hit the apt-get update which is a bit slow coz it hits
>
via the internet.
>
>
How can I configure Vagrant to just hit only once in a single vagrant
>
provision command?
>
Or do I have to do change something else?
>
>
@millisami
>
~Sachin Sagar Rai
>
Ruby on Rails Developer
>
http://tfm.com.np
>
http://nepalonrails.com
Archive powered by MHonArc 2.6.16.