@@ -8,21 +8,25 @@ Requirements
88
99Attributes
1010----------
11+ * node[ 'fb_apt'] [ 'allow_modified_pkg_keyrings' ]
12+ * node[ 'fb_apt'] [ 'apt_update_log_path' ]
1113* node[ 'fb_apt'] [ 'config' ]
1214* node[ 'fb_apt'] [ 'distro' ]
15+ * node[ 'fb_apt'] [ 'keymap' ]
16+ * node[ 'fb_apt'] [ 'keymap' ] [ $NAME]
1317* node[ 'fb_apt'] [ 'keys' ]
1418* node[ 'fb_apt'] [ 'keyserver' ]
1519* node[ 'fb_apt'] [ 'mirror' ]
16- * node[ 'fb_apt'] [ 'preserve_sources_list_d' ]
1720* node[ 'fb_apt'] [ 'preferences' ]
21+ * node[ 'fb_apt'] [ 'preserve_sources_list_d' ]
22+ * node[ 'fb_apt'] [ 'preserve_unknown_keyrings' ]
1823* node[ 'fb_apt'] [ 'repos' ]
24+ * node[ 'fb_apt'] [ 'sources' ]
25+ * node[ 'fb_apt'] [ 'sources' ] [ $NAME]
1926* node[ 'fb_apt'] [ 'update_delay' ]
2027* node[ 'fb_apt'] [ 'want_backports' ]
2128* node[ 'fb_apt'] [ 'want_non_free' ]
2229* node[ 'fb_apt'] [ 'want_source' ]
23- * node[ 'fb_apt'] [ 'preserve_unknown_keyrings' ]
24- * node[ 'fb_apt'] [ 'allow_modified_pkg_keyrings' ]
25- * node[ 'fb_apt'] [ 'apt_update_log_path' ]
2630
2731Usage
2832-----
@@ -34,50 +38,94 @@ to 0. The actual update is done via the `execute[apt-get update]` resource,
3438which other cookbooks can suscribe to or notify as well.
3539
3640### Repository sources
41+
3742By default the cookbook will setup the base distribution repos based on the
3843codename (as defined in ` node['lsb']['codename'] ` ) using a sensible default
3944mirror for the package sources. The mirror can be customized with
40- ` node['fb_apt']['mirror'] ` ; if set to ` nil ` , base repos will not be included
41- at all in ` /etc/apt/sources.list ` . If base repos are enabled, the additional
45+ ` node['fb_apt']['mirror'] ` ; if set to ` nil ` , base repos will not be included at
46+ all in ` /etc/apt/sources.list ` . If base repos are enabled, the additional
4247` backports ` and ` non-free ` sources can be enabled with the
4348` node['fb_apt']['want_backports'] ` and ` node['fb_apt']['want_non_free'] `
4449attributes, and source code repos can be enabled with
4550` node['fb_apt']['want_source'] ` ; these all default to ` false ` .
4651
47- Additional repository sources can be added with ` node['fb_apt']['repos'] ` . By
48- default ` fb_apt ` will clobber existing contents in ` /etc/apt/sources.list.d ` to
49- ensure it has full control on the repository list; this can be disabled with
52+ Additional repository sources can be added with ` node['fb_apt']['sources'] `
53+ in this way:
54+
55+ ``` ruby
56+ node.default[' fb_apt' ][' sources' ][' cool_repo' ] = {
57+ ' url' => ' https://cool_repo.com/' ,
58+ ' suite' => ' stable' ,
59+ ' components' => [' main' ],
60+ ' key' => ' cool_repo' , # this references keymap, see below
61+ }
62+ ```
63+
64+ Entries in ` sources ` support the following keys:
65+
66+ * ` type ` - The type of repo, ` deb ` or ` deb-src ` - Optional, defaults to ` deb `
67+ * ` url ` - The URL of the repo
68+ * ` suite ` - The suite to pull from - usually the OS version codename
69+ * ` components ` - An array of components
70+ * ` options ` - If present, must be a hash of options to put, such as ` arch `
71+ * ` key ` - A special-case option. This should be a string that maps to a key
72+ in ` node['fb_apt']['keymap'] ` . The ` options ` hash will be updated with the
73+ ` signed-by ` value set to the appropriate path for the keyring generated.
74+
75+ By default ` fb_apt ` will clobber existing contents in ` /etc/apt/sources.list.d `
76+ to ensure it has full control on the repository list; this can be disabled with
5077` node['fb_apt']['preserve_sources_list_d'] ` .
5178
79+ * NOTE* : Older versions of this cookbook used ` node['fb_apt']['repos'] ` . This
80+ is deprecated. As of this writing, sources in this list will still be added
81+ to the system, but a warning will be printed. The old syntax was significantly
82+ lacking, didn't play well with keys, and was hard to modify.
83+
5284### Keys
53- They ` keys ` hash is pre-populated with any keys from pkg-owned keyrings that
54- exist in ` /etc/apt/trusted.gpg.d/ ` so you don't need to worry about keeping
55- a list of repository keys in sync.
5685
57- You can add to this, but setting a key of your keyid and a value of either ` nil `
58- or the PEM-encoded key. If ` key ` is ` nil ` the key will be automatically fetched
59- from the ` node['fb_apt']['keyserver'] ` keyserver (` keys.gnupg.net ` by default).
60- Example:
86+ The ` node['fb_apt']['keymap'] ` is designed to make it easy to work with the
87+ per-repo keys that modern Apt requires. Simple associate a PEM value with a
88+ name, and then use that name in any entries in ` node['fb_apt']['sources'] `
89+ signed by that key. ` fb_apt ` will take the PEM, generate a keyring in
90+ ` /etc/apt/trusted.gpg.d/${NAME}.gpg ` and populate the signed-by values in your
91+ ` sources.list ` .
6192
62- ```
63- node.default['fb_apt']['keys']['94558F59'] = nil
64- node.default['fb_apt']['keys']['F3EFDBD9'] = <<-eos
93+ For example:
94+
95+ ``` ruby
96+ node.default[' fb_apt' ][' keys' ][' cool' ] = <<-eos
6597-----BEGIN PGP PUBLIC KEY BLOCK-----
6698...
99+ -----END PGP PUBLIC KEY BLOCK-----
67100eos
101+
102+ node.default[' fb_apt' ][' sources' ][' cool_app' ] = {
103+ ...
104+ ' key' => ' cool' ,
105+ }
68106```
69107
70- Automatic key fetching can be disabled by setting the keyserver to ` nil ` ; this
71- will produce an exception for any unspecified key.
108+ You can also make the value a http/https URL, but if you do, the file will be
109+ placed as-is in ` trusted.gpg.d ` , so it must be of the right format. Chef's
110+ ` remote_file ` resource will be used to manage the file. This is intended for
111+ repos who make full keyrings available instead of armored PEMs.
72112
73- By default any keyring in ` /etc/apt/trusted.gpg.d ` that is not owned by a
74- package will be deleted unless you set ` preserve_unknown_keyrings ` to false.
113+ Anything in ` /etc/apt/trusted.gpg.d ` that is owned by a package or by this
114+ cookbook will be kept, but any other file in there will be removed. unless you
115+ set ` preserve_unknown_keyrings ` to false.
75116
76117If a keyring owned by a package is found to have been modified (based on
77118` dpkg -V ` ), then the run will fail, unless ` allow_modified_pkg_keyrings ` is
78119set.
79120
121+ * NOTE* : Older versions of this cookbook used ` node['fb_apt']['keys'] ` which
122+ attempted to pull keyid's from the internet and load them via the now-deprecated
123+ ` apt-key ` . Use of that API will cause a warning, though this cookbook does still
124+ support it for now. However, modern ` apt-key ` does nothing, so your config will
125+ break if you do not migrate.
126+
80127### Configuration
128+
81129APT behaviour can be customized using ` node['fb_apt']['config'] ` , which will be
82130used to populate ` /etc/apt/apt.conf ` . Note that this will take precedence over
83131anything in ` /etc/apt/apt.conf.d ` . Example:
@@ -89,6 +137,7 @@ node.default['fb_apt']['config']['Acquire::http'].merge!({
89137```
90138
91139### Preferences
140+
92141You can fine tune which versions of packages will be selected for installation
93142by tweaking APT preferences via ` node['fb_apt']['preferences'] ` . Note that we
94143clobber the contents of ` /etc/apt/preferences.d ` to ensure this always takes
@@ -104,12 +153,14 @@ node.default['fb_apt']['preferences'][
104153```
105154
106155### Distro
156+
107157As mentioned above, ` fb_apt ` can assemble the basic sources for you. It uses
108158the LSB "codename" of the current systemd to build the URLs. In the event you
109159want to use Chef to upgrade across distros, however, you can set
110160` node['fb_apt']['distro'] ` to the appropriate name and it will be used instead.
111161
112162### Logging ` apt-get update `
163+
113164Set ` node['fb_apt']['apt_update_log_path'] ` to log stdout and stderr of the
114165` apt-get update ` command invoked by this cookbook. This may be useful for
115166debugging purposes. The caller must handle log rotation.
0 commit comments