Skip to content

Commit

Permalink
Init.pp cleanup; bump nomand 1.0.1 -> 1.0.2 (#42)
Browse files Browse the repository at this point in the history
* removing legacy service file, removing environmentfile in favor of dropins. moving to upstream service file structure

* adding install as package example, bumping version to , changing init_style type to better reflect the code present

* adding install as package example, bumping version to , changing init_style type to better reflect the code present

* classes shouldnt be called with topscope anymore

* bumping default versions

* reverting to allow not to manage service file

* bumping default versions

Co-authored-by: Tim Meusel <[email protected]>
  • Loading branch information
attachmentgenie and bastelfreak authored Jan 17, 2021
1 parent 8ead6e7 commit f363f51
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 18 deletions.
4 changes: 2 additions & 2 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Installs, configures, and manages nomad

```puppet
class { '::nomad':
version => '1.0.1', # check latest version at https://github.com/hashicorp/nomad/blob/master/CHANGELOG.md
version => '1.0.2', # check latest version at https://github.com/hashicorp/nomad/blob/master/CHANGELOG.md
config_hash => {
'region' => 'us-west',
'datacenter' => 'ptk',
Expand Down Expand Up @@ -176,7 +176,7 @@ Data type: `String[1]`

Specify version of nomad binary to download.

Default value: `'1.0.1'`
Default value: `'1.0.2'`

##### `install_method`

Expand Down
1 change: 0 additions & 1 deletion data/common.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions hiera.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ defaults: # Used for any hierarchy level that omits these keys.
hierarchy:
- name: "architecture"
path: "os/%{facts.os.architecture}.yaml"
- name: 'common'
path: 'common.yaml'
33 changes: 28 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Installs, configures, and manages nomad
#
# @example To set up a single nomad server, with several agents attached, on the server.
# class { '::nomad':
# version => '1.0.1', # check latest version at https://github.com/hashicorp/nomad/blob/master/CHANGELOG.md
# class { 'nomad':
# version => '1.0.2', # check latest version at https://github.com/hashicorp/nomad/blob/master/CHANGELOG.md
# config_hash => {
# 'region' => 'us-west',
# 'datacenter' => 'ptk',
Expand Down Expand Up @@ -35,8 +35,31 @@
# },
# }
#
# @example Install as package from the HashiCorp repositories
# class { 'nomad':
# install_method => 'package',
# bin_dir => '/bin',
# manage_repo => true,
# package_ensure => installed,
# 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"
# ]
# }
# },
# }
#
# @example Disable install and service components
# class { '::nomad':
# class { 'nomad':
# install_method => 'none',
# init_style => false,
# manage_service => false,
Expand Down Expand Up @@ -125,7 +148,7 @@
String[1] $group = 'nomad',
Optional[String[1]] $join_wan = undef,
Stdlib::Absolutepath $bin_dir = '/usr/local/bin',
String[1] $version = '1.0.1',
String[1] $version = '1.0.2',
Enum['url', 'package', 'none'] $install_method = 'url',
String[1] $os = downcase($facts['kernel']),
Optional[String[1]] $download_url = undef,
Expand All @@ -144,7 +167,7 @@
Stdlib::Ensure::Service $service_ensure = 'running',
Boolean $manage_service = true,
Boolean $restart_on_change = true,
Variant[String[1], Boolean] $init_style = $facts['service_provider'],
Variant[Enum['systemd', 'launchd'], Boolean] $init_style = $facts['service_provider'],
) {
$real_download_url = pick($download_url, "${download_url_base}${version}/${package_name}_${version}_${os}_${arch}.${download_extension}")
$config_hash_real = deep_merge($config_defaults, $config_hash)
Expand Down
8 changes: 4 additions & 4 deletions spec/acceptance/standard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@ class { 'nomad':
it { should be_directory }
end

describe file('/opt/puppet-archive/nomad-1.0.1') do
describe file('/opt/puppet-archive/nomad-1.0.2') do
it { should be_directory }
end

describe file('/opt/puppet-archive/nomad-1.0.1/nomad') do
describe file('/opt/puppet-archive/nomad-1.0.2/nomad') do
it { should be_file }
end

describe file('/usr/local/bin/nomad') do
it { should be_symlink }
it { should be_linked_to '/opt/puppet-archive/nomad-1.0.1/nomad' }
it { should be_linked_to '/opt/puppet-archive/nomad-1.0.2/nomad' }
end

describe service('nomad') do
it { should be_enabled }
end

describe command('nomad version') do
its(:stdout) { should match(/Nomad v1\.0\.1/) }
its(:stdout) { should match(/Nomad v1\.0\.2/) }
end

end
Expand Down
8 changes: 4 additions & 4 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
end

context "When installing via URL by default" do
it { should contain_archive('/opt/puppet-archive/nomad-1.0.1.zip').with(:source => 'https://releases.hashicorp.com/nomad/1.0.1/nomad_1.0.1_linux_amd64.zip') }
it { should contain_archive('/opt/puppet-archive/nomad-1.0.2.zip').with(:source => 'https://releases.hashicorp.com/nomad/1.0.2/nomad_1.0.2_linux_amd64.zip') }
it { should contain_file('/opt/puppet-archive').with(:ensure => 'directory') }
it { should contain_file('/opt/puppet-archive/nomad-1.0.1').with(:ensure => 'directory') }
it { should contain_file('/opt/puppet-archive/nomad-1.0.2').with(:ensure => 'directory') }
it { should contain_file('/usr/local/bin/nomad').that_notifies('Class[nomad::run_service]') }
end

Expand All @@ -83,7 +83,7 @@
let(:params) {{
:download_url => 'http://myurl',
}}
it { should contain_archive('/opt/puppet-archive/nomad-1.0.1.zip').with(:source => 'http://myurl') }
it { should contain_archive('/opt/puppet-archive/nomad-1.0.2.zip').with(:source => 'http://myurl') }
it { should contain_file('/usr/local/bin/nomad').that_notifies('Class[nomad::run_service]') }
end

Expand All @@ -100,7 +100,7 @@
:install_method => 'none'
}}
it { should_not contain_package('nomad') }
it { should_not contain_archive('/opt/puppet-archive/nomad-1.0.1.zip') }
it { should_not contain_archive('/opt/puppet-archive/nomad-1.0.2.zip') }
end


Expand Down

0 comments on commit f363f51

Please sign in to comment.