Version information
This version is compatible with:
- Puppet Enterprise 2023.8.x, 2023.7.x, 2023.6.x, 2023.5.x, 2023.4.x, 2023.3.x, 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x
- Puppet >= 7.0.0 < 9.0.0
- , , , , , ,
Start using this module
Add this module to your Puppetfile:
mod 'puppet-nomad', '3.1.0'
Learn more about managing modules with a PuppetfileDocumentation
puppet-nomad
What This Module Affects
- Installs the nomad daemon (via url or package)
- If installing from zip, you must ensure the unzip utility is available.
- Installs a configuration file (/etc/nomad.d/config.json)
- Manages the nomad service via systemd
Reference
See REFERENCE.
Limitations
Depends on the JSON gem, or a modern ruby. (Ruby 2.5 and newer are supported)
Development
Open an issue or fork and open a Pull Request
Acknowledgement
Must of this module was refactored from Kyle Anderson's great consul module available on the puppet forge. Go give him stars and likes and what not -- he deserves them!
Reference
Table of Contents
Classes
Public Classes
nomad
: Installs, configures, and manages nomadnomad::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
purge_config_dir
data_dir_mode
plugin_dir_mode
join_wan
bin_dir
version
install_method
os
download_url
download_url_base
download_extension
package_name
config_dir
extra_options
config_hash
config_defaults
config_validator
config_mode
manage_repo
manage_service
manage_service_file
pretty_config
service_enable
service_ensure
restart_on_change
env_vars
user
group
server_recovery
recovery_nomad_server_regex
recovery_nomad_server_hash
recovery_network_interface
recovery_rpc_port
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
Changelog
All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module.
v3.1.0 (2023-12-14)
Implemented enhancements:
- feat: Adding plugin_dir management #100 (attachmentgenie)
v3.0.0 (2023-08-21)
Breaking changes:
- Drop Puppet 6 support #88 (bastelfreak)
Implemented enhancements:
- Add EL9 support #98 (bastelfreak)
- Add Rocky/AlmaLinux/OracleLinux support #97 (bastelfreak)
- Ubuntu: Add support for 22.04 #96 (bastelfreak)
- puppet/systemd: Allow 5.x #95 (bastelfreak)
- puppet/hashi_stack: Allow 3.x #94 (bastelfreak)
- puppet/archive: Allow 7.x #93 (bastelfreak)
- Add Puppet 8 support #91 (bastelfreak)
- puppetlabs/stdlib: Allow 9.x #90 (bastelfreak)
- Add config validate #85 (maxadamo)
- add peers.json and script to recover from outage #82 (maxadamo)
- bump puppet/systemd to \< 5.0.0 #74 (jhoblitt)
Closed issues:
- add config validate #84
- Nomad server recover helper #77
- exec statement "reload nomad service" contains wrong command #75
Merged pull requests:
v2.2.0 (2023-01-07)
Implemented enhancements:
- Allow overriding user and group used #71 (jonasdemoor)
- Allow setting the data dir file mode #69 (optiz0r)
v2.1.0 (2022-05-23)
Implemented enhancements:
- Add fact for nomad_node_id #63 (sebastianrakel)
Merged pull requests:
- extra_options: default to undef instead of '' #64 (bastelfreak)
v2.0.0 (2021-08-27)
Breaking changes:
- Drop Debian 9; Add Debian 11 support #58 (root-expert)
Merged pull requests:
- add puppet-lint-param-docs #57 (bastelfreak)
- Allow up-to-date dependencies #55 (smortex)
- switch from camptocamp/systemd to voxpupuli/systemd #54 (bastelfreak)
- Fix variable type in env_vars documentation line #53 (bplunkert)
v1.1.0 (2021-05-14)
Implemented enhancements:
- Add support for nomad.env file / Add nomad 1.0.5 support #50 (bastelfreak)
v1.0.0 (2021-02-13)
Breaking changes:
- Aligning with upstream package layout, stdlib::to_json and install method #48 (attachmentgenie)
- removing os x support #47 (attachmentgenie)
- adding the option to setup the upstream HashiCorp repository #40 (attachmentgenie)
Closed issues:
- Default config is not in sync with upstream defaults #45
- user and group are not used #44
- Add support for puppet 7 #43
- Remove the environmentFile from service file #39
- add option to manage the upstream repo #35
- clean up init.pp params #34
- get systemd file in sync with upstream version #33
- nomad.service file large changes after upgrading to 0.0.4 #32
- Do not monkey patch JSON function #23
- Push puppet module 0.0.4 to forge #20
Merged pull requests:
- Adding puppet 7 support #46 (attachmentgenie)
- Init.pp cleanup; bump nomand 1.0.1 -> 1.0.2 #42 (attachmentgenie)
- Service file cleanup #41 (attachmentgenie)
- adding OOMScoreAdjust from upstream PR https://github.com/hashicorp/n… #38 (star3am)
- README.md: Add badges and fix links #31 (bastelfreak)
v0.0.4 (2021-01-07)
Closed issues:
- Syntax error on README.md :) #22
- donate this module to voxpupuli #21
- Add
CONSUL_HTTP_SSL
to systemd unit file #19 - Migrate this module to Vox Pupuli #18
- Reason to not support armv7l #17
- Cannot create /etc/sysconfig/nomad #10
- Replace puppet-staging with puppet-archive #7
Merged pull requests:
- prepare for 0.0.4 release #30 (attachmentgenie)
- Remove private class parameters #29 (ekohl)
- Documenting remaining params and example to puppet-strings tags #27 (attachmentgenie)
- renaming to puppet-nomad in the vox namespace, updating dependencies … #26 (attachmentgenie)
- modulesync 4.0.0-8-g292033c #25 (attachmentgenie)
- Porting functions to the modern Puppet 4.x API #16 (binford2k)
- ensure latest is often unwanted #15 (attachmentgenie)
- example doesnt show valid puppet code #14 (attachmentgenie)
- switching to upstream module to configure systemd service file #13 (attachmentgenie)
- Update version and add version parameter #12 (LEDfan)
- update systemd service #11 (damoun)
- Replace 'staging' puppet module with 'archive' #8 (herver)
- Nomad has arm builds, adding it to the $arch case #6 (ncorrare)
- correct var file setting for systemd #5 (vamitrou)
- Remove code to install Nomad UI (there is no UI for Nomad) #4 (mmickan)
- nomad agent does not have a -pid-file option #3 (phpwutz)
0.0.2 (2016-03-30)
Merged pull requests:
* This Changelog was automatically generated by github_changelog_generator
Dependencies
- puppetlabs/stdlib (>= 4.25.0 < 10.0.0)
- puppet/archive (>= 1.0.0 < 8.0.0)
- puppet/hashi_stack (>= 1.0.0 < 4.0.0)
- puppet/systemd (>= 1.1.1 < 6.0.0)
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.