Get package version in Salt

Having installed the latest version of package where it expects config files to do be in a path including the version number (e.g. postgresql-server), how can I get the installed version number in a variable to be used inside my state.sls file so the salt master can:

  • manage the config files in the correct path
  • use this for paths inside some jinja templated config files

If I can just get the value as a variable in the sls.

I know from the cli I can use the command:

salt minion-id pkg.version packagename

to return something like:


Update: I can get the correct version use e.g.:

{% set pg_version = salt['pkg.version']('postgresql') %}