summaryrefslogtreecommitdiff
path: root/cloudinit/distros
diff options
context:
space:
mode:
authorLars Kellogg-Stedman <lars@redhat.com>2016-12-01 19:40:36 -0500
committerScott Moser <smoser@brickies.net>2017-01-12 13:51:05 -0500
commita3daf184fd47dede8d91588281437453bd38fc1c (patch)
tree6c93488cda0b230217317b5783e9a97a7436d9a8 /cloudinit/distros
parente55ff8f8ea9abeb7c406b2eec3e91aad8fee6f64 (diff)
downloadvyos-cloud-init-a3daf184fd47dede8d91588281437453bd38fc1c.tar.gz
vyos-cloud-init-a3daf184fd47dede8d91588281437453bd38fc1c.zip
Use dnf instead of yum when available
Recent fedora releases use "dnf" instead of "yum" for package management. While there is a compatible "yum" cli available, there's no guarantee that it will be available. With this patch, cloud-init will check for /usr/bin/dnf and use that if it exists instead of yum. rhbz: https://bugzilla.redhat.com/show_bug.cgi?id=1194451 LP: #1647118
Diffstat (limited to 'cloudinit/distros')
-rw-r--r--cloudinit/distros/rhel.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/cloudinit/distros/rhel.py b/cloudinit/distros/rhel.py
index aa558381..7498c63a 100644
--- a/cloudinit/distros/rhel.py
+++ b/cloudinit/distros/rhel.py
@@ -190,13 +190,18 @@ class Distro(distros.Distro):
if pkgs is None:
pkgs = []
- cmd = ['yum']
- # If enabled, then yum will be tolerant of errors on the command line
- # with regard to packages.
- # For example: if you request to install foo, bar and baz and baz is
- # installed; yum won't error out complaining that baz is already
- # installed.
- cmd.append("-t")
+ if util.which('dnf'):
+ LOG.debug('Using DNF for package management')
+ cmd = ['dnf']
+ else:
+ LOG.debug('Using YUM for package management')
+ # the '-t' argument makes yum tolerant of errors on the command
+ # line with regard to packages.
+ #
+ # For example: if you request to install foo, bar and baz and baz
+ # is installed; yum won't error out complaining that baz is already
+ # installed.
+ cmd = ['yum', '-t']
# Determines whether or not yum prompts for confirmation
# of critical actions. We don't want to prompt...
cmd.append("-y")