I have that state:
pkg.installed:
- pkgs:
- libqt4-core
- libqt4-gui
which worked fine till those packages names has been changed on new release and now this works:
pkg.installed:
- pkgs:
- libqtcore4
- libqtgui4
How to make it work regardless of the system version ?
Several possibilities exists, but I think the first step is to separate your code between states (the processing) and pillar (the data). This way you can 'inject' the packages names in your state without changing it for every new release or new OS you want to support.
Simple option using pillar is just targetting on your OS or release (using grains) the use of one pillar or another, something like
# /srv/pillar/top.sls
base:
'G@release1':
- release1
'G@release2':
- release2
# /srv/pillar/release1.sls
pkgs:
- libqt4-core
- libqt4-gui
# /srv/pillar/release2.sls
pkgs:
- libqtcore4
- libqtgui4
# /srv/salt/my_state.sls
pkg.installed:
- pkgs: {{ salt['pillar.get']('pkg', []) }}
A more complex solution is to implement this state as a 'formula' and use a map.jinja
to define different options depending of release/OS/whatever. See this answer for details https://serverfault.com/a/957401/61847. This is more complex but has a lot of benefits: isolating code for a specific software, abstract OS details, provide sane defaults pillar, and possibility of individually test this specific formula.