Skip to content

Commit

Permalink
Add 'disable_makecache' API
Browse files Browse the repository at this point in the history
Differential Revision: D55318525

fbshipit-source-id: 23e2bcb990319bbb7c3c05f97111cd8a2f7fefc0
  • Loading branch information
cooperlees authored and facebook-github-bot committed Mar 25, 2024
1 parent 7c455a2 commit 3ee3d06
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cookbooks/fb_dnf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Requirements
Attributes
----------
* node['fb_dnf']['config'][$SECTION][$KEY][$VALUE]
* node['fb_dnf']['disable_makecache_timer']
* node['fb_dnf']['manage_packages']
* node['fb_dnf']['modules'][$MODULE][$CONFIG]
* node['fb_dnf']['repos'][$GROUP]['repos'][$REPO][$KEY][$VALUE]
Expand Down Expand Up @@ -49,6 +50,13 @@ ways:
These are not mutually exclusive and can be mixed as desired. See the README
for `fb_yum_repos` for details on how to define repositories.

### Disable dnf-makecache.timer

The dnf RPM includes a default make cache timer. This is not always required
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.

### 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,
},
},
'disable_makecache_timer' => false,
'manage_packages' => true,
'modules' => {},
'repos' => {},
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/fb_dnf/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@
end

include_recipe 'fb_dnf::packages'
# Need RPMs installed before we can disable/enable the makecache timer
include_recipe 'fb_dnf::makecache'
18 changes: 18 additions & 0 deletions cookbooks/fb_dnf/recipes/makecache.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# (c) Meta Platforms, Inc. and its affiliates. Confidential and proprietary.
#
# Cookbook Name:: fb_dnf
# Recipe:: makecache

MAKECACHE_SYSTEMD_UNIT_NAME = 'dnf-makecache.timer'.freeze

# 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'] }
action [:stop, :disable]
end

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

0 comments on commit 3ee3d06

Please sign in to comment.