ansible/ansible — pull request #7449 by Tatsh (2014-05-19 11:03:20+00:00)
Title: Add support for Portage emerge's --getbinpkg and --usepkgonly

`PORTAGE_BINHOST` allows for quick re-installation on a single machine (example given), and fast distribution of packages for machines that have the same configuration so that only one machine has to do the compiling.

For more information about `PORTAGE_BINHOST`, see https://wiki.gentoo.org/wiki/Binary_package_guide#Rationale

In short form, the arguments `--getbinpkg` and `--usepkgonly` are used in conjunction with `make.conf` with a properly set-up `PORTAGE_BINHOST` argument like the following to a server via SSH:

```bash
PORTAGE_BINHOST="ssh://somename@192.168.1.100/mnt/portage-stuff/packages"
```

`/mnt/portage-stuff/packages` contains the compiled packages and special metadata such as USE flags so that a match is not made if the USE flags on the target machine are not the same. In that case, if only `getbinpkg` is used, the package will then be compiled. If `usepkgonly` is used, then Portage will exit with a failure because it will not not have the pre-built package expected.

If someone wishes to use this feature on a remote machine, they should install a `make.conf` with the proper configuration prior to using the new arguments with the portage module.

Defined task:
```yaml
- name: 'Install Wine'
portage: quiet=yes state=present update=yes package=wine newuse=yes usepkgonly=yes state=emerged
```

Note that `usepkgonly=yes` is effectively `usepkgonly=yes getbinpkg=yes` or `-gK` to the `emerge` command.

This correctly gives the `changed` value:
```
TASK: [system | Install Wine] ***********
changed: [devbox] => {"changed": true, "cmd": ["/usr/bin/emerge", "--update", "--newuse", "--quiet", "--usepkgonly", "--getbinpkg", "wine"], "item": "", "msg": "Packages installed.", "rc": 0, "stderr": "", "stdout": ">>> Running pre-merge checks for app-emulation/wine-1.7.18\n>>> Emerging binary (1 of 1) app-emulation/wine-1.7.18::gentoo\n>>> Installing (1 of 1) app-emulation/wine-1.7.18\n>>> Recording app-emulation/wine in \"world\" favorites file...\n"}
```

Run again after installation:
```
TASK: [system | Install Wine] ***********
ok: [devbox] => {"changed": false, "cmd": ["/usr/bin/emerge", "--update", "--newuse", "--quiet", "--usepkgonly", "--getbinpkg", "wine"], "item": "", "msg": "Packages installed.", "rc": 0, "stderr": "", "stdout": ""}
```