Skip to content

Commit

Permalink
Add nomad_job port parameter (#7412)
Browse files Browse the repository at this point in the history
* Add nomad_job port parameter

* Add changelog frag

* Update doc frag

* Fix trailing whitespace

* Add port to nomad_info

* Update changelogs/fragments/7412-add-port-for-nomad-connection.yaml

Co-authored-by: Felix Fontein <[email protected]>

* Update plugins/doc_fragments/nomad.py

Co-authored-by: Felix Fontein <[email protected]>

* Add space

* Remove trailing whitespace

---------

Co-authored-by: Felix Fontein <[email protected]>
  • Loading branch information
apecnascimento and felixfontein authored Oct 25, 2023
1 parent 58846a6 commit 714e060
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/7412-add-port-for-nomad-connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- nomad_job, nomad_job_info - add ``port`` parameter (https://github.com/ansible-collections/community.general/pull/7412).
6 changes: 6 additions & 0 deletions plugins/doc_fragments/nomad.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions plugins/modules/nomad_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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'),
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/nomad_job_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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'),
Expand Down

0 comments on commit 714e060

Please sign in to comment.