Repository: ansible-collections/community.general

Issue:
idrac_redfish_command module - requesting job_id on the output
### Summary

idrac_redfish_command CreateBiosConfigJob  command doesn't return job id now. I'm trying to check if job is completed before moving to next steps. This will ensure system is consistent state before next steps are executed.

### Issue Type

Feature Idea

### Component Name

idrac_redfish_command

### Additional Information

<!--- Paste example playbooks or commands between quotes below -->
```yaml (paste below)
- name: Create BIOS Config job
  community.general.idrac_redfish_command:
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    category: Systems
    command: CreateBiosConfigJob
  register: bios_job

- debug:
     msg: "{{ bios_job.job_id }}


```


### Code of Conduct

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


Discussion:
Files identified in the description:
* [`plugins/modules/idrac_redfish_command.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/idrac_redfish_command.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 @bhavya06 @mraineri @rajeevkallur @renxulei @tomasg2012 @xmadsen
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->
cc @jyundt
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Since "msg" typically contains a message string and isn't necessarily programmatic, I would propose adding a new return property to contain the job ID. I would recommend using something like "return_values" like we did in the common Redfish module. This is what I'm thinking specifically:

```
RETURN = '''
msg:
    description: Message with action result or error description
    returned: always
    type: str
    sample: "Action was successful"
return_values:
    description: Dictionary containing command-specific response data from the action.
    returned: on success
    type: dict
    sample: {
        "job_id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_471269252011"
    }
'''
```

Would this approach work for you?

Would the full URI of the job (rather than just the Id) be good too? I think returning the full URI would be easier for consumers since they will not need to perform any sort of URI construction when following up with additional operations.

Resolving patch:
diff --git a/plugins/modules/idrac_redfish_command.py b/plugins/modules/idrac_redfish_command.py
--- a/plugins/modules/idrac_redfish_command.py
+++ b/plugins/modules/idrac_redfish_command.py
@@ -85,6 +85,14 @@
     returned: always
     type: str
     sample: "Action was successful"
+return_values:
+    description: Dictionary containing command-specific response data from the action.
+    returned: on success
+    type: dict
+    version_added: 6.6.0
+    sample: {
+        "job_id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_471269252011"
+    }
 '''
 
 import re
@@ -128,10 +136,9 @@ def create_bios_config_job(self):
             return response
 
         response_output = response['resp'].__dict__
-        job_id = response_output["headers"]["Location"]
-        job_id = re.search("JID_.+", job_id).group()
-        # Currently not passing job_id back to user but patch is coming
-        return {'ret': True, 'msg': "Config job %s created" % job_id}
+        job_id_full = response_output["headers"]["Location"]
+        job_id = re.search("JID_.+", job_id_full).group()
+        return {'ret': True, 'msg': "Config job %s created" % job_id, 'job_id': job_id_full}
 
 
 CATEGORY_COMMANDS_ALL = {
@@ -143,6 +150,7 @@ def create_bios_config_job(self):
 
 def main():
     result = {}
+    return_values = {}
     module = AnsibleModule(
         argument_spec=dict(
             category=dict(required=True),
@@ -210,11 +218,13 @@ def main():
                 if result['ret'] is False:
                     module.fail_json(msg=to_native(result['msg']))
                 result = rf_utils.create_bios_config_job()
+                if 'job_id' in result:
+                    return_values['job_id'] = result['job_id']
 
     # Return data back or fail with proper message
     if result['ret'] is True:
         del result['ret']
-        module.exit_json(changed=True, msg='Action was successful')
+        module.exit_json(changed=True, msg='Action was successful', return_values=return_values)
     else:
         module.fail_json(msg=to_native(result['msg']))
 


Test patch: