Skip to content

Latest commit

 

History

History
502 lines (319 loc) · 12.2 KB

REFERENCE.md

File metadata and controls

502 lines (319 loc) · 12.2 KB

Reference

Table of Contents

Classes

Public Classes

  • nomad: Installs, configures, and manages nomad
  • nomad::server_recovery: This class is used to generate a peers.json and a recovery script file for Nomad servers. It is used to recover from a Nomad server outage.

Private Classes

  • nomad::config: This class is called from nomad::init to install the config file.
  • nomad::install: This class is called from nomad::init to install the config file.
  • nomad::reload_service: This class is meant to be called from certain configuration changes that support reload.
  • nomad::run_service: This class is meant to be called from nomad It ensure the service is running

Classes

nomad

Installs, configures, and manages nomad

Examples

To set up a single nomad server, with several agents attached, on the server.
class { 'nomad':
  config_hash => {
    'region'     => 'us-west',
    'datacenter' => 'ptk',
    'log_level'  => 'INFO',
    'bind_addr'  => '0.0.0.0',
    'data_dir'   => '/opt/nomad',
    'server'     => {
      'enabled'          => true,
      'bootstrap_expect' => 3,
    }
  }
}
On the agent(s)
class { 'nomad':
  config_hash => {
    'region'     => 'us-west',
    'datacenter' => 'ptk',
    'log_level'  => 'INFO',
    'bind_addr'  => '0.0.0.0',
    'data_dir'   => '/opt/nomad',
    'client'     => {
      'enabled' => true,
      'servers' => [
        "nomad01.your-org.pvt:4647",
        "nomad02.your-org.pvt:4647",
        "nomad03.your-org.pvt:4647"
      ]
    }
  },
}
Install from zip file for a CPU architecture HashiCorp does not provide native packages for.
class { 'nomad':
  arch                => 'armv7l',
  install_method      => 'url',
  manage_service_file => true,
  version             => '1.0.3', # check latest version at https://github.com/hashicorp/nomad/blob/master/CHANGELOG.md
  config_hash         => {
    'region'     => 'us-west',
    'datacenter' => 'ptk',
    'log_level'  => 'INFO',
    'bind_addr'  => '0.0.0.0',
    'data_dir'   => '/opt/nomad',
    'client'     => {
      'enabled' => true,
      'servers' => [
        "nomad01.your-org.pvt:4647",
        "nomad02.your-org.pvt:4647",
        "nomad03.your-org.pvt:4647"
      ]
    }
  },
}
Disable install and service components
class { 'nomad':
  install_method => 'none',
  manage_service => false,
  config_hash    => {
    region     => 'us-west',
    datacenter => 'ptk',
    log_level  => 'INFO',
    bind_addr  => '0.0.0.0',
    data_dir   => '/opt/nomad',
    'client'     => {
      'enabled' => true,
      'servers' => [
        "nomad01.your-org.pvt:4647",
        "nomad02.your-org.pvt:4647",
        "nomad03.your-org.pvt:4647"
      ]
    }
  },
}

Parameters

The following parameters are available in the nomad class:

arch

Data type: String[1]

cpu architecture

purge_config_dir

Data type: Boolean

Purge config files no longer generated by Puppet

Default value: true

data_dir_mode

Data type: Stdlib::Filemode

Specify unix permissions for data dir directory managed by this module

Default value: '0755'

plugin_dir_mode

Data type: Stdlib::Filemode

Specify unix permissions for plugin dir directory managed by this module

Default value: '0755'

join_wan

Data type: Optional[String[1]]

join nomad cluster over the WAN

Default value: undef

bin_dir

Data type: Stdlib::Absolutepath

location of the nomad binary

Default value: '/usr/bin'

version

Data type: String[1]

Specify version of nomad binary to download.

Default value: 'installed'

install_method

Data type: Enum['none', 'package', 'url']

install via system package, download and extract from a url.

Default value: 'package'

os

Data type: String[1]

operation system to install for

Default value: downcase($facts['kernel'])

download_url

Data type: Optional[String[1]]

download url to download from

Default value: undef

download_url_base

Data type: String[1]

download hostname to down from

Default value: 'https://releases.hashicorp.com/nomad/'

download_extension

Data type: String[1]

archive type to download

Default value: 'zip'

package_name

Data type: String[1]

Only valid when the install_method == package.

Default value: 'nomad'

config_dir

Data type: Stdlib::Absolutepath

location of the nomad configuration

Default value: '/etc/nomad.d'

extra_options

Data type: Optional[String[1]]

Extra arguments to be passed to the nomad agent

Default value: undef

config_hash

Data type: Hash

Use this to populate the JSON config file for nomad.

Default value: {}

config_defaults

Data type: Hash

default set of config settings

Default value: {}

config_validator

Data type:

Variant[
    Enum['nomad_validator', 'ruby_validator'], Pattern[/\A.*\ %\z/]
  ]

Use this to set the JSON config file validation command. It defaults to nomad validator which is currenly missing some validation checks. If ruby is available on the system you could use 'ruby_validator', or create your own script (ending with space and % symbol).

Default value: 'nomad_validator'

config_mode

Data type: Stdlib::Filemode

Use this to set the JSON config file mode for nomad.

Default value: '0660'

manage_repo

Data type: Boolean

Configure the upstream HashiCorp repository. Only relevant when $nomad::install_method = 'package'.

Default value: true

manage_service

Data type: Boolean

manage the nomad service

Default value: true

manage_service_file

Data type: Boolean

create and manage the systemd service file

Default value: false

pretty_config

Data type: Boolean

Generates a human readable JSON config file.

Default value: false

service_enable

Data type: Boolean

enable the nomad service

Default value: true

service_ensure

Data type: Stdlib::Ensure::Service

ensure the state of the nomad service

Default value: 'running'

restart_on_change

Data type: Boolean

Determines whether to restart nomad agent on $config_hash changes. This will not affect reloads when service, check or watch configs change.

Default value: true

env_vars

Data type: Hash[String[1], String]

Hash of optional environment variables that should be passed to nomad

Default value: {}

user

Data type: String[1]

User to run the Nomad binary as. Also used as owner of directories and config files managed by this module.

Default value: 'root'

group

Data type: String[1]

Group to run the Nomad binary as. Also used as group of directories and config files managed by this module.

Default value: 'root'

server_recovery

Data type: Boolean

Nomad server outage recovery configuration

Default value: false

recovery_nomad_server_regex

Data type: Optional[String]

Regex to match Nomad server hostnames within the same puppet environment. It requires PuppetDB and it's mutually exclusive with nomad_server_hash.

Default value: undef

recovery_nomad_server_hash

Data type: Optional[Hash]

If you don't have the PuppetDB you can supply a Hash with server IPs and corresponding node-ids. It works without PuppetDB and it's mutually exclusive with nomad_server_regex.

Default value: undef

recovery_network_interface

Data type: Optional[String]

NIC where Nomad server IP is configured

Default value: undef

recovery_rpc_port

Data type: Stdlib::Port

Nomad server RPC port

Default value: 4647

nomad::server_recovery

This class is used to generate a peers.json and a recovery script file for Nomad servers. It is used to recover from a Nomad server outage.

Examples

using PuppetDB
class { 'nomad':
  config_hash                 => {
    'region'     => 'us-west',
    'datacenter' => 'ptk',
    'bind_addr'  => '0.0.0.0',
    'data_dir'   => '/opt/nomad',
    'server'     => {
      'enabled'          => true,
      'bootstrap_expect' => 3,
    },
  },
  server_recovery             => true,
  recovery_nomad_server_regex => 'nomad-server0',
  recovery_network_interface  => 'eth0',
}

Parameters

The following parameters are available in the nomad::server_recovery class:

nomad_server_regex

Data type: Optional[String]

Regex to match Nomad server hostnames within the same puppet environment. It's mutually exclusive with nomad_server_hash.

Default value: undef

nomad_server_hash

Data type: Optional[Hash]

If you don't have the PuppetDB you can supply a Hash with server IPs and corresponding node-ids. It's mutually exclusive with nomad_server_regex.

Default value: undef

network_interface

Data type: Optional[String]

NIC where Nomad server IP is configured

Default value: undef

rpc_port

Data type: Stdlib::Port

Nomad server RPC port

Default value: 4647