salt icon indicating copy to clipboard operation
salt copied to clipboard

Version support for "sources" arg in pkg.installed states

Open Cidan opened this issue 13 years ago • 31 comments

Example config:

erlang:
  pkg.installed:
    - sources:
      - esl-erlang: salt://files/packages/esl-erlangR15B02.deb

If I were to change the above config to use a deb with the version R16B02, salt does not upgrade the package because esl-erlang is already installed, and pkg.latest does not work with a "sources" parameter.

Cidan avatar Oct 11 '13 22:10 Cidan

Thanks for pointing this out. We'll get this fixed.

basepi avatar Oct 11 '13 23:10 basepi

Ah, I just got bitten by the same thing on CentOS. Therefore, bump ;)

viq avatar Dec 12 '13 12:12 viq

I too am running into this on CentOS! Working around it as we speak.

iskondi avatar Jan 10 '14 17:01 iskondi

I've run into the same problem. Any workaround?

+1

galet avatar Jan 29 '14 20:01 galet

Presently, the only solution would be to uninstall the package and reinstall the new one. This will require a modification to Salt's package management API and is a non-trivial change. It's definitely on my list of things to do, it just might take a few weeks to get to it.

terminalmage avatar Jan 29 '14 20:01 terminalmage

@galet here is my workaround:

{%- set influxdb_version = '0.5.0-rc.3' %}
# workaround issue #7772
{%- if salt['cmd.run']("dpkg-query --showformat='${Version}' -W influxdb") != influxdb_version %}
influxdb-pkg-removed:
  pkg.removed:
    - name: influxdb
    - require_in:
      - pkg: influxdb
{%- endif %}

influxdb:
  pkg.installed:
    - sources:
      - influxdb: http://s3.amazonaws.com/influxdb/influxdb_{{ influxdb_version }}_{{ grains['osarch'] }}.deb

This will uninstall the influxdb pkg if influxdb_version is different from version of influxdb pkg currently installed.

bbinet avatar Mar 06 '14 07:03 bbinet

Ran into this with my first ever .sls file https://gist.github.com/jsuchal/e63c85b4ca0a2eb9a939 and here is a workaround. https://gist.github.com/jsuchal/da156a97fa4cf7c4d856

jsuchal avatar Mar 15 '14 20:03 jsuchal

I just ran into this same issue.

It seems that a solution would be to treat sources similar names/pkgs how you can specify a version would work.

Syntax like this for example:

libzmq3:
  pkg.installed:
    - sources:
      - libzmq3:
        source: salt://libzmq3-3.2.2-13.1.x86_64.rpm
        version: 3.2.2-13.1

With the old syntax retaining the current behaviour.

I'm not too familiar with the pkg state, but it seems to me like this could be achieved by editing https://github.com/saltstack/salt/blob/develop/salt/states/pkg.py#L185 and replacing the

targets = [x for x in desired if x not in cur_pkgs]

With something like

targets = [x for x in desired if (x is not dict and x not in cur_pkgs) or (x is dict and (x['source'] not in cur_pkgs or x['version'] in cur_pkgs[x['source']]))]

Kinda ugly looking, and would need fixups elsewhere to handle using x['source'] instead of x in other places, etc but is there any reason this sort of approach wouldn't work?

nvx avatar Apr 02 '14 02:04 nvx

@nvx I've already worked out a strategy for implementing this, and know exactly how it is going to be done. It's just a matter of finding the cycles to do it.

terminalmage avatar Apr 02 '14 03:04 terminalmage

+1

ewdurbin avatar Jul 01 '14 02:07 ewdurbin

Is this fixed in the upcoming release?

harkx avatar Oct 01 '14 17:10 harkx

No. This issue will be updated when it is, so just make sure you are subscribed to notifications for this issue and you will know once it has been fixed.

terminalmage avatar Oct 01 '14 18:10 terminalmage

I have begun work on implementing this.

terminalmage avatar Jan 05 '15 15:01 terminalmage

ZD-234

rickh563 avatar Apr 06 '15 14:04 rickh563

Is this being worked on at all? It's been an open bug for 3 releases now :(

ryan-lane avatar Apr 07 '15 23:04 ryan-lane

This fix will not be part of 2015.2.0 . This fix is currently targeted for 2015.2.1 .

2015.2.0 is targeted to release very soon. 2015.2.1 will follow.

rickh563 avatar Apr 08 '15 17:04 rickh563

I had to put this aside a few months ago but I'm back working on it now.

terminalmage avatar May 13 '15 05:05 terminalmage

Thanks dude, I'm still working around this almost 2 years later, but it's all good! :)

Cidan avatar May 13 '15 05:05 Cidan

Yum support for this issue is being added in #23915 (still needs a rebase and some lint fixes). The way this is being implemented is that RPM metadata is checked and if it does not match what is installed, the package will be upgraded/downgraded accordingly.

For an example, see this gist.

terminalmage avatar May 19 '15 15:05 terminalmage

Will apt also be targeted for 2015.5.2? This is actually a blocker now for my upgrade to 2015.5 since module.run now causes watches to be fired every run (which is causing restarts of services).

ryan-lane avatar Jun 12 '15 01:06 ryan-lane