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?
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?
You might look into the resolver cookbook to set up your VM DNS. I found that by default the VM passes everything to VirtualBox and, only when that timed out, to the host machine's DNS gateway. My build times dropped 25% when I put resolver in as the first recipe in the run list.
Or run vagrant with --no-provisioner and if you need chef to do something
just run the chef scripts. Or is it something else you are looking for?
On Saturday, May 18, 2013, Mark Nichols wrote:
On May 18, 2013, at 6:27 AM, millisami r <millisami@gmail.com<javascript:_e({}, 'cvml', 'millisami@gmail.com');>>
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?
You might look into the resolver cookbook to set up your VM DNS. I found
that by default the VM passes everything to VirtualBox and, only when that
timed out, to the host machine's DNS gateway. My build times dropped 25%
when I put resolver in as the first recipe in the run list.
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 - 864007
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 - 864007
end
end
end
x.run_action(:run)
end
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?
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 - 864007
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 - 864007
end
end
end
x.run_action(:run)
end
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?
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 - 864007
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 - 864007
end
end
end
x.run_action(:run)
end
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?
@sam, it works, but that is just for the example I cited.
There are other dependent cookbooks, for eg mysql cookbook, nginx, etc.
I won't be adding those lines in those cookbooks, right?
I haven't tried that yet - was doing it manually before.
On Sat, May 18, 2013 at 9:02 AM, Sam Darwin <samuel.d.darwin@gmail.com<javascript:_e({}, 'cvml', 'samuel.d.darwin@gmail.com');>>
wrote:
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 - 864007
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 - 864007
end
end
end
x.run_action(:run)
end
On Sat, May 18, 2013 at 2:27 PM, millisami r <millisami@gmail.com<javascript:_e({}, 'cvml', 'millisami@gmail.com');>>
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?
Cookbooks shouldn't run "apt-get update" on every single chef-client
run, and probably most aren't. You can add that code into your
cookbooks manually, even site cookbooks, yes. You can contact the
official cookbook authors and ask them to add code like that ..
@sam, it works, but that is just for the example I cited.
There are other dependent cookbooks, for eg mysql cookbook, nginx, etc.
I won't be adding those lines in those cookbooks, right?
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 - 864007
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 - 864007
end
end
end
x.run_action(:run)
end
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?
You'll probably make mirror owners grumpy if you do, they probably won't
appreciate being hit by a slew of servers every 30 minutes (unless
you're running your own mirror/repository).
Paul
On 5/19/2013 10:19 PM, Sam Darwin wrote:
Millisami,
Cookbooks shouldn't run "apt-get update" on every single chef-client
run, and probably most aren't. You can add that code into your
cookbooks manually, even site cookbooks, yes. You can contact the
official cookbook authors and ask them to add code like that ..
@sam, it works, but that is just for the example I cited.
There are other dependent cookbooks, for eg mysql cookbook, nginx, etc.
I won't be adding those lines in those cookbooks, right?
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 - 864007
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 - 864007
end
end
end
x.run_action(:run)
end
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?
Right, cookbooks should be using something along the lines of Package, and
if you aren't able to resolve this automatically in a chef run, then
including a call to an apt recipe to update the repo information in the run
should resolve the issue automatically if run-time order is resolved
correctly.
--
~~ StormeRider ~~
"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."
Cookbooks shouldn't run "apt-get update" on every single chef-client
run, and probably most aren't. You can add that code into your
cookbooks manually, even site cookbooks, yes. You can contact the
official cookbook authors and ask them to add code like that ..
@sam, it works, but that is just for the example I cited.
There are other dependent cookbooks, for eg mysql cookbook, nginx, etc.
I won't be adding those lines in those cookbooks, right?
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 - 864007
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 - 864007
end
end
end
x.run_action(:run)
end
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?