Skip to content

Commit

Permalink
Merge pull request ceph#37922 from mgfritch/project-kubic
Browse files Browse the repository at this point in the history
cephadm: install podman from the Kubic project

Reviewed-by: Kiefer Chang <[email protected]>
Reviewed-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov authored Nov 12, 2020
2 parents a9b94c5 + 26937aa commit 4dc60e9
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 6 deletions.
7 changes: 4 additions & 3 deletions qa/distros/all/ubuntu_18.04_podman.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
os_type: ubuntu
os_version: "18.04"

# feel free to remove this test, if ppa:projectatomic is no longer maintained.
# feel free to remove this test, if Kubic project is no longer maintained.
tasks:
- exec:
all:
- sudo apt -y install software-properties-common
- sudo add-apt-repository -y ppa:projectatomic/ppa
- curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_18.04/Release.key | sudo apt-key add -
- echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_18.04/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
- sudo apt update
- sudo apt -y install podman
- echo -e "[registries.search]\nregistries = ['docker.io']" | sudo tee /etc/containers/registries.conf
52 changes: 49 additions & 3 deletions src/cephadm/cephadm
Original file line number Diff line number Diff line change
Expand Up @@ -4605,6 +4605,7 @@ class Apt(Packager):
branch=branch, commit=commit)
self.distro = self.DISTRO_NAMES[distro]
self.distro_codename = distro_codename
self.distro_version = distro_version

def repo_path(self):
return '/etc/apt/sources.list.d/ceph.list'
Expand Down Expand Up @@ -4646,15 +4647,17 @@ class Apt(Packager):
logger.info('Removing repo at %s...' % self.repo_path())
os.unlink(self.repo_path())

if self.distro == 'ubuntu':
self.rm_kubic_repo()

def install(self, ls):
logger.info('Installing packages %s...' % ls)
call_throws(['apt', 'install', '-y'] + ls)

def install_podman(self):
if self.distro == 'ubuntu':
logger.info('Setting up repo for pdoman...')
self.install(['software-properties-common'])
call_throws(['add-apt-repository', '-y', 'ppa:projectatomic/ppa'])
logger.info('Setting up repo for podman...')
self.add_kubic_repo()
call_throws(['apt', 'update'])

logger.info('Attempting podman install...')
Expand All @@ -4664,6 +4667,49 @@ class Apt(Packager):
logger.info('Podman did not work. Falling back to docker...')
self.install(['docker.io'])

def kubic_repo_url(self):
return 'https://download.opensuse.org/repositories/devel:/kubic:/' \
'libcontainers:/stable/xUbuntu_%s/' % self.distro_version

def kubic_repo_path(self):
return '/etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list'

def kubric_repo_gpgkey_url(self):
return '%s/Release.key' % self.kubic_repo_url()

def kubric_repo_gpgkey_path(self):
return '/etc/apt/trusted.gpg.d/kubic.release.gpg'

def add_kubic_repo(self):
url = self.kubric_repo_gpgkey_url()
logger.info('Installing repo GPG key from %s...' % url)
try:
response = urlopen(url)
except HTTPError as err:
logger.error('failed to fetch GPG repo key from %s: %s' % (
url, err))
raise Error('failed to fetch GPG key')
key = response.read().decode('utf-8')
tmp_key = write_tmp(key, 0, 0)
keyring = self.kubric_repo_gpgkey_path()
call_throws(['apt-key', '--keyring', keyring, 'add', tmp_key.name])

logger.info('Installing repo file at %s...' % self.kubic_repo_path())
content = 'deb %s /\n' % self.kubic_repo_url()
with open(self.kubic_repo_path(), 'w') as f:
f.write(content)

def rm_kubic_repo(self):
keyring = self.kubric_repo_gpgkey_path()
if os.path.exists(keyring):
logger.info('Removing repo GPG key %s...' % keyring)
os.unlink(keyring)

p = self.kubic_repo_path()
if os.path.exists(p):
logger.info('Removing repo at %s...' % p)
os.unlink(p)


class YumDnf(Packager):
DISTRO_NAMES = {
Expand Down

0 comments on commit 4dc60e9

Please sign in to comment.