Created
March 14, 2019 22:20
-
-
Save natemccurdy/bc5386b5423ba85ae31b224b6ca4fee0 to your computer and use it in GitHub Desktop.
Getting a package version from PE's package inventory feature
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
# PuppetDB Query method | |
$query = "package_inventory[package_name,version,provider] {certname = \"${facts['fqdn']}\"}" | |
$pkgs_from_puppetdb = puppetdb_query($query) | |
$bash_version_from_puppetdb = $pkgs_from_puppetdb.filter |$pkg| {$pkg['package_name'] == 'bash'}[0]['version'] | |
notice($bash_version_from_puppetdb) | |
# PE Inventory Fact method | |
$pkgs_from_inventory_fact = $facts['_puppet_inventory_1']['packages'] | |
$bash_version_from_inventory = $pkgs_from_inventory_fact.filter |$pkg| {$pkg[0] == 'bash'}[0][1] | |
notice($bash_version_from_inventory) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://puppet.com/docs/puppetdb/6.0/api/query/v4/packages.html
https://puppet.com/docs/pe/2019.0/viewing_packages_in_use.html