Repository: ansible-collections/community.general

Issue:
nomad_job module needs support host ports difent than 4646
### Summary

Currently the nomad_job module only has the host parameter, making it impossible to use ports other than the default (4646)

### Issue Type

Feature Idea

### Component Name

nomad_job

### Additional Information

<!--- Paste example playbooks or commands between quotes below -->
```yaml (paste below)
- name: Create job
  community.general.nomad_job:
    host: localhost
    port: 4645
    state: present
    content: "{{ lookup('ansible.builtin.file', 'job.hcl') }}"
    timeout: 120
```
Adding the port parameter will make it possible to use ports other than the default port

### Code of Conduct

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


Discussion:
Files identified in the description:
* [`plugins/modules/nomad_job.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/nomad_job.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 @chris93111
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/plugins/doc_fragments/nomad.py b/plugins/doc_fragments/nomad.py
--- a/plugins/doc_fragments/nomad.py
+++ b/plugins/doc_fragments/nomad.py
@@ -18,6 +18,12 @@ class ModuleDocFragment(object):
         - FQDN of Nomad server.
       required: true
       type: str
+    port:
+      description:
+        - Port of Nomad server.
+      type: int
+      default: 4646
+      version_added: 8.0.0
     use_ssl:
       description:
         - Use TLS/SSL connection.
diff --git a/plugins/modules/nomad_job.py b/plugins/modules/nomad_job.py
--- a/plugins/modules/nomad_job.py
+++ b/plugins/modules/nomad_job.py
@@ -71,6 +71,14 @@
     content: "{{ lookup('ansible.builtin.file', 'job.hcl') }}"
     timeout: 120
 
+- name: Connect with port to create job
+  community.general.nomad_job:
+    host: localhost
+    port: 4645
+    state: present
+    content: "{{ lookup('ansible.builtin.file', 'job.hcl') }}"
+    timeout: 120
+
 - name: Stop job
   community.general.nomad_job:
     host: localhost
@@ -103,6 +111,7 @@ def run():
     module = AnsibleModule(
         argument_spec=dict(
             host=dict(required=True, type='str'),
+            port=dict(type='int', default=4646),
             state=dict(required=True, choices=['present', 'absent']),
             use_ssl=dict(type='bool', default=True),
             timeout=dict(type='int', default=5),
@@ -132,6 +141,7 @@ def run():
 
     nomad_client = nomad.Nomad(
         host=module.params.get('host'),
+        port=module.params.get('port'),
         secure=module.params.get('use_ssl'),
         timeout=module.params.get('timeout'),
         verify=module.params.get('validate_certs'),
diff --git a/plugins/modules/nomad_job_info.py b/plugins/modules/nomad_job_info.py
--- a/plugins/modules/nomad_job_info.py
+++ b/plugins/modules/nomad_job_info.py
@@ -281,6 +281,7 @@ def run():
     module = AnsibleModule(
         argument_spec=dict(
             host=dict(required=True, type='str'),
+            port=dict(type='int', default=4646),
             use_ssl=dict(type='bool', default=True),
             timeout=dict(type='int', default=5),
             validate_certs=dict(type='bool', default=True),
@@ -300,6 +301,7 @@ def run():
 
     nomad_client = nomad.Nomad(
         host=module.params.get('host'),
+        port=module.params.get('port'),
         secure=module.params.get('use_ssl'),
         timeout=module.params.get('timeout'),
         verify=module.params.get('validate_certs'),


Test patch: