Repository: ansible-collections/community.general

Issue:
add no-deps option to ansible_galaxy_install for collections
### Summary

I'd like to only have the collections and their versions that I explicitly described in `requirements.yml` downloaded by ansible-galaxy. There is a `--no-deps` switch available in `ansible-galaxy collection/role install`, but it is not exposed as an option by the module.

I only need this for `type: collection` - but it would of course be nice if it also would work of `type: both` or `type: role` is specified. Potentially there need to be 2 options to be able to install roles with and collections without dependencies for example.

### Issue Type

Feature Idea

### Component Name

ansible_galaxy_install

### Additional Information

<!--- Paste example playbooks or commands between quotes below -->
```yaml (paste below)

```


### Code of Conduct

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


Discussion:
Files identified in the description:
* [`plugins/modules/packaging/language/ansible_galaxy_install.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/packaging/language/ansible_galaxy_install.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 @russoz
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Thanks for placing the ticket, @MarkusTeufelberger , will be looking into that in the next days/weeks. 

Resolving patch:
diff --git a/plugins/modules/packaging/language/ansible_galaxy_install.py b/plugins/modules/packaging/language/ansible_galaxy_install.py
--- a/plugins/modules/packaging/language/ansible_galaxy_install.py
+++ b/plugins/modules/packaging/language/ansible_galaxy_install.py
@@ -53,6 +53,12 @@
         Please notice that C(ansible-galaxy) will not install collections with I(type=both), when I(requirements_file)
         contains both roles and collections and I(dest) is specified.
     type: path
+  no_deps:
+    description:
+      - Refrain from installing dependencies.
+    version_added: 4.5.0
+    type: bool
+    default: false
   force:
     description:
       - Force overwriting an existing role or collection.
@@ -178,7 +184,7 @@ class AnsibleGalaxyInstall(CmdModuleHelper):
     ansible_version = None
     is_ansible29 = None
 
-    output_params = ('type', 'name', 'dest', 'requirements_file', 'force')
+    output_params = ('type', 'name', 'dest', 'requirements_file', 'force', 'no_deps')
     module = dict(
         argument_spec=dict(
             type=dict(type='str', choices=('collection', 'role', 'both'), required=True),
@@ -186,6 +192,7 @@ class AnsibleGalaxyInstall(CmdModuleHelper):
             requirements_file=dict(type='path'),
             dest=dict(type='path'),
             force=dict(type='bool', default=False),
+            no_deps=dict(type='bool', default=False),
             ack_ansible29=dict(type='bool', default=False),
         ),
         mutually_exclusive=[('name', 'requirements_file')],
@@ -201,6 +208,7 @@ class AnsibleGalaxyInstall(CmdModuleHelper):
         requirements_file=dict(fmt=('-r', '{0}'),),
         dest=dict(fmt=('-p', '{0}'),),
         force=dict(fmt="--force", style=ArgFormat.BOOLEAN),
+        no_deps=dict(fmt="--no-deps", style=ArgFormat.BOOLEAN),
     )
     force_lang = "en_US.UTF-8"
     check_rc = True
@@ -293,7 +301,7 @@ def __run__(self):
             self._setup29()
         else:
             self._setup210plus()
-        params = ('type', {'galaxy_cmd': 'install'}, 'force', 'dest', 'requirements_file', 'name')
+        params = ('type', {'galaxy_cmd': 'install'}, 'force', 'no_deps', 'dest', 'requirements_file', 'name')
         self.run_command(params=params)
 
     def process_command_output(self, rc, out, err):


Test patch: