-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(debian): use repository keyring instead of key_id
- Loading branch information
1 parent
119939d
commit db49eba
Showing
6 changed files
with
90 additions
and
2 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.. _readme_apt_keyrings: | ||
|
||
apt repositories' keyrings | ||
========================== | ||
|
||
Debian family of OSes deprecated the use of `apt-key` to manage repositories' keys | ||
in favor of using `keyring files` which contain a binary OpenPGP format of the key | ||
(also known as "GPG key public ring") | ||
|
||
As docker don't provide such key files, we created them following the | ||
official recomendations in their sites and install the resulting files. | ||
|
||
See https://docs.docker.com/engine/install/debian/#install-using-the-repository for details | ||
|
||
.. code-block:: bash | ||
$ curl -fsSL https://download.docker.com/linux/debian/gpg | \ | ||
gpg --dearmor --output docker-archive-keyring.gpg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
|
||
case platform.name | ||
when 'centos' | ||
repo_file = '/etc/yum.repos.d/docker-ce.repo' | ||
# rubocop:disable Metrics/LineLength | ||
repo_url = "https://download.docker.com/linux/#{platform.name}/$releasever/$basearch/stable" | ||
# rubocop:enable Metrics/LineLength | ||
when 'debian', 'ubuntu' | ||
# Inspec does not provide a `codename` matcher, so we add ours | ||
finger_codename = { | ||
'ubuntu-18.04' => 'bionic', | ||
'ubuntu-20.04' => 'focal', | ||
'debian-9' => 'stretch', | ||
'debian-10' => 'buster', | ||
'debian-11' => 'bullseye' | ||
} | ||
codename = finger_codename[system.platform[:finger]] | ||
|
||
repo_keyring = '/usr/share/keyrings/docker-archive-keyring.gpg' | ||
repo_file = '/etc/apt/sources.list.d/docker.list' | ||
# rubocop:disable Metrics/LineLength | ||
repo_url = "deb [signed-by=#{repo_keyring} arch=amd64] https://download.docker.com/linux/#{platform.name} #{codename} stable" | ||
# rubocop:enable Metrics/LineLength | ||
end | ||
|
||
control 'Docker repository keyring' do | ||
title 'should be installed' | ||
|
||
only_if('Requirement for Debian family') do | ||
os.debian? | ||
end | ||
|
||
describe file(repo_keyring) do | ||
it { should exist } | ||
it { should be_owned_by 'root' } | ||
it { should be_grouped_into 'root' } | ||
its('mode') { should cmp '0644' } | ||
end | ||
end | ||
|
||
control 'Docker repository' do | ||
impact 1 | ||
title 'should be configured' | ||
describe file(repo_file) do | ||
its('content') { should include repo_url } | ||
end | ||
end |