Skip to content

Commit

Permalink
Update params
Browse files Browse the repository at this point in the history
  • Loading branch information
RiANOl committed Dec 2, 2016
1 parent 9487482 commit ed21a7e
Show file tree
Hide file tree
Showing 2 changed files with 190 additions and 99 deletions.
175 changes: 117 additions & 58 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,88 +4,148 @@
#
# === Parameters
#
# [*version*]
# Specify version of nomad binary to download.
# [*arch*]
# Architecture of nomad binary to download.
#
# [*archive_path*]
# Path used when installing nomad via the url.
#
# [*bin_dir*]
# Directory to create the symlink to the nomad binary in.
#
# [*config_defaults*]
# Configuration defaults hash. Gets merged with config_hash.
#
# [*config_dir*]
# Directory to place nomad configuration files in.
#
# [*config_hash*]
# Use this to populate the JSON config file for nomad.
#
# [*config_mode*]
# Use this to set the JSON config file mode for nomad.
#
# [*pretty_config*]
# Generates a human readable JSON config file. Defaults to `false`.
# [*download_extension*]
# The extension of the archive file containing the nomad binary to download.
#
# [*pretty_config_indent*]
# Toggle indentation for human readable JSON file. Defaults to `4`.
# [*download_url*]
# Fully qualified url to the location of the archive file containing the nomad binary.
#
# [*download_url_base*]
# Base url to the location of the archive file containing the nomad binary.
#
# [*extra_groups*]
# Extra groups to add the nomad system user to.
#
# [*extra_options*]
# Extra arguments to be passed to the nomad agent
#
# [*group*]
# Name of the group that should own the nomad configuration files.
#
# [*init_style*]
# What style of init system your system uses. Set to 'unmanaged' to disable
# managing init system files for the nomad service entirely.
#
# [*install_method*]
# Valid strings: `package` - install via system package
# `url` - download and extract from a url. Defaults to `url`.
# `none` - disable install.
#
# [*package_name*]
# Only valid when the install_method == package. Defaults to `nomad`.
# [*log_file*]
# Path used when writing log to.
#
# [*manage_group*]
# Whether to create/manage the group that should own the nomad configuration files.
#
# [*manage_service*]
# Whether to manage the nomad service.
#
# [*manage_user*]
# Whether to create/manage the user that should own nomad's configuration files.
#
# [*os*]
# OS component in the name of the archive file containing the nomad binary.
#
# [*package_ensure*]
# Only valid when the install_method == package. Defaults to `latest`.
#
# [*package_name*]
# Only valid when the install_method == package. Defaults to `nomad`.
#
# [*pretty_config*]
# Generates a human readable JSON config file. Defaults to `false`.
#
# [*pretty_config_indent*]
# Toggle indentation for human readable JSON file. Defaults to `4`.
#
# [*purge_config_dir*]
# Purge config files no longer generated by Puppet
#
# [*restart_on_change*]
# Determines whether to restart nomad agent on $config_hash changes.
# This will not affect reloads when service, check or watch configs change.
# Defaults to `true`.
# Defaults to `true`.
#
# [*extra_options*]
# Extra arguments to be passed to the nomad agent
# [*service_enable*]
# Whether to enable the nomad service to start at boot.
#
# [*init_style*]
# What style of init system your system uses.
# [*service_ensure*]
# Whether the nomad service should be running or not.
#
# [*user*]
# Name of the user that should own the nomad configuration files.
#
# [*version*]
# Specify version of nomad binary to download.
#
# [*purge_config_dir*]
# Purge config files no longer generated by Puppet
class nomad (
$manage_user = true,
$user = 'nomad',
$manage_group = true,
$extra_groups = [],
$purge_config_dir = true,
$group = 'nomad',
$bin_dir = '/usr/local/bin',
$arch = $nomad::params::arch,
$version = $nomad::params::version,
$install_method = $nomad::params::install_method,
$os = $nomad::params::os,
$download_url = undef,
$download_url_base = $nomad::params::download_url_base,
$download_extension = $nomad::params::download_extension,
$package_name = $nomad::params::package_name,
$package_ensure = $nomad::params::package_ensure,
$config_dir = '/etc/nomad',
$extra_options = '',
$config_hash = {},
$config_defaults = {},
$config_mode = $nomad::params::config_mode,
$pretty_config = false,
$pretty_config_indent = 4,
$service_enable = true,
$service_ensure = 'running',
$manage_service = true,
$restart_on_change = true,
$init_style = $nomad::params::init_style,
$arch = $::nomad::params::arch,
$archive_path = $::nomad::params::archive_path,
$bin_dir = $::nomad::params::bin_dir,
$config_defaults = $::nomad::params::config_defaults,
$config_dir = $::nomad::params::config_dir,
$config_hash = $::nomad::params::config_hash,
$config_mode = $::nomad::params::config_mode,
$download_extension = $::nomad::params::download_extension,
$download_url = $::nomad::params::download_url,
$download_url_base = $::nomad::params::download_url_base,
$extra_groups = $::nomad::params::extra_groups,
$extra_options = $::nomad::params::extra_options,
$group = $::nomad::params::group,
$init_style = $::nomad::params::init_style,
$install_method = $::nomad::params::install_method,
$log_file = $::nomad::params::log_file,
$manage_group = $::nomad::params::manage_group,
$manage_service = $::nomad::params::manage_service,
$manage_user = $::nomad::params::manage_user,
$os = $::nomad::params::os,
$package_ensure = $::nomad::params::package_ensure,
$package_name = $::nomad::params::package_name,
$pretty_config = $::nomad::params::pretty_config,
$pretty_config_indent = $::nomad::params::pretty_config_indent,
$purge_config_dir = $::nomad::params::purge_config_dir,
$restart_on_change = $::nomad::params::restart_on_change,
$service_enable = $::nomad::params::service_enable,
$service_ensure = $::nomad::params::service_ensure,
$user = $::nomad::params::user,
$version = $::nomad::params::version,
) inherits nomad::params {

# lint:ignore:140chars
$real_download_url = pick($download_url, "${download_url_base}${version}/${package_name}_${version}_${os}_${arch}.${download_extension}")
# lint:endignore

validate_bool($purge_config_dir)
validate_bool($manage_user)
validate_array($extra_groups)
validate_bool($manage_service)
validate_bool($restart_on_change)
validate_hash($config_hash)
validate_hash($config_defaults)
validate_array($extra_groups)
validate_bool($manage_group)
validate_bool($manage_service)
validate_bool($manage_user)
validate_bool($pretty_config)
validate_integer($pretty_config_indent)
validate_bool($purge_config_dir)
validate_bool($restart_on_change)
validate_bool($service_enable)

$config_hash_real = deep_merge($config_defaults, $config_hash)
validate_hash($config_hash_real)
Expand All @@ -96,19 +156,18 @@
$data_dir = undef
}


if ($config_hash_real['ports'] and $config_hash_real['ports']['rpc']) {
$rpc_port = $config_hash_real['ports']['rpc']
if ($config_hash_real['ports'] and $config_hash_real['ports']['http']) {
$http_port = $config_hash_real['ports']['http']
} else {
$rpc_port = 8400
$http_port = 4646
}

if ($config_hash_real['addresses'] and $config_hash_real['addresses']['rpc']) {
$rpc_addr = $config_hash_real['addresses']['rpc']
} elsif ($config_hash_real['client_addr']) {
$rpc_addr = $config_hash_real['client_addr']
if ($config_hash_real['addresses'] and $config_hash_real['addresses']['http']) {
$http_addr = $config_hash_real['addresses']['http']
} elsif ($config_hash_real['bind_addr']) {
$http_addr = $config_hash_real['bind_addr']
} else {
$rpc_addr = $::ipaddress_lo
$http_addr = $::ipaddress_lo
}

$notify_service = $restart_on_change ? {
Expand Down
Loading

0 comments on commit ed21a7e

Please sign in to comment.