Chefonic way to do apt-get update


#1

Hi,

what is the chef way for running apt-get update in a recipe?

for now I am using:

execute “apt_update” do
command "apt-get update"
action :run
end


#2

I’m not sure what you’re goal is with that, but if it’s just to ensure that it’s run regularly, check out the Opscode apt cookbook: https://github.com/opscode-cookbooks/apt

It ensures that apt-get update is run at least once per day.


Larry Wright
Argonaut Labs, LLC
http://argonautlabs.com

On Saturday, June 30, 2012 at 8:21 AM, David Montgomery wrote:

Hi,

what is the chef way for running apt-get update in a recipe?

for now I am using:

execute “apt_update” do
command "apt-get update"
action :run
end


#3

Nothing wrong with an execute, but the apt cookbook will do this for you as
mentioned.

Then within any other resource def you can use notifies like:

notifies :run, resources(:execute => “apt-get update”), :immediately

Notice that it’s calling ‘apt-get update’ (no dash) and not
’apt-get-update’ (with dash), which is also defined in by the apt
cookbook.

-sme

On Sat, Jun 30, 2012 at 6:21 AM, David Montgomery <davidmontgomery@gmail.com

wrote:

Hi,

what is the chef way for running apt-get update in a recipe?

for now I am using:

execute “apt_update” do
command "apt-get update"
action :run
end