We are using salt stack to deploy our app as a debian package. The application itself is Scala and uses Java style versioning, e.g. during development the version number stays for example at 1.5.0-SNAPSHOT. But the package itself is always updated.
The problem is that salt stack only re-install when there is an update to the version. But for us the version stays the same but the content changes.
So far we are helping ourselves by always removing the package first
my-app-removed: pkg.removed:
- name: my-app
my-app: pkg.installed:
- sources:
- my-app: salt://my-app-1-5-0-SNAPSHOT.deb
But this always re-installs, so state.highstate always triggers a change. Is there another way to this, to make dpkg / pkg on debian to also upgrade same version numbers if, and only if, the content changed?
We also checked the verify flag for the pkg state (which basically installs also if any file changed), but that didn't work and the doc also says only yum supports it at the moment.
The onchanges
requisite makes a state run only if the dependent state has changes. So, I'd keep a local cache of the .deb file, and detect when it changes, and only remove the pkg if the file changes. (You also do the install from the locally cached file.)
snapshot-deb-file:
file.managed:
- name: /var/cache/my-app-1-5-0-SNAPSHOT.deb
- source: salt://my-app-1-5-0-SNAPSHOT.deb
my-app-removed:
pkg.removed:
- name: my-app
- onchanges:
- file: snapshot-deb-file
my-app:
pkg.installed:
- sources:
- my-app: /var/cache/my-app-1-5-0-SNAPSHOT.deb