martin
martin

Reputation: 990

saltstack install a new version of package from salt://files/

working with salt 3003.1, what's the best way to install a new version package from salt://files/ assuming the same name and version?

I have this config below, but if I put a new package there without changing versions, it won't pick it up.

mypackage:
  pkg.installed:
    - reinstall: False
    - source: salt://files/{{ pillar['env'] }}/deb/{{ pillar['mypackagelatest'] }}
  service.running:
    - enable: True
    - require:
      - file: /etc/mypackage/mypackage.toml
    - watch:
      - file: /etc/mypackage/mypackage.toml

alternatively, can I use a simple https link, no repo? thanks

Upvotes: 0

Views: 768

Answers (1)

seshadri_c
seshadri_c

Reputation: 7340

pkg.installed is a state module, and hence only takes action when necessary, i.e. it is idempotent in its action. So, unless it detects changes such as below, it will report that the specified package is already installed.

  • package not installed
  • package is newer than the one installed, etc.

It would be a good practice to stick to this approach and have versioned packages, so the package is updated (by Saltstack) when the version changes.

That said...

If this is not possible for some reason, then we can use the salt execution module pkg.install. Execution modules run every time they are called. Example:

install-mypackage:
  module.run:
    - name: pkg.install
    - sources:
        - mypackage: salt://files/mypackage-1.0-1.deb

This can be undesirable at times as this will install (on every run) the package regardless of whether the version or contents have changed.

Upvotes: 1

Related Questions