Repository: ansible-collections/community.general

Issue:
Allow to pass `--select=y` to portage module
### Summary

Hello,

Users using `--oneshot` as Portage default in their config currently can't write packages in the `@world` set because there is no way to pass `--select=y` to `emerge` command line.

I think we need to introduce a parameter to the existing module to allow explicit write of packages in the world set.

Best

### Issue Type

Feature Idea

### Component Name

portage

### Additional Information

One way of configuring portage is to make `--oneshot` the default behavior, which prevents emerge to write newly installed packages into the world set by default. Of course it is still possible to explicitly ask to add packages into the world set after install through `--select=y` flag in the command line.

The behavior is explained in the man page:
```
       --select [ y | n ], -w
              Add specified packages to the world set (inverse of --oneshot).
              This  is  useful if you want to use EMERGE_DEFAULT_OPTS to make
              --oneshot behavior default.
```

From my understanding, currently `portage` Ansible module does not allow users in this setup to write packages in the world set. Maybe we could
- either add a `select` parameter with default `true`, which is the default behavior for portage, but could break behavior for Ansible users using `--oneshot` as default, as it would suddenly add packages in their world file.
- alternatively, keep `select` parameter as above, but with a blurry default like `default` so that the flag is simply not passed to `emerge` if user wants to rely on configured portage behavior.
- or add an explicit `force_world_set` (I did not find a better name but the idea is here 😛 ) which would default to `false`, which would append `--select=y` to the flags if enabled.

What do you think? I can probably provide the patch if needed for that feature if you can guide me through about which implementation would be the most suitable.


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/modules/portage.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/portage.py)

If these files are incorrect, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @Tatsh @wltjr
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->
I opened https://github.com/ansible-collections/community.general/pull/8236 to fix this issue; it does not seem it breaks much retrocompatibility. Any feedback welcomed :) 

Resolving patch:
diff --git a/plugins/modules/portage.py b/plugins/modules/portage.py
--- a/plugins/modules/portage.py
+++ b/plugins/modules/portage.py
@@ -121,6 +121,14 @@
     type: bool
     default: false
 
+  select:
+    description:
+      - If set to V(true), explicitely add the package to the world file.
+      - Please note that this option is not used for idempotency, it is only used
+        when actually installing a package.
+    type: bool
+    version_added: 8.6.0
+
   sync:
     description:
       - Sync package repositories first
@@ -374,6 +382,7 @@ def emerge_packages(module, packages):
         'loadavg': '--load-average',
         'backtrack': '--backtrack',
         'withbdeps': '--with-bdeps',
+        'select': '--select',
     }
 
     for flag, arg in emerge_flags.items():
@@ -523,6 +532,7 @@ def main():
             nodeps=dict(default=False, type='bool'),
             onlydeps=dict(default=False, type='bool'),
             depclean=dict(default=False, type='bool'),
+            select=dict(default=None, type='bool'),
             quiet=dict(default=False, type='bool'),
             verbose=dict(default=False, type='bool'),
             sync=dict(default=None, choices=['yes', 'web', 'no']),
@@ -543,6 +553,7 @@ def main():
             ['quiet', 'verbose'],
             ['quietbuild', 'verbose'],
             ['quietfail', 'verbose'],
+            ['oneshot', 'select'],
         ],
         supports_check_mode=True,
     )


Test patch: