Skip to content

Instantly share code, notes, and snippets.

@FlorinAsavoaie
Last active October 6, 2017 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FlorinAsavoaie/c4694582f6613d10c39aff243d3599ad to your computer and use it in GitHub Desktop.
Save FlorinAsavoaie/c4694582f6613d10c39aff243d3599ad to your computer and use it in GitHub Desktop.
External Puppet fact listing leaf packages of Yum, without depending on yum-utils.
#!/usr/bin/env python
# This is to be used as an external Puppet fact that can tell you what are the
# leaf packages (the ones that no other package has a dependency on) installed
# on RHEL based a machine.
import logging
from yum import YumBase
logging.getLogger('yum.verbose.YumPlugins').setLevel(logging.CRITICAL)
print '%s: %s' % ('leaf_packages',
[ package.name for package in YumBase().rpmdb.returnLeafNodes() ])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment