community.general.nomad_job module – Launch a Nomad Job

Note

This module is part of the community.general collection (version 8.5.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: community.general.nomad_job.

New in community.general 1.3.0

Synopsis

  • Launch a Nomad job.

  • Stop a Nomad job.

  • Force start a Nomad job

Aliases: clustering.nomad.nomad_job

Requirements

The below requirements are needed on the host that executes this module.

  • python-nomad

Parameters

Parameter

Comments

client_cert

path

Path of certificate for TLS/SSL.

client_key

path

Path of certificate’s private key for TLS/SSL.

content

string

Content of Nomad job.

Either this or name must be specified.

content_format

string

Type of content of Nomad job.

Choices:

  • "hcl" ← (default)

  • "json"

force_start

boolean

Force job to started.

Choices:

  • false ← (default)

  • true

host

string / required

FQDN of Nomad server.

name

string

Name of job for delete, stop and start job without source.

Name of job for delete, stop and start job without source.

Either this or content must be specified.

namespace

string

Namespace for Nomad.

port

integer

added in community.general 8.0.0

Port of Nomad server.

Default: 4646

state

string / required

Deploy or remove job.

Choices:

  • "present"

  • "absent"

timeout

integer

Timeout (in seconds) for the request to Nomad.

Default: 5

token

string

ACL token for authentication.

use_ssl

boolean

Use TLS/SSL connection.

Choices:

  • false

  • true ← (default)

validate_certs

boolean

Enable TLS/SSL certificate validation.

Choices:

  • false

  • true ← (default)

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: none

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

See Also

See also

Nomad jobs documentation

Complete documentation for Nomad API jobs.

Examples

- name: Create job
  community.general.nomad_job:
    host: localhost
    state: present
    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
    state: absent
    name: api

- name: Force job to start
  community.general.nomad_job:
    host: localhost
    state: present
    name: api
    timeout: 120
    force_start: true

Authors

  • FERREIRA Christophe (@chris93111)