New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
salt.states.pkg add check if package installed in system, without installation/removal of package #39744
Comments
The unless and onlyif commands are only for specifying shell commands, so you would need to do This appears to be a duplicate of the above Thanks, |
I show you how to do cross-distribution way and you respond: use RPM -q. By official way of Salt, for now, I need to manually do a template and describe install on every possible distribution of some solution. Then I need to manually do a template to describe how to check does package installed, on every possible distribution. This is what you suggested me in favour of official one-liner install scripts that already do that by official way on any supported distribution. One-liners are official, and highly officially maintained source to install solutions. Salt official documentation uses one-liner as main way of install https://docs.saltstack.com/en/latest/topics/installation/#quick-install. Sorry, I see you missed my point. What you suggest is what I already implemented. I show there is no way to check if package installed, in the state file. That is all. Man, I envy you. You talk with so many best IT guys in such great Enterprise product, you can learn so much by digging-in. P.S. |
Right, the issue I linked to was to be able to use salt modules in the unless and only if array. So, you could do So the state would look like this
or something like that. |
You should also be able to do exactly what you are trying to do using the following.
Or possibly this to run if it is unable to install docker-engine
The basics of those scripts is to just setup repositories, and install the packages. |
This is great response. You can read titles, beyond them are more information on that title. 1.
|
pkg.is_installed is a hypothetical and doesn't exist ... yet. Also, it looks like I was mistaken and that test: True is not a state Runtime keyword that could be used in this way. And again, this
Is a proposed way to do the onlyif and unless in the feature request that I said this request is a duplicate of. |
Ok. Now we looked deeper, and it is really covered by other reports. I going to wait on that features resolved. Thank you great to work with you. |
@gtmanfred I'm new to salt. I want to write an SLS file to list all the available updates on a particular minion. I'm applying the state on minion itself on our salt dashboard portal. I wrote a small snippet that is pasted below. The result shows success but doesn't give output in a list format or something like that. SLS file |
A bit late to the party but this whole thread confused me until I worked out a solution - use the Linux
Will only run the command if it finds |
Description of Issue/Question
Add to
salt.states.pkg
function to check if package installed or not present, but without further installation or removal.There are one-liners for many applications.
One-liners:
sudo salt '*' grains.ls
Does not have grains that can say me if package installed.
Using a module, I can do:
salt 'ID' pkg.version _package_
That returns version, if package installed, None, if package is not installed.
But I think this functionality is obviously must be present in
salt.states.pkg
. We install packages there, we remove packages there, we update packages there, and probably we need to check if it installed?So we don't need to hack-around, putting module commands in
cmd.run
states and referencing to them from one-linercmd.run
, in sls files.As I understand, states and modules must share code, so enabling just check in
salt.states.pkg
is easy.Anyway it is already used by
salt.states.pkg
in chains of action, but we can not say not to install or remove package, just check in system.Example:
I want to use official installation script: https://get.docker.com/
Or for our fun, lets assume I want to use Salt https://bootstrap.saltstack.com in containers directly. For testing/learning purposes run states in test containers - is great approach.
Because, depending on platform - Docker/Salt installs differently. Example:
Docker team / Salt team manages this for us in this one-liners.
I want to check, does package installed, if not - run one-liner.
I don't need to think about what platform I use, after automatic onle-liner was done, if I want to update Docker version - I just use
salt.states.pkg.latest
againstdocker
package.But without function to check if package installed I need to adapt to platform, to check if Docker installed. Without that
cmd.run
does one-liner every time I run sls.I saw and tested return parameter, because it sort-of states what I need, but is not clear in documentation what this parameter does.
It bluntly installs docker. I don't need that, I need only to check, does package installed.
Setup
OR
Steps to Reproduce Issue
Use any one-liner, like https://get.docker.com/, where official one-liner manages proper install for you.
But then you need to add check that application is not installed in system, so one-liner runs only when application not installed.
The most straight way on most systems is to check if the package installed.
Otherwise we must rely that one-liner just exits with zero code if application already installed, not throws error, or thinks that we want to do reinstall procedure every time.
Versions Report
Is probably not relevant, in devel docks I found nothing.
Salt Version:
Salt: 2016.11.2
Dependency Versions:
cffi: Not Installed
cherrypy: unknown
dateutil: 2.6.0
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.9.5
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.24.0
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.8
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
Python: 2.7.13 (default, Dec 21 2016, 07:16:46)
python-gnupg: Not Installed
PyYAML: 3.12
PyZMQ: 16.0.2
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.4.2
ZMQ: 4.2.0
System Versions:
dist:
machine: x86_64
release: 4.9.11-1-ARCH
system: Linux
version: Not Installed
P.S.
I don't know, maybe hack-around and feeding module commands to states is a right way, or it is not really Salt way, I rely on your experience.
The text was updated successfully, but these errors were encountered: