Skip to content

Commit

Permalink
Merge pull request #100 from attachmentgenie/plugin_dir_management
Browse files Browse the repository at this point in the history
feat: Adding plugin_dir management
  • Loading branch information
bastelfreak authored Dec 14, 2023
2 parents 4b1b1ca + d330f59 commit 60e1e0c
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -176,6 +177,14 @@ Specify unix permissions for data dir directory managed by this module

Default value: `'0755'`

##### <a name="-nomad--plugin_dir_mode"></a>`plugin_dir_mode`

Data type: `Stdlib::Filemode`

Specify unix permissions for plugin dir directory managed by this module

Default value: `'0755'`

##### <a name="-nomad--join_wan"></a>`join_wan`

Data type: `Optional[String[1]]`
Expand Down
9 changes: 9 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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: {
Expand Down
43 changes: 43 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit 60e1e0c

Please sign in to comment.