While building out some recipes we discovered that triggering an apt_update as part of the flow can greatly slow things down if the system is already in a good state but the update runs anyways.
To work around this we made an apt_update call with action :nothing and then set up anything that actually requires the update to notify :before or :immediately (like before installing a package or after adding an apt repository, though the repository case can be controlled via a flag when adding).
We would like to test that the apt_update call is only triggered when necessary, and doesn't run as part of a converge that wouldn't otherwise install packages.
apt_update 'update' do
action :nothing
end
apt_repository 'git-core' do
uri 'ppa:git-core/ppa'
distribution node['lsb']['codename']
notifies :update, 'apt_update[update]', :immediately
end