Skip to content

Commit

Permalink
Add manage_packages attribute to more open-source cookbooks
Browse files Browse the repository at this point in the history
Summary: Add the ability to disable package management to more open-source cookbooks.

Differential Revision: D62007116

fbshipit-source-id: d65b991982185222639feabc3cdf71742554965c
  • Loading branch information
epilatow authored and facebook-github-bot committed Aug 30, 2024
1 parent 4715d83 commit b897ee8
Show file tree
Hide file tree
Showing 24 changed files with 102 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cookbooks/fb_cron/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Attributes
* node['fb_cron']['anacrontab']['environment']['$SETTING']
* node['fb_cron']['cron_allow']
* node['fb_cron']['cron_deny']
* node['fb_cron']['manage_packages']

Usage
-----
Expand Down Expand Up @@ -131,3 +132,8 @@ node.default['fb_cron']['cron_allow'] << 'user1'
```

This can be used for compliance with security benchmarks.

### Packages
By default this cookbook keeps the cron package up-to-date, but if you
want to manage them locally, simply set
`node['fb_cron']['manage_packages']` to false.
1 change: 1 addition & 0 deletions cookbooks/fb_cron/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@
# This is a hidden attribute because people shouldn't change this unless
# they know what they're doing.
'_crontab_path' => '/etc/cron.d/fb_crontab',
'manage_packages' => true,
}
1 change: 1 addition & 0 deletions cookbooks/fb_cron/recipes/packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

if package_name
package package_name do
only_if { node['fb_cron']['manage_packages'] }
action :upgrade
end
end
6 changes: 6 additions & 0 deletions cookbooks/fb_ethers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Requirements
Attributes
----------
* node['fb_ethers']['entries']
* node['fb_ethers']['manage_packages']

Usage
-----
Expand All @@ -22,3 +23,8 @@ node.default['fb_ethers']['entries'] = {
'50:e5:49:2f:75:c6' => 'foo03',
}
```

### Packages
By default this cookbook keeps the net-tools package up-to-date, but if you
want to manage them locally, simply set
`node['fb_ethers']['manage_packages']` to false.
1 change: 1 addition & 0 deletions cookbooks/fb_ethers/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@

default['fb_ethers'] = {
'entries' => {},
'manage_packages' => true,
}
1 change: 1 addition & 0 deletions cookbooks/fb_ethers/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

package 'net-tools' do
only_if { node.linux? }
only_if { node['fb_ethers']['manage_packages'] }
action :upgrade
end

Expand Down
6 changes: 6 additions & 0 deletions cookbooks/fb_kpatch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ Requirements
Attributes
----------
* node['fb_kpatch']['enable']
* node['fb_kpatch']['manage_packages']

Usage
-----
Include `fb_kpatch::default` to install kpatch. The daemon is enabled and
started by default; this can be controlled with `node['fb_kpatch']['enable']`.

### Packages
By default this cookbook keeps the kpatch-runtime package up-to-date, but if you
want to manage them locally, simply set
`node['fb_kpatch']['manage_packages']` to false.
1 change: 1 addition & 0 deletions cookbooks/fb_kpatch/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@

default['fb_kpatch'] = {
'enable' => true,
'manage_packages' => true,
}
1 change: 1 addition & 0 deletions cookbooks/fb_kpatch/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
end

package 'kpatch-runtime' do
only_if { node['fb_kpatch']['manage_packages'] }
action :upgrade
end

Expand Down
6 changes: 6 additions & 0 deletions cookbooks/fb_logrotate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Attributes
* node['fb_logrotate']['debug_log']
* node['fb_logrotate']['systemd_timer']
* node['fb_logrotate']['timer_settings']
* node['fb_logrotate']['manage_packages']

Usage
-----
Expand Down Expand Up @@ -238,3 +239,8 @@ Note that the use of the size property together with logrotate runs that are
more frequent than daily will result in `duplicate log entry` errors in
logrotate because the default dateformat is `-%Y%m%d`. To handle this, specify
a more granular dateformat, e.g. `-%Y%m%d%H`.

### Packages
By default this cookbook keeps the logrotate and pigz package up-to-date, but
if you want to manage them locally, simply set
`node['fb_logrotate']['manage_packages']` to false.
1 change: 1 addition & 0 deletions cookbooks/fb_logrotate/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
'configs' => configs,
'add_locking_to_logrotate' => false,
'debug_log' => false,
'manage_packages' => true,
'systemd_timer' => systemd_timer,
'systemd_settings' => {
'OnCalendar' => 'daily',
Expand Down
1 change: 1 addition & 0 deletions cookbooks/fb_logrotate/recipes/packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
#

package ['logrotate', 'pigz'] do
only_if { node['fb_logrotate']['manage_packages'] }
action :upgrade
end
6 changes: 6 additions & 0 deletions cookbooks/fb_postfix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Attributes
* node['fb_postfix']['transport']
* node['fb_postfix']['virtual']
* node['fb_postfix']['custom_headers']
* node['fb_postfix']['manage_packages']

Usage
-----
Expand Down Expand Up @@ -105,3 +106,8 @@ node.default['fb_postfix']['custom_headers']['some description'] = {

*Note*: In `main.cf`, `header_checks` is by default pointed to
`/etc/postfix/custom_headers.regexp`.

### Packages
By default this cookbook keeps the postfix package up-to-date, but if you
want to manage them locally, simply set
`node['fb_postfix']['manage_packages']` to false.
1 change: 1 addition & 0 deletions cookbooks/fb_postfix/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
# Postfix will interpret this to be hostname
'smtp_helo_name' => '$myhostname',
},
'manage_packages' => true,
# master.cf as per http://www.postfix.org/master.5.html
# In master.cf, unique by service:type and not just service.
'master.cf' => {
Expand Down
1 change: 1 addition & 0 deletions cookbooks/fb_postfix/recipes/packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
#

package 'postfix' do
only_if { node['fb_postfix']['manage_packages'] }
action :upgrade
end
6 changes: 6 additions & 0 deletions cookbooks/fb_sdparm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Attributes
----------
* node['fb_sdparm']['enforce']
* node['fb_sdparm']['settings']
* node['fb_sdparm']['manage_packages']

Usage
-----
Expand Down Expand Up @@ -56,3 +57,8 @@ node.default['fb_sdparm']['enforce'] = true
end
end
```

### Packages
By default this cookbook keeps the sdparm package up-to-date, but if you
want to manage them locally, simply set
`node['fb_sdparm']['manage_packages']` to false.
1 change: 1 addition & 0 deletions cookbooks/fb_sdparm/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

default['fb_sdparm'] = {
'enforce' => false,
'manage_packages' => true,
'settings' => {
'rotational' => {},
'non-rotational' => {},
Expand Down
1 change: 1 addition & 0 deletions cookbooks/fb_sdparm/recipes/packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
#

package 'sdparm' do
only_if { node['fb_sdparm']['manage_packages'] }
action :upgrade
end
6 changes: 6 additions & 0 deletions cookbooks/fb_sysstat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ Requirements

Attributes
----------
* node['fb_sysstat']['manage_packages']

Usage
-----
Include the cookbook in your recipe or runlist.

### Packages
By default this cookbook keeps the sysstat package up-to-date, but if you
want to manage them locally, simply set
`node['fb_sysstat']['manage_packages']` to false.
20 changes: 20 additions & 0 deletions cookbooks/fb_sysstat/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
#
# Copyright (c) 2016-present, Facebook, Inc.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
default['fb_sysstat'] = {
'manage_packages' => true,
}
1 change: 1 addition & 0 deletions cookbooks/fb_sysstat/recipes/packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
#

package 'sysstat' do
only_if { node['fb_sysstat']['manage_packages'] }
action :upgrade
end
6 changes: 6 additions & 0 deletions cookbooks/fb_tcpdump/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ Requirements

Attributes
----------
* node['fb_tcpdump']['manage_packages']

Usage
-----
#### fb_tcpdump::default
Just include the recipe in your runlist.

### Packages
By default this cookbook keeps the tcpdump package up-to-date, but if you
want to manage them locally, simply set
`node['fb_tcpdump']['manage_packages']` to false.
20 changes: 20 additions & 0 deletions cookbooks/fb_tcpdump/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
#
# Copyright (c) 2016-present, Facebook, Inc.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
default['fb_tcpdump'] = {
'manage_packages' => true,
}
1 change: 1 addition & 0 deletions cookbooks/fb_tcpdump/recipes/packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
end

package 'tcpdump' do
only_if { node['fb_tcpdump']['manage_packages'] }
action :upgrade
end

0 comments on commit b897ee8

Please sign in to comment.