Only run pkg.upgrade if there are new packages to install

933 views
Skip to first unread message

Scott Leibrand

unread,
Sep 22, 2015, 3:15:02 PM9/22/15
to Salt-users
When running highstate, I want to make sure that all packages are fully upgraded / uptodate.  I've tried both:

update-packages:
  pkg.uptodate:
    - refresh: True

and:

pkg.upgrade:
  module.run:
    - refresh: True

Those work, but they always return Changes: and blue output, even when nothing gets upgraded:

      Result: True
     Comment: Upgrade successful.
     Changes:
              ----------
              changes:
                  ----------
              comment:
              result:
                  True

Is there any way to run something that checks for upgradeable packages, returns Result: Clean and gives green output when there are no changes, and only run pkg.upgrade if there are actually new packages to install?

Thanks,
Scott

Nicholas Capo

unread,
Sep 22, 2015, 4:45:57 PM9/22/15
to Salt-users
There is a state module for installing all updates [0].
But there does not seem to be an execution modules for that.
However, I do see pkg.list_upgrades [1] and pkg.upgrade_available [2].

Also useful in your search is the sys.doc command:

List everything:
$ sudo salt-call sys.doc pkg

Only show the docs for a single module (pkg):
$ sudo salt-call sys.doc pkg

Nicholas




--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Scott Leibrand

unread,
Sep 22, 2015, 5:39:59 PM9/22/15
to salt-...@googlegroups.com
I am already using pkg.uptodate [0] (see original message below): that accomplishes the upgrade, but always returns changes even when there aren't any.

I can't use upgrade_available [2] for this purpose, as it requires a single package name: it won't operate on all installed packages.

Do you know of a way to use list_upgrades [1] in a state file rather than interactively?  I tried this, and it doesn't work:
list_upgrades:
  module.run

If I can get that to run, I'll then need to figure out some way to make the pkg.uptodate or pkg.upgrade conditional on its output...

Thanks,
Scott

--
You received this message because you are subscribed to a topic in the Google Groups "Salt-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/salt-users/RhSjWJYMOOo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to salt-users+...@googlegroups.com.

Nicholas Capo

unread,
Sep 22, 2015, 9:00:24 PM9/22/15
to salt-...@googlegroups.com

Ah, sorry...I looked right past that. If pkg.uptodate isn't stateful, that sounds like a bug to me.

Nicholas

Colton Myers

unread,
Sep 25, 2015, 12:16:27 PM9/25/15
to salt-...@googlegroups.com
That does sound like a bug to me as well. These states should be comparing before and after state and only reporting changes if something changed. Can you please file an issue on Github?

--
Colton Myers
Core Engineer, SaltStack
@basepi on Twitter/Github/IRC

Scott Leibrand

unread,
Sep 25, 2015, 2:06:12 PM9/25/15
to salt-...@googlegroups.com
Opened https://github.com/saltstack/salt/issues/27414

Please let me know if that should have any other info, or should be opened under a different repo.

Thanks,
Scott
Reply all
Reply to author
Forward
0 new messages