diff --git a/REFERENCE.md b/REFERENCE.md index 5eb788b..a25ac3c 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -123,6 +123,7 @@ The following parameters are available in the `nomad` class: * [`arch`](#-nomad--arch) * [`purge_config_dir`](#-nomad--purge_config_dir) * [`data_dir_mode`](#-nomad--data_dir_mode) +* [`plugin_dir_mode`](#-nomad--plugin_dir_mode) * [`join_wan`](#-nomad--join_wan) * [`bin_dir`](#-nomad--bin_dir) * [`version`](#-nomad--version) @@ -176,6 +177,14 @@ 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]]` diff --git a/manifests/init.pp b/manifests/init.pp index 136a2e4..7a69b7a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -84,6 +84,8 @@ # Purge config files no longer generated by Puppet # @param data_dir_mode # Specify unix permissions for data dir directory managed by this module +# @param plugin_dir_mode +# Specify unix permissions for plugin dir directory managed by this module # @param join_wan # join nomad cluster over the WAN # @param bin_dir @@ -149,6 +151,7 @@ String[1] $arch, Boolean $purge_config_dir = true, Stdlib::Filemode $data_dir_mode = '0755', + Stdlib::Filemode $plugin_dir_mode = '0755', Optional[String[1]] $join_wan = undef, Stdlib::Absolutepath $bin_dir = '/usr/bin', String[1] $version = 'installed', @@ -191,6 +194,12 @@ $data_dir = undef } + if $config_hash_real['plugin_dir'] { + $plugin_dir = $config_hash_real['plugin_dir'] + } else { + $plugin_dir = undef + } + if ($config_hash_real['ports'] and $config_hash_real['ports']['rpc']) { $rpc_port = $config_hash_real['ports']['rpc'] } else { diff --git a/manifests/install.pp b/manifests/install.pp index 1d7946d..63d03f1 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -11,6 +11,15 @@ } } + if $nomad::plugin_dir { + file { $nomad::plugin_dir: + ensure => 'directory', + owner => $nomad::user, + group => $nomad::group, + mode => $nomad::plugin_dir_mode, + } + } + case $nomad::install_method { 'url': { $install_path = '/opt/puppet-archive' @@ -49,6 +58,9 @@ if $nomad::data_dir { Package[$nomad::package_name] -> File[$nomad::data_dir] } + if $nomad::plugin_dir { + Package[$nomad::package_name] -> File[$nomad::plugin_dir] + } } 'none': {} default: { diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 26482b4..9a96cab 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -226,6 +226,35 @@ it { is_expected.not_to contain_file('/dir1').with(ensure: :directory) } end + context 'When plugin_dir is provided' do + let(:params) do + { + config_hash: { + 'plugin_dir' => '/plugin_dir', + }, + } + end + + it { is_expected.to contain_file('/plugin_dir').with(ensure: :directory, mode: '0755') } + + context 'When plugin_dir_mode is provided' do + let(:params) do + { + config_hash: { + 'plugin_dir' => '/plugin_dir', + }, + plugin_dir_mode: '0750' + } + end + + it { is_expected.to contain_file('/plugin_dir').with(mode: '0750') } + end + end + + context 'When plugin_dir is not provided' do + it { is_expected.not_to contain_file('/plugin_dir').with(ensure: :directory) } + end + context 'The bootstrap_expect in config_hash is an int' do let(:params) do { @@ -443,6 +472,20 @@ it { is_expected.to contain_file('/dir1').with(ensure: 'directory', owner: 'nomad', group: 'nomad') } end + context 'with provided plugin_dir' do + let :params do + { + config_hash: { + 'plugin_dir' => '/dir1', + }, + user: 'nomad', + group: 'nomad', + } + end + + it { is_expected.to contain_file('/dir1').with(ensure: 'directory', owner: 'nomad', group: 'nomad') } + end + context 'with env_vars' do let :params do {