Skip to content

Latest commit

 

History

History
650 lines (410 loc) · 16 KB

REFERENCE.md

File metadata and controls

650 lines (410 loc) · 16 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

Resource types

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

Resource types

nomad_key_value

Manage Nomad key value objects.

Examples

handling keys in the key value store
nomad_key_value {
  default:
    ensure          => present,
    address         => 'https://127.0.0.1:4646',
    token           => $nomad_token.unwrap,
    tls_server_name => 'nomad.example.org',
    ca_cert         => '/etc/ssl/certs/COMODO_OV.crt',
    require         => Class['nomad'];
  'test/keys':
    value  => {
      'key1' => 'value1',
      'key2' => 'value2',
    };
  'test_again/keys':
    ensure => absent,
    value  => {
      'key1' => 'value13',
      'key2' => 'value21',
    };
}

Properties

The following properties are available in the nomad_key_value type.

ensure

Valid values: present, absent

The basic property that the resource should be in.

Default value: present

value

The key-value pairs to set

Parameters

The following parameters are available in the nomad_key_value type.

address

Nomad URL, with scheme and port number. It defaults to http://127.0.0.1:4646

Default value: http://127.0.0.1:4646

binary_path

Path to the nomad binary. Can be an absolute path or just "nomad" if it is in the PATH.

ca_cert

Path to a PEM-encoded CA certificate file to use to verify the Nomad server SSL certificate.

Default value: ''

ca_path

Path to a directory of PEM-encoded CA certificate files to verify the Nomad server SSL certificate.

Default value: ''

client_cert

Path to the client certificate file to use to authenticate to the Nomad server.

Default value: ''

client_key

Path to the client private key file to use to authenticate to the Nomad server.

Default value: ''

name

namevar

Name of the path object containing the key/value pairs

namespace

The namespace to query. If unspecified, it will use the default namespace.

Default value: ''

provider

The specific backend to use for this nomad_key_value resource. You will seldom need to specify this --- Puppet will usually discover the appropriate provider for your platform.

region

Name of the region. It defaults to global

Default value: global

skip_verify

Valid values: true, false, yes, no

Skip Nomad certificate verification. Defaults to false.

Default value: false

tls_server_name

The server name to use as the SNI host when connecting via TLS.

Default value: ''

token

Nomad token with read and write access to the variables

Default value: ''