saltstack/salt — pull request #2491 by thekuffs (2012-11-09 00:24:23+00:00)
Title: Fix yumpkg failed install

I was having trouble installing nscd on one of my test boxes and ended up on a witch hunt to find the culprit (it was SELinux policy causing the problem). `yumpkg`s error reporting was nonexistent, making debugging the issue quite difficult.

This patch adds some error logging to the process. It also provides a potential method for collecting better information about the packages installed / upgraded / failed by yum. `_YumErrorLogger` only logs errors at the moment, but it could easily be extended to collect all the transactional details and hopefully make faster decisions than the pre/post `list_pkgs()` that we do now.

I also took the liberty of promoting `kwargs['sources']` (added in adccb3378db1ddd254ccadb7186cf9b00281c762) to a first-class keyword argument. This will make documentation and debugging easier.

Here's some example output from the new logging facility.

```
[INFO ] Selecting 'nscd' for installation
Loading mirror speeds from cached hostfile
* base: dallas.tx.mirror.xygenhosting.com
* epel: mirror.steadfast.net
* extras: dist1.800hosting.com
* updates: dallas.tx.mirror.xygenhosting.com
[DEBUG ] Added 1 transactions
[INFO ] Resolving dependencies
[INFO ] Processing transaction
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 209 k
Running rpm_check_debug
[ERROR ] Error unpacking rpm package nscd-2.12-1.80.el6_3.6.x86_64
[ERROR ] nscd-2.12-1.80.el6_3.6.x86_64 error: unpacking of archive failed on file /etc/rc.d/init.d/nscd;509c4978: cpio: open failed - Permission denied

Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
* base: dallas.tx.mirror.xygenhosting.com
* epel: mirror.steadfast.net
* extras: dist1.800hosting.com
* updates: dallas.tx.mirror.xygenhosting.com
{'local': {}}
```

I'm thinking that the return data structure from `pkg.install` could probably use a new member called `'failed'`. This would give us a more solid vector for returning errors back to the master or other facilities depending on that data.