salt icon indicating copy to clipboard operation
salt copied to clipboard

Extend pkg to install from file

Open scott-w opened this issue 14 years ago • 66 comments

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

scott-w avatar Oct 19 '12 14:10 scott-w

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

thatch45 avatar Oct 19 '12 15:10 thatch45

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.

terminalmage avatar Oct 19 '12 17:10 terminalmage

@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.

terminalmage avatar Oct 19 '12 18:10 terminalmage

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!

thatch45 avatar Oct 19 '12 19:10 thatch45

Ahh ok, so no additional function, just an additional kwarg to the existing install function?

terminalmage avatar Oct 19 '12 19:10 terminalmage

You got it :)

thatch45 avatar Oct 19 '12 19:10 thatch45

@archtaku you might want to check the solarispkg module as it requires a "source" package to be provided similiar to how @thatch45 is suggesting.

rrtj3 avatar Oct 19 '12 20:10 rrtj3

Ooh, thanks @romeotheriault!

terminalmage avatar Oct 20 '12 16:10 terminalmage

@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.

terminalmage avatar Oct 22 '12 03:10 terminalmage

@archtaku, I merged this in, I am excited to see this included in more systems!

thatch45 avatar Oct 22 '12 04:10 thatch45

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.

terminalmage avatar Oct 22 '12 05:10 terminalmage

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.

rrtj3 avatar Oct 22 '12 19:10 rrtj3

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.

terminalmage avatar Oct 22 '12 19:10 terminalmage

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.

terminalmage avatar Nov 12 '12 07:11 terminalmage

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.

UtahDave avatar Nov 12 '12 07:11 UtahDave

No, I haven't touched it. Don't have a windows box on which to test. Have at it!

terminalmage avatar Nov 12 '12 07:11 terminalmage

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?

rrtj3 avatar Nov 13 '12 06:11 rrtj3

I think he had just not checked it off the list yet :)

thatch45 avatar Nov 13 '12 06:11 thatch45

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.

terminalmage avatar Nov 13 '12 17:11 terminalmage

Sure, I'd be happy to test it out. Just let me know. Thanks.

rrtj3 avatar Nov 13 '12 19:11 rrtj3