Skip to content

Commit 4b7c333

Browse files
authored
v 3.10.1
* pdk test unit opn Puppet 8, 7 and 6 * Test pdk container for github actions * Fixed Unknown variable: 'real_base_url' * Lints * Lints and undef fixes * Lints. Remove unit tests on Puppet 6 * Adapt tp data for spec tests * Disable param documentation check in puppet lint * Disable param documentation check in puppet lint * Lints and fixes * Fixing tests * unit tests
1 parent 5d23c2a commit 4b7c333

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+154
-128
lines changed

.github/workflows/pr.yml

+12-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
name: 'Static code analysys'
99
runs-on: ubuntu-latest
1010
timeout-minutes: 10
11-
container: puppet/puppet-dev-tools:4.x
11+
container: puppet/pdk:3.0.0.0
1212
steps:
1313
- uses: actions/checkout@v3
1414
- name: Run static validations
@@ -20,10 +20,18 @@ jobs:
2020
name: 'Unit tests'
2121
runs-on: ubuntu-latest
2222
timeout-minutes: 60
23-
container: puppet/puppet-dev-tools:4.x
23+
container: puppet/pdk:3.0.0.0
2424
steps:
2525
- uses: actions/checkout@v3
26-
- name: Run unit tests
27-
run: /usr/local/bin/pdk bundle exec rake spec
26+
- name: Run unit tests on Puppet 8
27+
run: /usr/local/bin/pdk test unit --puppet-version=8 --parallel
2828
env:
2929
BUNDLE_WITHOUT: development:system_tests:release
30+
continue-on-error: true
31+
- name: Run unit tests on Puppet 7
32+
run: /usr/local/bin/pdk test unit --puppet-version=7 --parallel
33+
env:
34+
BUNDLE_WITHOUT: development:system_tests:release
35+
continue-on-error: true
36+
37+

.puppet-lint.rc

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
--relative
2+
--no-parameter_documentation-check

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# CHANGELOG
22

3+
## 3.10.1
4+
5+
- Changed CI containers used
6+
- Unit tests for Puppet 7 and 8
7+
- Lints and fix on undefined vars
8+
- Updated tp::create_dir
9+
310
## 3.10.0
411

512
- Added support for $MAJVERSION variable in tinydata

Gemfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ group :development do
3434
gem "rubocop", '= 1.48.1', require: false
3535
gem "rubocop-performance", '= 1.16.0', require: false
3636
gem "rubocop-rspec", '= 2.19.0', require: false
37-
gem "puppet-strings", '~> 3.0', require: false
37+
gem "puppet-strings", '~> 2.0', require: false
3838
gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
3939
end
40-
group :system_tests do
41-
gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw]
42-
gem "serverspec", '~> 2.41', require: false
43-
end
40+
#group :system_tests do
41+
# gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw]
42+
# gem "serverspec", '~> 2.41', require: false
43+
#end
4444

4545
puppet_version = ENV['PUPPET_GEM_VERSION']
4646
facter_version = ENV['FACTER_GEM_VERSION']

README-legacy.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Configure the application main configuration file a custom erb template which us
178178

179179
tp::conf { 'rsyslog':
180180
template => 'site/rsyslog/rsyslog.conf.erb',
181-
options_hash => hiera('rsyslog::options_hash'),
181+
options_hash => lookup('rsyslog::options_hash'),
182182
}
183183

184184
Populate any custom directory from a Git repository (it requires Puppet Labs' vcsrepo module):

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ Configure the application main configuration file a custom erb template which us
195195

196196
tp::conf { 'rsyslog':
197197
template => 'site/rsyslog/rsyslog.conf.erb',
198-
options_hash => hiera('rsyslog::options_hash'),
198+
options_hash => lookup('rsyslog::options_hash'),
199199
}
200200

201201
Populate any custom directory from a Git repository (it requires Puppet Labs' vcsrepo module):

manifests/cli.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class tp::cli (
55
Enum['present','absent'] $ensure = 'present',
66
Boolean $manage_tp = true,
7-
Hash $tp_commands = lookup('tp::tp_commands', {}),
7+
Hash $tp_commands = pick($tp::tp_commands, {}),
88

99
Hash $options = {},
1010
Boolean $purge_dirs = true,

manifests/conf.pp

+13-13
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
#
5454
# tp::conf { 'openssh':
5555
# template => 'site/openssh/sshd_config',
56-
# options_hash => hiera('openssh::options_hash'),
56+
# options_hash => lookup('openssh::options_hash'),
5757
# }
5858
#
5959
#
@@ -237,7 +237,7 @@
237237
Variant[Undef,String] $owner = undef,
238238
Variant[Undef,String] $group = undef,
239239

240-
String $path_prefix = '',
240+
String $path_prefix = '', # lint:ignore:params_empty_string_assignment
241241
Boolean $path_parent_create = false,
242242

243243
Variant[Boolean,String] $config_file_notify = true,
@@ -300,20 +300,20 @@
300300
$real_path = "${path_prefix}${calculated_path}"
301301

302302
$local_file_params = delete_undef_values({
303-
'path' => $real_path,
304-
'mode' => $mode,
305-
'owner' => $owner,
306-
'group' => $group,
303+
'path' => $real_path,
304+
'mode' => $mode,
305+
'owner' => $owner,
306+
'group' => $group,
307307
})
308308

309309
$local_settings = delete_undef_values({
310-
"${prefix}files" => {
311-
"${base_file}" => $local_file_params,
312-
},
313-
"${base_file}_file_mode" => $mode,
314-
"${base_file}_file_owner" => $owner,
315-
"${base_file}_file_group" => $group,
316-
"${base_file}_file_path" => $real_path,
310+
"${prefix}files" => {
311+
"${base_file}" => $local_file_params,
312+
},
313+
"${base_file}_file_mode" => $mode,
314+
"${base_file}_file_owner" => $owner,
315+
"${base_file}_file_group" => $group,
316+
"${base_file}_file_path" => $real_path,
317317
})
318318
$settings = deep_merge($tp_settings,$settings_hash,$my_settings,$local_settings)
319319

manifests/create_dir.pp

+35-23
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,46 @@
1010
define tp::create_dir (
1111
Optional[String] $owner = undef,
1212
Optional[String] $group = undef,
13-
Optional[String] $mode = undef,
13+
Optional[Stdlib::Filemode] $mode = undef,
1414
Stdlib::AbsolutePath $path = $title,
1515
) {
16-
exec { "mkdir -p ${title}":
17-
command => "mkdir -p ${path}",
18-
path => $facts['path'],
19-
creates => $path,
16+
$mkdir_command = $facts['os']['family'] ? {
17+
'windows' => "New-Item -ItemType Directory -Force -Path '${path}'",
18+
default => "mkdir -p '${path}'",
2019
}
21-
if $owner {
22-
exec { "chown ${owner} ${title}":
23-
command => "chown ${owner} ${path}",
24-
path => $facts['path'],
25-
onlyif => "[ $(ls -ld ${path} | awk '{ print \$3 }') != ${owner} ]",
26-
}
20+
$command_provider = $facts['os']['family'] ? {
21+
'windows' => 'powershell',
22+
default => undef,
2723
}
28-
if $group {
29-
exec { "chgrp ${group} ${title}":
30-
command => "chgrp ${group} ${path}",
31-
path => $facts['path'],
32-
onlyif => "[ $(ls -ld ${path} | awk '{ print \$4 }') != ${group} ]",
33-
}
24+
25+
exec { "Create directory ${title}":
26+
command => $mkdir_command,
27+
path => $facts['path'],
28+
creates => $path,
29+
provider => $command_provider,
3430
}
35-
if $mode {
36-
exec { "chmod ${mode} ${title}":
37-
command => "chmod ${mode} ${path}",
38-
path => $facts['path'],
39-
subscribe => Exec["mkdir -p ${title}"],
40-
refreshonly => true,
31+
32+
if $facts['os']['family'] != 'windows' {
33+
if $owner {
34+
exec { "chown ${owner} ${title}":
35+
command => "chown '${owner}' '${path}'",
36+
path => $facts['path'],
37+
onlyif => "[ \$(stat -c '%U' '${path}') != '${owner}' ]",
38+
}
39+
}
40+
if $group {
41+
exec { "chgrp ${group} ${title}":
42+
command => "chgrp '${group}' '${path}'",
43+
path => $facts['path'],
44+
onlyif => "[ \$(stat -c '%G' '${path}') != '${group}' ]",
45+
}
46+
}
47+
if $mode {
48+
exec { "chmod ${mode} ${title}":
49+
command => "chmod '${mode}' '${path}'",
50+
path => '/bin:/sbin:/usr/sbin:/usr/bin',
51+
onlyif => "[ 0\$(stat -c '%a' '${path}') != '${mode}' ]",
52+
}
4153
}
4254
}
4355
}

manifests/dir.pp

+20-20
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155

156156
Enum['global','user'] $scope = 'global',
157157

158-
String $path_prefix = '',
158+
String $path_prefix = '', # lint:ignore:params_empty_string_assignment
159159
Boolean $path_parent_create = false,
160160

161161
Variant[Boolean,String] $config_dir_notify = true,
@@ -213,30 +213,30 @@
213213
$real_path = "${path_prefix}${calculated_path}"
214214

215215
$local_file_params = delete_undef_values({
216-
'path' => $real_path,
217-
'mode' => $mode,
218-
'owner' => $owner,
219-
'group' => $group,
220-
'recurse' => $recurse,
221-
'purge' => $purge,
222-
'force' => $force,
216+
'path' => $real_path,
217+
'mode' => $mode,
218+
'owner' => $owner,
219+
'group' => $group,
220+
'recurse' => $recurse,
221+
'purge' => $purge,
222+
'force' => $force,
223223
})
224224

225225
$local_settings = delete_undef_values({
226-
"${prefix}dirs" => {
227-
"${base_dir}" => $local_file_params,
228-
},
229-
"${base_dir}_dir_mode" => $mode,
230-
"${base_dir}_dir_owner" => $owner,
231-
"${base_dir}_dir_group" => $group,
232-
"${base_dir}_dir_path" => $real_path,
233-
"${base_dir}_dir_recurse" => $recurse,
234-
"${base_dir}_dir_purge" => $purge,
235-
"${base_dir}_dir_force" => $force,
226+
"${prefix}dirs" => {
227+
"${base_dir}" => $local_file_params,
228+
},
229+
"${base_dir}_dir_mode" => $mode,
230+
"${base_dir}_dir_owner" => $owner,
231+
"${base_dir}_dir_group" => $group,
232+
"${base_dir}_dir_path" => $real_path,
233+
"${base_dir}_dir_recurse" => $recurse,
234+
"${base_dir}_dir_purge" => $purge,
235+
"${base_dir}_dir_force" => $force,
236236
})
237237

238238
$settings = deep_merge($tp_settings,$settings_hash,$my_settings,$local_settings)
239-
$real_mode = pick_default(getvar("settings.${base_dir}_dir_mode"), getvar("settings.${prefix}dirs.${base_dir}.mode"), getvar('settings.config_dir_mode'), undef)
239+
$real_mode = pick_default(getvar("settings.${base_dir}_dir_mode"), getvar("settings.${prefix}dirs.${base_dir}.mode"), getvar('settings.config_dir_mode'), '0755')
240240
$real_owner = pick_default(getvar("settings.${base_dir}_dir_owner"), getvar("settings.${prefix}dirs.${base_dir}.owner"), getvar('settings.config_dir_owner'), undef)
241241
$real_group = pick_default(getvar("settings.${base_dir}_dir_group"), getvar("settings.${prefix}dirs.${base_dir}.group"), getvar('settings.config_dir_group'), undef)
242242
$real_recurse = pick_default(getvar("settings.${base_dir}_dir_recurse"), getvar("settings.${prefix}dirs.${base_dir}.recurse"), getvar('settings.config__dir_recurse'), undef)
@@ -314,7 +314,7 @@
314314
notify => $real_notify,
315315
recurse => $real_recurse,
316316
purge => $real_purge,
317-
# force => $real_force,
317+
# force => $real_force,
318318
}
319319
file { $real_path:
320320
* => $file_params + pick(getvar("settings.${base_dir}_dir_params"),getvar("settings.${prefix}dirs.${base_dir}.params"), {}),

manifests/init.pp

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
String $tp_group = 'root',
3535
String $tp_mode = '0755',
3636
String $check_service_command = 'puppet resource service',
37-
String $check_service_command_post = '',
37+
String $check_service_command_post = '', # lint:ignore:params_empty_string_assignment
3838
String $check_package_command = 'puppet resource package',
39-
String $check_repo_path = '',
40-
String $check_repo_path_post = '',
39+
String $check_repo_path = '', # lint:ignore:params_empty_string_assignment
40+
String $check_repo_path_post = '', # lint:ignore:params_empty_string_assignment
4141
#Stdlib::Absolutepath $tp_dir = '/etc/tp',
4242
Optional[String] $ruby_path = undef,
4343
String $lib_source = 'puppet:///modules/tp/lib/',

manifests/install.pp

+15-17
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
Hash $tp_repo_params = {},
188188
Boolean $manage_package = true,
189189
Boolean $manage_service = true,
190-
Boolean $apt_safe_trusted_key = lookup('tp::apt_safe_trusted_key', Boolean , first, false),
190+
Boolean $apt_safe_trusted_key = pick(getvar('tp::apt_safe_trusted_key'), false),
191191

192192
Boolean $cli_enable = pick(getvar('tp::cli_enable'), false),
193193
Boolean $puppi_enable = false,
@@ -239,11 +239,11 @@
239239
$extracted_file = getvar('tp_settings.release.extracted_file')
240240

241241
$local_settings = delete_undef_values({
242-
install_method => $real_install_method,
243-
repo => $repo,
244-
upstream_repo => $upstream_repo,
242+
install_method => getvar('real_install_method'),
243+
repo => getvar('repo'),
244+
upstream_repo => getvar('upstream_repo'),
245245
git_source => $real_install_method ? {
246-
'source' => $source,
246+
'source' => getvar('source'),
247247
default => undef,
248248
},
249249
destination => $real_install_method ? {
@@ -252,20 +252,18 @@
252252
default => undef,
253253
},
254254
packages => delete_undef_values({
255-
main => delete_undef_values({
256255
name => tp::title_replace(getvar('settings.packages.main.name'),$app),
257256
}),
258-
}),
259257
release => delete_undef_values({
260-
base_url => pick_default($real_base_url),
261-
file_name => $real_filename,
262-
url => $real_url,
263-
extracted_dir => $extracted_dir,
264-
extracted_file => $extracted_file,
265-
setup => delete_undef_values({
266-
enable => getvar('tp_settings.release.setup.enable'),
267-
links => getvar('tp_settings.release.setup.links'),
268-
}),
258+
base_url => getvar('real_base_url'),
259+
file_name => getvar('real_filename'),
260+
url => getvar('real_url'),
261+
extracted_dir => getvar('extracted_dir'),
262+
extracted_file => getvar('extracted_file'),
263+
setup => delete_undef_values({
264+
enable => getvar('tp_settings.release.setup.enable'),
265+
links => getvar('tp_settings.release.setup.links'),
266+
}),
269267
}),
270268
})
271269

@@ -289,7 +287,7 @@
289287
tp::setup { "tp::install::${real_install_method} ${app}":
290288
ensure => $ensure,
291289
version => $real_version,
292-
install_method => $real_install_method,
290+
install_method => $real_install_method,
293291
source_dir => getvar('settings.destination'),
294292
app => $app,
295293
on_missing_data => $on_missing_data,

manifests/install/package.pp

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
Hash $tp_repo_params = {},
105105
Boolean $manage_package = true,
106106
Boolean $manage_service = true,
107-
Boolean $apt_safe_trusted_key = lookup('tp::apt_safe_trusted_key', Boolean , first, false),
107+
Boolean $apt_safe_trusted_key = pick(getvar('tp::apt_safe_trusted_key'), false),
108108

109109
String[1] $data_module = 'tinydata',
110110

@@ -345,7 +345,7 @@
345345
}
346346
$services.each |$k| {
347347
service { $k:
348-
* => $service_defaults + pick(getvar("settings.services.${kk}.params"), getvar('settings.service_params'), {}),
348+
* => $service_defaults + pick(getvar("settings.services.${k}.params"), getvar('settings.service_params'), {}),
349349
}
350350
}
351351
}

manifests/repo.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
Variant[Undef,String[1]] $apt_release = undef,
3030
Variant[Undef,String[1]] $apt_repos = undef,
3131
Variant[Undef,String[1]] $apt_pin = undef,
32-
Boolean $apt_safe_trusted_key = lookup('tp::apt_safe_trusted_key', Boolean , first, false),
32+
Boolean $apt_safe_trusted_key = pick(getvar('tp::apt_safe_trusted_key'), false),
3333
Stdlib::Absolutepath $apt_gpg_key_dir = '/etc/apt/keyrings',
3434

3535
Variant[Undef,String[1]] $zypper_repofile_url = undef,

manifests/setup.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
# tp::setup { 'namevar': }
88
define tp::setup (
99
Tp::Install_method $install_method,
10-
Optional[StdLib::Absolutepath] $source_dir,
1110
String $app,
11+
Optional[StdLib::Absolutepath] $source_dir = undef,
1212
Variant[Boolean,String] $ensure = present,
1313
Optional[String] $version = undef,
1414
Tp::Fail $on_missing_data = pick(getvar('tp::on_missing_data'),'notify'),

0 commit comments

Comments
 (0)