Extend pkg to install from file
Was discussing this in #salt. It would be nice to specify a .deb or .rpm file and have Salt install it.
The syntax would look something like:
httpd:
pkg:
- installed
- skip_verify: True
- file: salt://packages/httpd_ubuntu1234.deb
I agree, we should be able to specify a package source that could also be a list. We should put this on 0.10.5
Implementing this will require parsing the output from shell commands that list metadata from packages, in order to get info like the package name, version, etc. Examples of the commands for various packages are below.
Arch: pacman -Qpi filename.pkg.tar.xz RHEL/CentOS/Fedora: rpm -qpi filename.rpm Ubuntu/Mint/Debian: dpkg-deb -I filename.deb
(that's an upper-case "i", not a lowercase "L")
Note that OpenSUSE, being an RPM-based distro, can use the same command as RHEL/CentOS/Fedora.
@thatch45 it looks like the way to go would be to add to the individual package-handling modules a function called install_file(), and once this in place, add the support to the pkg state.
Yes, the way to do this is in the install function for the providers, they all accept kwargs,and so we should check for the key "source" in the kwargs and then trying to install the named source. Thanks for the heads up on these @archtaku, I think this addition will be very welcome!
Ahh ok, so no additional function, just an additional kwarg to the existing install function?
You got it :)
@archtaku you might want to check the solarispkg module as it requires a "source" package to be provided similiar to how @thatch45 is suggesting.
Ooh, thanks @romeotheriault!
@romeotheriault thanks again for the advice. I just submitted a pull req for Arch, since that's what I run on my laptop and it was the easiest to test. Will work on others as time allows. I added some code in that pull req that makes it easier to check the valid remote file protocols, so I might make some changes to solarispkg.py that use this simplified code. If so, I'll be asking for your assistance to test them.
@archtaku, I merged this in, I am excited to see this included in more systems!
Thanks, I just tried my hand at extending yumpkg.py. I will be holding off on making the same changes for yumpkg5.py and zypper.py until the yumpkg.py changes have been vetted though, as this was my first crack at using Red Hat's python modules.
Thanks @archtaku, sounds good. I'll take a look at the pacman module and take a look at the valid remove file protocol part. I'll see if I can merge it in and test it in the next few days.
Sure. See what I did in pacman.py for an idea of what you'd need to do in order to check the protocol designation.
OK, status update on this. Support has been added for pacman, yum (both yumpkg and yumpkg5 modules), and zypper. Still on the to-do list are: apt.py, ebuild.py, freebsdpkg.py, and solarispkg.py.
I should be able to work on apt and freebsd, but will probably need assistance with ebuild (gentoo) and solaris. Anyone that decides to work on this should look at how pacman and zypper were done to get a general idea of how to implement this. I've been going through and making sure that there is meaningful logging when an RPM is not cached (due to things like a bad salt:// path or an http timeout), or when the local package file is not present. This kind of logging should be implemented across all distros/platforms to aid in troubleshooting.
Has win_pkg.py been done already?
On Mon, Nov 12, 2012 at 12:11 AM, Erik Johnson [email protected]:
OK, status update on this. Support has been added for pacman, yum (both yumpkg and yumpkg5 modules), and zypper. Still on the to-do list are: apt.py, ebuild.py, freebsdpkg.py, and solarispkg.py.
I should be able to work on apt and freebsd, but will probably need assistance with ebuild (gentoo) and solaris. Anyone that decides to work on this should look at how pacman and zypper were done to get a general idea of how to implement this. I've been going through and making sure that there is meaningful logging when an RPM is not cached (due to things like a bad salt:// path or an http timeout), or when the local package file is not present. This kind of logging should be implemented across all distros/platforms to aid in troubleshooting.
— Reply to this email directly or view it on GitHubhttps://github.com/saltstack/salt/issues/2291#issuecomment-10278817.
No, I haven't touched it. Don't have a windows box on which to test. Have at it!
solarispkg already has the ability to install from a file....
SMClgcc346:
pkg.installed:
- source: salt://srv/salt/pkgs/gcc-3.4.6-sol10-sparc-local.pkg
or is it something else you're trying to do as well?
I think he had just not checked it off the list yet :)
Yeah @romeotheriault, I did leave out solarispkg as well. In the next week or so I will be adding the ability to install multiple packages in the same call to install(), so I may call on you to test this.
Sure, I'd be happy to test it out. Just let me know. Thanks.