Skip to content

Commit

Permalink
Make the renable optional
Browse files Browse the repository at this point in the history
Differential Revision: D55366233

fbshipit-source-id: 450a2f6a8285133f5b55064ef4670bd7dd22af72
  • Loading branch information
cooperlees authored and facebook-github-bot committed Mar 26, 2024
1 parent 2f830f4 commit 03ff688
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cookbooks/fb_dnf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ depending how one wants to use dnf. Set
`node['fb_dnf']['disable_makecache_timer']` API to `true` to stop this periodic
refresh of the dnf metadata cache.

To rollback / renable *dnf-makecahce.timer* you also need a second API boolean set:
- `node['fb_dnf']['enable_makecache_timer']` (set to `true`)
This is to protect use cases where *dnf-mcachecache.timer* is being disabled/stopped
another way.

### Modularity support
DNF supports modules which may need to be enabled, disabled, or default. You
can use `node['fb_dnf']['modules']` to configure modules. Do this via:
Expand Down
1 change: 1 addition & 0 deletions cookbooks/fb_dnf/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
'skip_if_unavailable' => node.centos? ? false : true,
},
},
'enable_makecache_timer' => false,
'disable_makecache_timer' => false,
'manage_packages' => true,
'modules' => {},
Expand Down
8 changes: 8 additions & 0 deletions cookbooks/fb_dnf/recipes/makecache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@

MAKECACHE_SYSTEMD_UNIT_NAME = 'dnf-makecache.timer'.freeze

if node['fb_dnf']['disable_makecache_timer'] && node['fb_dnf']['enable_makecache_timer']
Chef::Log.error(
'[fb_dnf] Something has set BOTH disable + enable makecache timer - Nothing will happen!',
)
end

# If API is set to true, stop + disable the timer
systemd_unit MAKECACHE_SYSTEMD_UNIT_NAME do
only_if { node['fb_dnf']['disable_makecache_timer'] }
not_if { node['fb_dnf']['enable_makecache_timer'] }
action [:stop, :disable]
end

# If API is set to false, start + enable the timer
systemd_unit MAKECACHE_SYSTEMD_UNIT_NAME do
only_if { node['fb_dnf']['enable_makecache_timer'] }
not_if { node['fb_dnf']['disable_makecache_timer'] }
action [:start, :enable]
end

0 comments on commit 03ff688

Please sign in to comment.