diff --git a/changelogs/fragments/7412-add-port-for-nomad-connection.yaml b/changelogs/fragments/7412-add-port-for-nomad-connection.yaml new file mode 100644 index 0000000000..599883d414 --- /dev/null +++ b/changelogs/fragments/7412-add-port-for-nomad-connection.yaml @@ -0,0 +1,2 @@ +minor_changes: + - nomad_job, nomad_job_info - add ``port`` parameter (https://github.com/ansible-collections/community.general/pull/7412). \ No newline at end of file diff --git a/plugins/doc_fragments/nomad.py b/plugins/doc_fragments/nomad.py index b19404e830..0c420eb8e9 100644 --- a/plugins/doc_fragments/nomad.py +++ b/plugins/doc_fragments/nomad.py @@ -18,6 +18,12 @@ options: - 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 index 94f5b4a0ce..87e8ec04ca 100644 --- a/plugins/modules/nomad_job.py +++ b/plugins/modules/nomad_job.py @@ -71,6 +71,14 @@ EXAMPLES = ''' 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 index 00076ffed1..bd7cf8ca98 100644 --- 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'),