diff options
author | Thom May <thom@chef.io> | 2016-01-19 11:30:38 +0000 |
---|---|---|
committer | Thom May <thom@chef.io> | 2016-01-20 15:29:06 +0000 |
commit | 354cfa12ce137ef9128fdc6d2fa789e4ad5a60c7 (patch) | |
tree | 1f01ff3c078a5669022d23964521f6e8c7f75036 /lib/chef/provider | |
parent | 8d9bbbcda3b39fd1e0c8d20693c186213fdc8ffe (diff) | |
download | chef-354cfa12ce137ef9128fdc6d2fa789e4ad5a60c7.tar.gz |
Add periodic action as the default
Diffstat (limited to 'lib/chef/provider')
-rw-r--r-- | lib/chef/provider/apt_update.rb | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/chef/provider/apt_update.rb b/lib/chef/provider/apt_update.rb index f321f55018..498c83a3a6 100644 --- a/lib/chef/provider/apt_update.rb +++ b/lib/chef/provider/apt_update.rb @@ -30,11 +30,33 @@ class Chef def load_current_resource end + def action_periodic + if !apt_up_to_date? + converge_by "update new lists of packages" do + shell_out!("apt-get -q update") + end + end + end + def action_update - converge_by "retrieve new lists of packages" do + converge_by "force update new lists of packages" do shell_out!("apt-get -q update") end end + + private + # Determines whether we need to run `apt-get update` + # + # @return [Boolean] + def apt_up_to_date? + if ::File.exist?("/var/lib/apt/periodic/update-success-stamp") && + ::File.mtime("/var/lib/apt/periodic/update-success-stamp") > Time.now - new_resource.frequency + true + else + false + end + end + end end end |