简体   繁体   English

SaltStack-版本未更改时如何重新安装软件包

[英]SaltStack - How to reinstall package when version did not change

We are using salt stack to deploy our app as a debian package. 我们正在使用Salt Stack将我们的应用程序部署为Debian软件包。 The application itself is Scala and uses Java style versioning, eg during development the version number stays for example at 1.5.0-SNAPSHOT. 该应用程序本身是Scala,并使用Java样式版本控制,例如,在开发过程中,版本号保持在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. 问题在于,只有在对该版本进行更新时,才能重新安装Salt堆栈。 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. 但这总是会重新安装,因此state.highstate总是会触发更改。 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? 还有另一种方法,只要且仅当内容更改时,才能在debian上使dpkg / pkg也升级相同的版本号?

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. 我们还检查了pkg状态的verify标志(如果更改了任何文件,它基本上也会安装),但这没有用,文档还说目前只有yum支持它。

The onchanges requisite makes a state run only if the dependent state has changes. 仅当从属状态发生更改时, onchanges必需条件才能使状态运行。 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. 因此,我将保留.deb文件的本地缓存,并检测它何时更改,并且仅在文件更改时才删除pkg。 (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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM